diff --git a/system/lib/README.md b/system/lib/README.md index aaf37978718c7..462cb28b7efa2 100644 --- a/system/lib/README.md +++ b/system/lib/README.md @@ -16,13 +16,26 @@ document. These current set of static constructors in system libraries and their priorities (lowest run first) are: -- 1: `emscripten_stack_init` (stack_limits.S) -- 47: `initialize_emmalloc_heap` (emmalloc.c) -- 48: `__emscripten_init_main_thread` (pthread/library_pthread.c) -- 49: `init_file_data` (generated by file_packager.py) -- 50: asan init (??) -- 100: `WasmFS wasmFS` (wasmfs/wasmfs.cpp) +- 1: `emscripten_stack_init` ([libemcc/stack_limits.S][stack_limits.S]) +- 47: `initialize_emmalloc_heap` ([emmalloc.c][emmalloc.c]) +- 48: `__emscripten_init_main_thread` ([pthread/library_pthread.c][library_pthread.c]) +- 48: `emscripten_wasm_worker_main_thread_initialize` ([wasm_worker/library_wasm_worker.c][library_wasm_worker.c]) +- 49: `init_file_data` (generated by [file_packager.py][file_packager.py]) +- 50: `asan.module_ctor`, which calls `__asan_init` (generated by the LLVM + AddressSanitizer pass, see `kAsanEmscriptenCtorAndDtorPriority` in + [AddressSanitizer.cpp][AddressSanitizer.cpp]) +- 100: `__emscripten_environ_constructor` ([libc/musl/src/env/__environ.c][__environ.c]) +- 100: `WasmFS wasmFS` ([wasmfs/wasmfs.cpp][wasmfs.cpp]) Priorities 0 - 100 are reserved for system libraries and user-level constructors should all run at 101 and above (for example libc++ initializes its standard I/O streams at priority 101). + +[stack_limits.S]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/libemcc/stack_limits.S +[emmalloc.c]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/emmalloc.c +[library_pthread.c]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/pthread/library_pthread.c +[library_wasm_worker.c]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/wasm_worker/library_wasm_worker.c +[file_packager.py]: https://github.com/emscripten-core/emscripten/blob/main/tools/file_packager.py +[AddressSanitizer.cpp]: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +[__environ.c]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/env/__environ.c +[wasmfs.cpp]: https://github.com/emscripten-core/emscripten/blob/main/system/lib/wasmfs/wasmfs.cpp