[lld] [lld][WebAssembly] Allow linker-synthetic symbols to be undefine when… (PR #153537)
YAMAMOTO Takashi via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 01:33:08 PDT 2025
================
@@ -985,23 +985,35 @@ static void createOptionalSymbols() {
ctx.sym.dsoHandle = symtab->addOptionalDataSymbol("__dso_handle");
- if (!ctx.arg.shared)
- ctx.sym.dataEnd = symtab->addOptionalDataSymbol("__data_end");
-
+ auto addDataLayoutSymbol = [&](StringRef s) -> DefinedData * {
+ // Data layout symbols are either defined by lld, or (in the case
+ // of PIC code) defined by the dynamic linker / embedder.
+ if (ctx.isPic) {
+ ctx.arg.allowUndefinedSymbols.insert(s);
+ return nullptr;
+ } else {
+ return symtab->addOptionalDataSymbol(s);
+ }
+ };
+
+ ctx.sym.dataEnd = addDataLayoutSymbol("__data_end");
+ ctx.sym.stackLow = addDataLayoutSymbol("__stack_low");
+ ctx.sym.stackHigh = addDataLayoutSymbol("__stack_high");
+ ctx.sym.globalBase = addDataLayoutSymbol("__global_base");
+ ctx.sym.heapBase = addDataLayoutSymbol("__heap_base");
+ ctx.sym.heapEnd = addDataLayoutSymbol("__heap_end");
+
+ // for pic,
+ // - __memory_base and __table_base are handled in createSyntheticSymbols.
+ // - how __wasm_first_page_end should be is not clear yet.
----------------
yamt wrote:
> wasi-sdk may need to ship another set of shared libraries with page_size=1, right?
it seems working with:
https://github.com/WebAssembly/wasi-libc/pull/616
https://github.com/llvm/llvm-project/pull/153763
https://github.com/llvm/llvm-project/pull/153537
More information about the llvm-commits
mailing list