[PATCH] D53993: [ELF] Change sh_link of .rel{, a}.plt to make GNU strip happy
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 1 14:48:59 PDT 2018
MaskRay updated this revision to Diff 172243.
MaskRay retitled this revision from "[ELF] Set sh_link to 0 in static link to make GNU strip happy" to "[ELF] Change sh_link of .rel{,a}.plt to make GNU strip happy".
MaskRay edited the summary of this revision.
MaskRay added a comment.
Apply pcc's suggestion
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D53993
Files:
ELF/SyntheticSections.cpp
test/ELF/aarch64-gnu-ifunc.s
test/ELF/gnu-ifunc-i386.s
test/ELF/gnu-ifunc.s
Index: test/ELF/gnu-ifunc.s
===================================================================
--- test/ELF/gnu-ifunc.s
+++ test/ELF/gnu-ifunc.s
@@ -15,16 +15,13 @@
// CHECK-NEXT: Address: [[RELA:.*]]
// CHECK-NEXT: Offset: 0x158
// CHECK-NEXT: Size: 48
-// CHECK-NEXT: Link: [[SYMTAB:.*]]
+// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: [[GOTPLT:.*]]
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
// CHECK-NEXT: }
// CHECK: Index: [[GOTPLT]]
// CHECK-NEXT: Name: .got.plt
-// CHECK: Index: [[SYMTAB]]
-// CHECK-NEXT: Name: .symtab
-// CHECK-NEXT: Type: SHT_SYMTAB
// CHECK: Relocations [
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
// CHECK-NEXT: 0x202000 R_X86_64_IRELATIVE
Index: test/ELF/gnu-ifunc-i386.s
===================================================================
--- test/ELF/gnu-ifunc-i386.s
+++ test/ELF/gnu-ifunc-i386.s
@@ -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: 4
// CHECK-NEXT: AddressAlignment: 4
// CHECK-NEXT: EntrySize: 8
Index: test/ELF/aarch64-gnu-ifunc.s
===================================================================
--- test/ELF/aarch64-gnu-ifunc.s
+++ test/ELF/aarch64-gnu-ifunc.s
@@ -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: 4
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1491,13 +1491,11 @@
}
void RelocationBaseSection::finalizeContents() {
- // If all relocations are R_*_{,I}RELATIVE they don't refer to any dynamic
- // symbol and we don't need a dynamic symbol table. If that is the case, use
- // the index of the regular symbol table section (if exists) or 0.
- if (In.DynSymTab)
- getParent()->Link = In.DynSymTab->getParent()->SectionIndex;
- else if (In.SymTab)
- getParent()->Link = In.SymTab->getParent()->SectionIndex;
+ // When linking glibc statically, .rel{,a}.plt contains R_*_IRELATIVE
+ // relocations due to IFUNC (e.g. strcpy). sh_link will be set to 0 in that
+ // case.
+ if (InputSection *SymTab = Config->Relocatable ? In.SymTab : In.DynSymTab)
+ getParent()->Link = SymTab->getParent()->SectionIndex;
else
getParent()->Link = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53993.172243.patch
Type: text/x-patch
Size: 2555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181101/fd18c87d/attachment.bin>
More information about the llvm-commits
mailing list