Skip to content

Commit

Permalink
DynamicLinking.md: add notes about memory/table exports
Browse files Browse the repository at this point in the history
This is my attempt to capture the discussion in
WebAssembly#232
  • Loading branch information
yamt committed Sep 3, 2024
1 parent f44d6c5 commit c855267
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DynamicLinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ connect export the final relocated addresses (i.e. they cannot add
relocation; the loader, which knows `__memory_base`, can then calculate the
final relocated address.

### Note for memory/table exports

The commonly used C conventions including WASIp1 require modules to
export the "memory" memory and the "__indirect_function_table" table.

However, because PIE executables with this dynamic-linking convention
are already importing these instance resources, it's redundant to
export them as well. For that reason, for PIE executables, we don't
require these resources exported.

Shared libraries don't need to export these instance resoures either
because it's assumed that these instance resources for the main module
are shared among linked shared libraries as well. (The runtime linkers
can validate if it's actually the case and reject loading modules
otherwise.)

On the other hand, non-PIE executables need to export these instance
resources as usual.

## Implementation Status

### LLVM Implementation
Expand Down

0 comments on commit c855267

Please sign in to comment.