[lld] r315584 - Use 0 as sh_link when we don't have a dynamic symbol table.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 08:05:04 PDT 2017
Author: rafael
Date: Thu Oct 12 08:05:04 2017
New Revision: 315584
URL: http://llvm.org/viewvc/llvm-project?rev=315584&view=rev
Log:
Use 0 as sh_link when we don't have a dynamic symbol table.
It doesn't make sense to link from an alloc section to a non alloc
one as we were doing.
This matches the behavior of both gold and bfd.
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/test/ELF/aarch64-gnu-ifunc.s
lld/trunk/test/ELF/gnu-ifunc-i386.s
lld/trunk/test/ELF/gnu-ifunc.s
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=315584&r1=315583&r2=315584&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Oct 12 08:05:04 2017
@@ -1284,8 +1284,10 @@ template <class ELFT> unsigned Relocatio
}
template <class ELFT> void RelocationSection<ELFT>::finalizeContents() {
- this->Link = InX::DynSymTab ? InX::DynSymTab->getParent()->SectionIndex
- : InX::SymTab->getParent()->SectionIndex;
+ // If all relocations are *RELATIVE they don't refer to any
+ // dynamic symbol and we don't need a dynamic symbol table. If that
+ // is the case, just use 0 as the link.
+ this->Link = InX::DynSymTab ? InX::DynSymTab->getParent()->SectionIndex : 0;
// Set required output section properties.
getParent()->Link = this->Link;
Modified: lld/trunk/test/ELF/aarch64-gnu-ifunc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-gnu-ifunc.s?rev=315584&r1=315583&r2=315584&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-gnu-ifunc.s (original)
+++ lld/trunk/test/ELF/aarch64-gnu-ifunc.s Thu Oct 12 08:05:04 2017
@@ -15,7 +15,7 @@
// CHECK-NEXT: Address: [[RELA:.*]]
// CHECK-NEXT: Offset: 0x158
// CHECK-NEXT: Size: 48
-// CHECK-NEXT: Link: 6
+// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
Modified: lld/trunk/test/ELF/gnu-ifunc-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc-i386.s?rev=315584&r1=315583&r2=315584&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc-i386.s (original)
+++ lld/trunk/test/ELF/gnu-ifunc-i386.s Thu Oct 12 08:05:04 2017
@@ -15,7 +15,7 @@
// CHECK-NEXT: Address: [[RELA:.*]]
// CHECK-NEXT: Offset: 0xD4
// CHECK-NEXT: Size: 16
-// CHECK-NEXT: Link: 6
+// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 4
// CHECK-NEXT: EntrySize: 8
Modified: lld/trunk/test/ELF/gnu-ifunc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-ifunc.s?rev=315584&r1=315583&r2=315584&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-ifunc.s (original)
+++ lld/trunk/test/ELF/gnu-ifunc.s Thu Oct 12 08:05:04 2017
@@ -15,7 +15,7 @@
// CHECK-NEXT: Address: [[RELA:.*]]
// CHECK-NEXT: Offset: 0x158
// CHECK-NEXT: Size: 48
-// CHECK-NEXT: Link: 6
+// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
More information about the llvm-commits
mailing list