[lld] 0334578 - [ELF] --wrap: don't leave the original symbol as SHN_UNDEF in .symtab or .dynsym
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 8 18:18:36 PDT 2020
Author: Fangrui Song
Date: 2020-08-08T18:18:20-07:00
New Revision: 0334578edc60ad8a7455e7b76e41901376245b56
URL: https://github.com/llvm/llvm-project/commit/0334578edc60ad8a7455e7b76e41901376245b56
DIFF: https://github.com/llvm/llvm-project/commit/0334578edc60ad8a7455e7b76e41901376245b56.diff
LOG: [ELF] --wrap: don't leave the original symbol as SHN_UNDEF in .symtab or .dynsym
Added:
Modified:
lld/ELF/SymbolTable.cpp
lld/test/ELF/wrap-shlib-undefined.s
Removed:
################################################################################
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index afc8b05f8767..6283d943984a 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -42,6 +42,8 @@ void SymbolTable::wrap(Symbol *sym, Symbol *real, Symbol *wrap) {
if (real->exportDynamic)
sym->exportDynamic = true;
+ if (sym->isUndefined())
+ sym->isUsedInRegularObj = false;
// Now renaming is complete, and no one refers to real. We drop real from
// .symtab and .dynsym. If real is undefined, it is important that we don't
diff --git a/lld/test/ELF/wrap-shlib-undefined.s b/lld/test/ELF/wrap-shlib-undefined.s
index 175f2ec8d091..eca21b91d866 100644
--- a/lld/test/ELF/wrap-shlib-undefined.s
+++ b/lld/test/ELF/wrap-shlib-undefined.s
@@ -26,10 +26,8 @@
# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=DYNSYM
# RUN: llvm-objdump -d %t1 | FileCheck %s --check-prefix=ASM
-## FIXME GNU ld does not export bar
-# DYNSYM: Symbol table '.dynsym' contains 3 entries:
+# DYNSYM: Symbol table '.dynsym' contains 2 entries:
# DYNSYM: NOTYPE LOCAL DEFAULT UND
-# DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND bar
# DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_bar
# ASM: <_start>:
More information about the llvm-commits
mailing list