[lld] r368369 - [lld][WebAssembly] Don't create optional symbols when outputing an object file

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 16:56:21 PDT 2019


Author: sbc
Date: Thu Aug  8 16:56:21 2019
New Revision: 368369

URL: http://llvm.org/viewvc/llvm-project?rev=368369&view=rev
Log:
[lld][WebAssembly] Don't create optional symbols when outputing an object file

Summary: This was a bug in rL368310.  I'm working on a test case now.

Differential Revision: https://reviews.llvm.org/D65985

Modified:
    lld/trunk/wasm/Driver.cpp

Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=368369&r1=368368&r2=368369&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Thu Aug  8 16:56:21 2019
@@ -463,34 +463,35 @@ static GlobalSymbol *createGlobalVariabl
 
 // 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 createSyntheticSymbols() {
 }
 
 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 @@ void LinkerDriver::link(ArrayRef<const c
   for (auto *arg : args.filtered(OPT_export))
     config->exportedSymbols.insert(arg->getValue());
 
-  if (!config->relocatable)
-    createSyntheticSymbols();
+  createSyntheticSymbols();
 
   createFiles(args);
   if (errorCount())




More information about the llvm-commits mailing list