[lld] [lld][WebAssembly]: Restore non-pie dynamic-linking executable (PR #108146)
YAMAMOTO Takashi via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 00:48:16 PDT 2024
================
@@ -1467,15 +1469,29 @@ void Writer::createApplyDataRelocationsFunction() {
{
raw_string_ostream os(bodyContent);
writeUleb128(os, 0, "num locals");
+ uint64_t off = os.tell();
for (const OutputSegment *seg : segments)
if (!config->sharedMemory || !seg->isTLS())
for (const InputChunk *inSeg : seg->inputSegments)
inSeg->generateRelocationCode(os);
+ if (off == os.tell()) {
+ LLVM_DEBUG(dbgs() << "skipping empty __wasm_apply_data_relocs\n");
+ return;
+ }
writeU8(os, WASM_OPCODE_END, "END");
}
- createFunction(WasmSym::applyDataRelocs, bodyContent);
+ // __wasm_apply_data_relocs
+ // Function that applies relocations to data segment post-instantiation.
+ static WasmSignature nullSignature = {{}, {}};
+ auto def = symtab->addSyntheticFunction(
+ "__wasm_apply_data_relocs",
+ WASM_SYMBOL_VISIBILITY_DEFAULT | WASM_SYMBOL_EXPORTED,
+ make<SyntheticFunction>(nullSignature, "__wasm_apply_data_relocs"));
+ def->markLive();
+
+ createFunction(def, bodyContent);
----------------
yamt wrote:
> This change seems to incorporate a couple of different things now. Would you mind separating out the change to "Only create __wasm_apply_data_relocs conditionally". That seems like it could land separately and is somewhat unrelated to fix at hand?
https://github.com/llvm/llvm-project/pull/109249
> Also, regarding the conditional creation of this symbol, what happens if somebody does `--export=__wasm_apply_data_relocs` or otherwise references this symbol, but we "skip" creating it?
is it expected to work at all? do you have real use cases? or is it just a theoretical concern?
i thought __wasm_apply_data_relocs was just for dynamic-linking.
https://github.com/llvm/llvm-project/pull/108146
More information about the llvm-commits
mailing list