[lld] r315727 - Handle shared symbols in --gc-sections.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 13 11:32:16 PDT 2017
Author: rafael
Date: Fri Oct 13 11:32:16 2017
New Revision: 315727
URL: http://llvm.org/viewvc/llvm-project?rev=315727&view=rev
Log:
Handle shared symbols in --gc-sections.
We don't want to gc a section if it is used via __start_*, but we were
doing that if the same symbol was visible in a shared library.
Modified:
lld/trunk/ELF/MarkLive.cpp
lld/trunk/test/ELF/startstop-gccollect.s
Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=315727&r1=315726&r2=315727&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Fri Oct 13 11:32:16 2017
@@ -74,7 +74,7 @@ static void resolveReloc(InputSectionBas
return;
}
- if (B.isUndefined())
+ if (!B.isInCurrentDSO())
for (InputSectionBase *Sec : CNamedSections.lookup(B.getName()))
Fn(Sec, 0);
}
Modified: lld/trunk/test/ELF/startstop-gccollect.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/startstop-gccollect.s?rev=315727&r1=315726&r2=315727&view=diff
==============================================================================
--- lld/trunk/test/ELF/startstop-gccollect.s (original)
+++ lld/trunk/test/ELF/startstop-gccollect.s Fri Oct 13 11:32:16 2017
@@ -11,6 +11,12 @@
# RUN: ld.lld %t --gc-sections -o %tout
# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
+# RUN: echo ".global __start_foo; __start_foo:" > %t2.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -o %t2.so
+# RUN: ld.lld %t --gc-sections -o %tout %t2.so
+# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s
+
# DISASM: _start:
# DISASM-NEXT: 201000: e8 05 00 00 00 callq 5 <__start_foo>
# DISASM-NEXT: 201005: e8 02 00 00 00 callq 2 <__stop_bar>
More information about the llvm-commits
mailing list