[PATCH] D65985: [lld][WebAssembly] Don't create optional symbols when outputing an object file
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 16:42:03 PDT 2019
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 added a reviewer: quantum.
This was a bug in rL368310 <https://reviews.llvm.org/rL368310>. I'm working on a test case now.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65985
Files:
lld/wasm/Driver.cpp
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -463,34 +463,35 @@
// Create ABI-defined synthetic symbols
static void createSyntheticSymbols() {
+ if (config->relocatable)
+ return;
+
static WasmSignature nullSignature = {{}, {}};
static WasmSignature i32ArgSignature = {{}, {ValType::I32}};
static llvm::wasm::WasmGlobalType globalTypeI32 = {WASM_TYPE_I32, false};
static llvm::wasm::WasmGlobalType mutableGlobalTypeI32 = {WASM_TYPE_I32,
true};
- if (!config->relocatable) {
- WasmSym::callCtors = symtab->addSyntheticFunction(
- "__wasm_call_ctors", WASM_SYMBOL_VISIBILITY_HIDDEN,
- make<SyntheticFunction>(nullSignature, "__wasm_call_ctors"));
-
- if (config->passiveSegments) {
- // Passive segments are used to avoid memory being reinitialized on each
- // thread's instantiation. These passive segments are initialized and
- // dropped in __wasm_init_memory, which is the first function called from
- // __wasm_call_ctors.
- WasmSym::initMemory = symtab->addSyntheticFunction(
- "__wasm_init_memory", WASM_SYMBOL_VISIBILITY_HIDDEN,
- make<SyntheticFunction>(nullSignature, "__wasm_init_memory"));
- }
+ WasmSym::callCtors = symtab->addSyntheticFunction(
+ "__wasm_call_ctors", WASM_SYMBOL_VISIBILITY_HIDDEN,
+ make<SyntheticFunction>(nullSignature, "__wasm_call_ctors"));
+
+ if (config->passiveSegments) {
+ // Passive segments are used to avoid memory being reinitialized on each
+ // thread's instantiation. These passive segments are initialized and
+ // dropped in __wasm_init_memory, which is the first function called from
+ // __wasm_call_ctors.
+ WasmSym::initMemory = symtab->addSyntheticFunction(
+ "__wasm_init_memory", WASM_SYMBOL_VISIBILITY_HIDDEN,
+ make<SyntheticFunction>(nullSignature, "__wasm_init_memory"));
+ }
- if (config->isPic) {
- // For PIC code we create a synthetic function __wasm_apply_relocs which
- // is called from __wasm_call_ctors before the user-level constructors.
- WasmSym::applyRelocs = symtab->addSyntheticFunction(
- "__wasm_apply_relocs", WASM_SYMBOL_VISIBILITY_HIDDEN,
- make<SyntheticFunction>(nullSignature, "__wasm_apply_relocs"));
- }
+ if (config->isPic) {
+ // For PIC code we create a synthetic function __wasm_apply_relocs which
+ // is called from __wasm_call_ctors before the user-level constructors.
+ WasmSym::applyRelocs = symtab->addSyntheticFunction(
+ "__wasm_apply_relocs", WASM_SYMBOL_VISIBILITY_HIDDEN,
+ make<SyntheticFunction>(nullSignature, "__wasm_apply_relocs"));
}
@@ -524,8 +525,10 @@
}
static void createOptionalSymbols() {
- if (!config->relocatable)
- WasmSym::dsoHandle = symtab->addOptionalDataSymbol("__dso_handle");
+ if (config->relocatable)
+ return;
+
+ WasmSym::dsoHandle = symtab->addOptionalDataSymbol("__dso_handle");
if (!config->shared)
WasmSym::dataEnd = symtab->addOptionalDataSymbol("__data_end");
@@ -702,8 +705,7 @@
for (auto *arg : args.filtered(OPT_export))
config->exportedSymbols.insert(arg->getValue());
- if (!config->relocatable)
- createSyntheticSymbols();
+ createSyntheticSymbols();
createFiles(args);
if (errorCount())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65985.214262.patch
Type: text/x-patch
Size: 3438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190808/2911ad37/attachment.bin>
More information about the llvm-commits
mailing list