Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicLinking.md: add notes about memory/table exports #234

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is "we" here? If its WASI the perhaps this belongs in the wasi repo instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it should be in both. (wasi and here)

i added it here first because i feel the memory/table convention is more widely used than just wasi.


Shared libraries don't need to export these resources either.
They should also import these resources, since they share the memory
and function table with the main module. (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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can/should add something under this header for wasi now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean to update the implementation status section?


### LLVM Implementation
Expand Down