[PATCH] D41057: Avoid a gnu readelf warning

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 10 12:17:51 PST 2017


rafael created this revision.
Herald added subscribers: kristof.beyls, emaste, aemerson.

This avoids a readelf warning, matches bfd ld and should be harmless.


https://reviews.llvm.org/D41057

Files:
  ELF/SyntheticSections.cpp
  test/ELF/dynamic-reloc.s


Index: test/ELF/dynamic-reloc.s
===================================================================
--- test/ELF/dynamic-reloc.s
+++ test/ELF/dynamic-reloc.s
@@ -18,7 +18,7 @@
 // CHECK-NEXT: Offset:
 // CHECK-NEXT: Size: [[RELASIZE:.*]]
 // CHECK-NEXT: Link: 1
-// CHECK-NEXT: Info: 0
+// CHECK-NEXT: Info: [[RELALINK:.*]]
 // CHECK-NEXT: AddressAlignment: 8
 // CHECK-NEXT: EntrySize: 24
 
@@ -30,6 +30,9 @@
 // CHECK-NEXT: ]
 // CHECK-NEXT: Address: 0x201000
 
+// CHECK:      Index: [[RELALINK]]
+// CHECK-NEXT: Name: .got.plt
+
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.plt {
 // CHECK-NEXT:     Relocation {
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1224,6 +1224,15 @@
 
   // Set required output section properties.
   getParent()->Link = Link;
+
+  // In non relocatable files relocations use virtual addresses, not section
+  // offsets. Given that, there doesn't seem to be any strong reason to set
+  // sh_info for relocation sections. We do it for .rela.plt only because gnu
+  // readelf produces a warning if we don't.
+  if (this == InX::RelaPlt) {
+    Info = InX::GotPlt->getParent()->SectionIndex;
+    getParent()->Info = Info;
+  }
 }
 
 template <class ELFT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41057.126299.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171210/c88323b0/attachment.bin>


More information about the llvm-commits mailing list