[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
This commit is contained in:
Fangrui Song 2022-02-05 09:56:29 -08:00
parent ef3fade14b
commit 7288b85cc8
3 changed files with 4 additions and 7 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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