WebAssembly / WebAssembly/tool-conventions

Symbol metadata for dynamic linking

Open
#154 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
372
Forks
75
PR merge metrics
No merged PRs in 30d

Description

The current (experimental) dynamic linking ABI doesn't support any kind of symbol information other than the imports and exports of a module. It does use a small custom "dylink" section but currently has no per-symbol information.

In order to support dynamic linking along + threading (https://github.com/emscripten-core/emscripten/issues/3494) and in order to support weak symbol references (https://github.com/emscripten-core/emscripten/issues/12826) emscripten needs some way to add flags to symbols. Specifically for dynamic linking we need way to mark a given export is TLS and for weak externals we need to way to mark a given import as WEAK.

I think we have 2 options:

  1. Add thing information into the import or export name itself
  2. Use a custom section.

(1) sounds unattractive since it involved name mangling. However the number of flags we need to is unlikely to grow much (if at all). We could allow for example the @tls suffix on exports and the @weak suffix on imports.

For (2) we would presumably add to the existing dylink section. However we don't currently part the dylink section of the main executable at runtime so that would be something we would have to start doing. If we go with (2) we would need to invent some kind of dynamic symbol table.

Of course in the long term we want to use module linking, but I don't think there is any support for either TLS or weak symbols in the current or planed module linking proposal.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing custom "dylink" section conventions and the linked issues on dynamic linking with threading and weak symbol references. The work is done when the project has a decided symbol-metadata design that can mark TLS exports and WEAK imports, with the required runtime handling documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
backend-api-design, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.