summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-06-02 09:17:45 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-06-02 09:17:45 +0000
commitef84219d211a354f5fa58ca307bb9999e406868f (patch)
tree3316fd5d666d151dd87fc6bf69c3cf9bab9fc7b8
parent4ae7e812338cdb2e42763dd802a715a545838328 (diff)
downloadbcm5719-llvm-ef84219d211a354f5fa58ca307bb9999e406868f.tar.gz
bcm5719-llvm-ef84219d211a354f5fa58ca307bb9999e406868f.zip
[ELF] - Assign SHF_INFO_LINK flag to REL[A] sections.
Spec says: (http://www.sco.com/developers/gabi/latest/ch4.sheader.html) sh_info This member holds extra information, whose interpretation depends on the section type. If the sh_flags field for this section header includes the attribute SHF_INFO_LINK, then this member represents a section header table index. SHF_INFO_LINK The sh_info field of this section header holds a section header table index. Since sh_info for SHT_REL[A] sections should contain the section header index of the section to which the relocation applies, this is consistent with spec to put this flag. Behavior matches both bfd and gold as well. Differential revision: https://reviews.llvm.org/D33763 llvm-svn: 304531
-rw-r--r--lld/ELF/OutputSections.cpp1
-rw-r--r--lld/test/ELF/emit-relocs.s9
2 files changed, 9 insertions, 1 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 4f8906a3208..8357d6b03bb 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -128,6 +128,7 @@ template <class ELFT> void OutputSection::finalize() {
// the section to which the relocation applies.
InputSectionBase *S = First->getRelocatedSection();
Info = S->getOutputSection()->SectionIndex;
+ Flags |= SHF_INFO_LINK;
}
static uint64_t updateOffset(uint64_t Off, InputSection *S) {
diff --git a/lld/test/ELF/emit-relocs.s b/lld/test/ELF/emit-relocs.s
index dfe20589e97..81763bc0dfb 100644
--- a/lld/test/ELF/emit-relocs.s
+++ b/lld/test/ELF/emit-relocs.s
@@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: ld.lld --emit-relocs %t1.o -o %t
-# RUN: llvm-readobj -t -r %t | FileCheck %s
+# RUN: llvm-readobj -t -r -s %t | FileCheck %s
## Check single dash form.
# RUN: ld.lld -emit-relocs %t1.o -o %t1
@@ -11,6 +11,13 @@
# RUN: ld.lld -q %t1.o -o %t2
# RUN: llvm-readobj -t -r %t2 | FileCheck %s
+# CHECK: Section {
+# CHECK: Index: 2
+# CHECK-NEXT: Name: .rela.text
+# CHECK-NEXT: Type: SHT_RELA
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_INFO_LINK
+# CHECK-NEXT: ]
# CHECK: Relocations [
# CHECK-NEXT: Section ({{.*}}) .rela.text {
# CHECK-NEXT: 0x201002 R_X86_64_32 .text 0x1
OpenPOWER on IntegriCloud