[PATCH] D65985: [lld][WebAssembly] Don't create optional symbols when outputing an object file

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 16:57:19 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL368369: [lld][WebAssembly] Don't create optional symbols when outputing an object file (authored by sbc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D65985?vs=214262&id=214264#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65985/new/

https://reviews.llvm.org/D65985

Files:
  lld/trunk/wasm/Driver.cpp


Index: lld/trunk/wasm/Driver.cpp
===================================================================
--- lld/trunk/wasm/Driver.cpp
+++ lld/trunk/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.214264.patch
Type: text/x-patch
Size: 3456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190808/b3307568/attachment.bin>


More information about the llvm-commits mailing list