Skip to content

Commit

Permalink
Document __wasm_call_ctors (#131)
Browse files Browse the repository at this point in the history
* Document __wasm_call_ctors

A user rolling their own toolchain was asking after their missing
constructors on llvm-dev, and I was going to point them to the
documentation of __wasm_call_ctors wehen I discovered that there was
none. This PR fixes that hole in our docs.

* Generalize wording

* Describe how __wasm_call_ctors may be called or exported
  • Loading branch information
tlively authored and sunfishcode committed Dec 18, 2019
1 parent b7afb38 commit 09bf6b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tasks need to be performed:
- Merging of table sections (re-numbering tables)
- Merging of data segments (re-positioning data)
- Resolving undefined external references
- Synthesizing functions to call constructors and perform other initialization

The linking technique described here is designed to be fast, and avoids having
to disassemble the code section. The extra metadata required by the linker
Expand Down Expand Up @@ -527,7 +528,12 @@ event symbols in the linked output.)
Start Section
-------------

By default the static linker should not output a WebAssembly start section.
By default the static linker should not output a WebAssembly start
section. Constructors are instead called from a synthetic function
`__wasm_call_ctors` that the runtime and embedder should arrange to have called
after instantiation. `__wasm_call_ctors` is not exported by default because it
may be called by some other startup function defined by the runtime. For the
embedder to call it directly it should be exported like any other function.

Rationale: Use of the WebAssembly start function was considered for running
static constructors and/or the main entry point to the program. However,
Expand Down

0 comments on commit 09bf6b6

Please sign in to comment.