[PATCH] D119902: [lld][WebAssembly] Don't force the export symbols assiged internal/dummy GOT entries

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 15 15:37:12 PST 2022


sbc100 created this revision.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, dschuff.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Symbol with regular GOT entries do need to be exported, but those
that are internalized (and have internal GOT entires) should not
be exported.

This happens to fix the failures on the emscripten waterfall where
extra symbols were being exported by the linker (and then later
removed by wasm-opt).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119902

Files:
  lld/wasm/Symbols.cpp
  lld/wasm/SyntheticSections.cpp


Index: lld/wasm/SyntheticSections.cpp
===================================================================
--- lld/wasm/SyntheticSections.cpp
+++ lld/wasm/SyntheticSections.cpp
@@ -167,6 +167,12 @@
     return;
   LLVM_DEBUG(dbgs() << "addGOTEntry: " << toString(*sym) << "\n");
   sym->setGOTIndex(numImportedGlobals++);
+  if (config->isPic) {
+    // Any symbol that is assigned an normal GOT entry must be exported
+    // otherwise the dynamic linker won't be able create the entry that contains
+    // it.
+    sym->forceExport = true;
+  }
   gotSymbols.push_back(sym);
 }
 
Index: lld/wasm/Symbols.cpp
===================================================================
--- lld/wasm/Symbols.cpp
+++ lld/wasm/Symbols.cpp
@@ -190,11 +190,6 @@
 void Symbol::setGOTIndex(uint32_t index) {
   LLVM_DEBUG(dbgs() << "setGOTIndex " << name << " -> " << index << "\n");
   assert(gotIndex == INVALID_INDEX);
-  if (config->isPic) {
-    // Any symbol that is assigned a GOT entry must be exported otherwise the
-    // dynamic linker won't be able create the entry that contains it.
-    forceExport = true;
-  }
   gotIndex = index;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119902.409080.patch
Type: text/x-patch
Size: 1138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220215/fba3dfa4/attachment.bin>


More information about the llvm-commits mailing list