[lld] e1617d2 - Revert "[lld][WebAssembly] Fix for weak undefined functions in -pie mode"

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 09:04:31 PST 2021


Author: Sam Clegg
Date: 2021-02-12T09:04:18-08:00
New Revision: e1617d23ff06c550e79ca288d9a38c0bdbb335e8

URL: https://github.com/llvm/llvm-project/commit/e1617d23ff06c550e79ca288d9a38c0bdbb335e8
DIFF: https://github.com/llvm/llvm-project/commit/e1617d23ff06c550e79ca288d9a38c0bdbb335e8.diff

LOG: Revert "[lld][WebAssembly] Fix for weak undefined functions in -pie mode"

This reverts commit ac2be2b6a366c05c01b8228fd804ba6ed52d320b.

This causes a whole much of emscripten tests to fail due to newly
undefined symbols appearing.  Will investigate and look into re-landing
later.

Added: 
    

Modified: 
    lld/test/wasm/weak-undefined-pic.s
    lld/wasm/Driver.cpp
    lld/wasm/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/weak-undefined-pic.s b/lld/test/wasm/weak-undefined-pic.s
index 34f9ed1e935e..b0f31e1a12d9 100644
--- a/lld/test/wasm/weak-undefined-pic.s
+++ b/lld/test/wasm/weak-undefined-pic.s
@@ -22,7 +22,6 @@ get_foo_addr:
 _start:
   .functype _start () -> ()
   call get_foo_addr
-  call foo
   end_function
 
 .weak foo
@@ -69,15 +68,11 @@ _start:
 # CHECK-NEXT:      - Index:           1
 # CHECK-NEXT:        Name:            'GOT.func.internal.undefined_weak:foo'
 
-# With `-pie + + --unresolved-symbols=import-functions` or `-shared` the
-# resolution should be deferred to the dynamic linker and the function address
-# should be imported as GOT.func.foo.
+# With `-pie` or `-shared` the resolution should be deferred to the dynamic
+# linker and the function address should be imported as GOT.func.foo.
 #
-# RUN: wasm-ld --experimental-pic -shared %t.o -o %t3.wasm
+# RUN: wasm-ld --experimental-pic -pie %t.o -o %t3.wasm
 # RUN: obj2yaml %t3.wasm | FileCheck %s --check-prefix=IMPORT
-#
-# RUN: wasm-ld --experimental-pic -pie --unresolved-symbols=import-functions %t.o -o %t4.wasm
-# RUN: obj2yaml %t4.wasm | FileCheck %s --check-prefix=IMPORT
 
 #      IMPORT:  - Type:            IMPORT
 #      IMPORT:      - Module:          GOT.func
@@ -93,12 +88,3 @@ _start:
 # IMPORT-NEXT:         Name:            __table_base
 # IMPORT-NEXT:       - Index:           2
 # IMPORT-NEXT:         Name:            foo
-
-# With just `-pie` (which does not default to import-functions) there shoule be
-# no import at all.
-#
-# RUN: wasm-ld --experimental-pic -pie %t.o -o %t5.wasm
-# RUN: obj2yaml %t5.wasm | FileCheck %s --check-prefix=NO-IMPORT
-
-# NO-IMPORT:      Name:            'undefined_weak:foo'
-# NO-IMPORT-NOT:  Name: foo

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 91315c5fc743..3e2786d2b59d 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -1016,8 +1016,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
       sym->forceExport = true;
   }
 
-  if (!config->relocatable &&
-      config->unresolvedSymbols != UnresolvedPolicy::ImportFuncs) {
+  if (!config->relocatable && !config->isPic) {
     // Add synthetic dummies for weak undefined functions.  Must happen
     // after LTO otherwise functions may not yet have signatures.
     symtab->handleWeakUndefines();

diff  --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 29fa99e50c31..d91b6b811081 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -569,6 +569,8 @@ void Writer::calculateImports() {
   for (Symbol *sym : symtab->getSymbols()) {
     if (!sym->isUndefined())
       continue;
+    if (sym->isWeak() && !config->relocatable)
+      continue;
     if (!sym->isLive())
       continue;
     if (!sym->isUsedInRegularObj)


        


More information about the llvm-commits mailing list