Skip to content

which memory dynamic-linking libraries should use for host functions? #232

Description

@yamt

https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md says:

Regardless of the kind, all modules accessing WASI APIs also export a linear memory with the name memory. Data pointers in WASI API calls are relative to this memory's index space.

i guess it's the convention used by many of host functions, not only WASI.

however, wasi-libc's libc.so doesn't export "memory".

actually, wasm-ld rejects -shared -export-memory.
https://github.com/llvm/llvm-project/blob/06a808c4f4014edfeb2517bddd0bcb63eb4a260b/lld/wasm/Driver.cpp#L658

am i missing something?

a. wasm-ld should be fixed.

b. application-abi.md doesn't apply to a module which is a shared library.
the memory exported from the "main" module should always be used.
i feel this a bit strange because the module calling wasi (eg. libc.so) doesn't know about the "main" module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions