[lld] r289212 - Give preempting symbols precedence over linker script.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 9 06:12:02 PST 2016
Author: rafael
Date: Fri Dec 9 08:12:02 2016
New Revision: 289212
URL: http://llvm.org/viewvc/llvm-project?rev=289212&view=rev
Log:
Give preempting symbols precedence over linker script.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/test/ELF/gc-sections-shared.s
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=289212&r1=289211&r2=289212&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Dec 9 08:12:02 2016
@@ -423,8 +423,12 @@ void SymbolTable<ELFT>::addShared(Shared
std::tie(S, WasInserted) =
insert(Name, Sym.getType(), STV_DEFAULT, /*CanOmitFromDynSym*/ true, F);
// Make sure we preempt DSO symbols with default visibility.
- if (Sym.getVisibility() == STV_DEFAULT)
+ if (Sym.getVisibility() == STV_DEFAULT) {
S->ExportDynamic = true;
+ // Exporting preempting symbols takes precedence over linker scripts.
+ if (S->VersionId == VER_NDX_LOCAL)
+ S->VersionId = VER_NDX_GLOBAL;
+ }
if (WasInserted || isa<Undefined>(S->body())) {
replaceBody<SharedSymbol<ELFT>>(S, F, Name, Sym, Verdef);
if (!S->isWeak())
Modified: lld/trunk/test/ELF/gc-sections-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-shared.s?rev=289212&r1=289211&r2=289212&view=diff
==============================================================================
--- lld/trunk/test/ELF/gc-sections-shared.s (original)
+++ lld/trunk/test/ELF/gc-sections-shared.s Fri Dec 9 08:12:02 2016
@@ -19,6 +19,15 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: bar
+# CHECK-NEXT: Value:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type:
+# CHECK-NEXT: Other:
+# CHECK-NEXT: Section: .text
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: bar2
# CHECK-NEXT: Value:
# CHECK-NEXT: Size:
More information about the llvm-commits
mailing list