[lld] 7288b85 - [ELF] --wrap: don't copy exportDynamic

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 5 09:56:33 PST 2022


Author: Fangrui Song
Date: 2022-02-05T09:56:29-08:00
New Revision: 7288b85cc80f1ce5509aeea860e6b4232cd3ca01

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

LOG: [ELF] --wrap: don't copy exportDynamic

For -no-pie/-pie, when `__real_foo` is interposable in a shared object, `foo` is
exported. This rule does not match GNU ld and is unneeded because:

* the exported `foo` does not interpose `__real_foo` at run-time
* the similar `__wrap_foo` <-> `foo` relation does not have the rule

Added: 
    

Modified: 
    lld/ELF/SymbolTable.cpp
    lld/test/ELF/wrap-no-real.s
    lld/test/ELF/wrap-shlib-undefined.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index ec425cd7e1d12..90a4ab93868cd 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -40,8 +40,6 @@ void SymbolTable::wrap(Symbol *sym, Symbol *real, Symbol *wrap) {
   idx2 = idx1;
   idx1 = idx3;
 
-  if (real->exportDynamic)
-    sym->exportDynamic = true;
   if (!real->isUsedInRegularObj && sym->isUndefined())
     sym->isUsedInRegularObj = false;
 

diff  --git a/lld/test/ELF/wrap-no-real.s b/lld/test/ELF/wrap-no-real.s
index 125e2cfbcce75..4839e58a2c949 100644
--- a/lld/test/ELF/wrap-no-real.s
+++ b/lld/test/ELF/wrap-no-real.s
@@ -23,9 +23,9 @@
 // RUN: llvm-readelf -s -x .got %t2 | FileCheck --check-prefix=READELF --implicit-check-not=__real_ %s
 
 // CHECK2: <_start>:
-// CHECK2-NEXT: movq {{.*}}(%rip), %rax  # 0x2022e8
-// CHECK2-NEXT: movq {{.*}}(%rip), %rbx  # 0x2022e8
-// CHECK2-NEXT: movq {{.*}}(%rip), %rcx  # 0x2022e0
+// CHECK2-NEXT: movq {{.*}}(%rip), %rax  # 0x2022c0
+// CHECK2-NEXT: movq {{.*}}(%rip), %rbx  # 0x2022c0
+// CHECK2-NEXT: movq {{.*}}(%rip), %rcx  # 0x2022b8
 
 .global _start
 _start:

diff  --git a/lld/test/ELF/wrap-shlib-undefined.s b/lld/test/ELF/wrap-shlib-undefined.s
index 2897b7e39ce2d..b5546a678aca1 100644
--- a/lld/test/ELF/wrap-shlib-undefined.s
+++ b/lld/test/ELF/wrap-shlib-undefined.s
@@ -24,11 +24,10 @@
 # RUN: llvm-readelf --dyn-syms %t2 | FileCheck %s --check-prefix=CHECK2
 
 ## See wrap-plt2.s why __wrap_foo is retained.
-# CHECK2:      Symbol table '.dynsym' contains 4 entries:
+# CHECK2:      Symbol table '.dynsym' contains 3 entries:
 # CHECK2:      NOTYPE  LOCAL  DEFAULT  UND
 # CHECK2-NEXT: NOTYPE  GLOBAL DEFAULT  UND bar
 # CHECK2-NEXT: NOTYPE  GLOBAL DEFAULT  UND __wrap_foo
-# CHECK2-NEXT: NOTYPE  GLOBAL DEFAULT    6 foo
 
 ## __wrap_bar is undefined.
 # RUN: ld.lld -shared %t/main.o --wrap=bar -o %t3.so


        


More information about the llvm-commits mailing list