diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index afc8b05f8767e..6283d943984af 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 175f2ec8d0910..eca21b91d866a 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>: