[PATCH] D33763: [ELF] - Assign SHF_INFO_LINK flag to REL[A] sections.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 12:17:42 PDT 2017


Interesting. I see that gas also sets it these days. That was
https://sourceware.org/bugzilla/show_bug.cgi?id=16317.

Since this is now common and in line with the standard, LGTM. Please
open a bug about doing the same in MC.

Thanks,
Rafael

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
> Herald added a subscriber: emaste.
>
> 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. A table below describes the values. 
> **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.
>
>
> https://reviews.llvm.org/D33763
>
> Files:
>   ELF/OutputSections.cpp
>   test/ELF/emit-relocs.s
>
>
> Index: test/ELF/emit-relocs.s
> ===================================================================
> --- test/ELF/emit-relocs.s
> +++ 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
> Index: ELF/OutputSections.cpp
> ===================================================================
> --- ELF/OutputSections.cpp
> +++ ELF/OutputSections.cpp
> @@ -156,6 +156,7 @@
>    // 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) {
>
>
> Index: test/ELF/emit-relocs.s
> ===================================================================
> --- test/ELF/emit-relocs.s
> +++ 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
> Index: ELF/OutputSections.cpp
> ===================================================================
> --- ELF/OutputSections.cpp
> +++ ELF/OutputSections.cpp
> @@ -156,6 +156,7 @@
>    // 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) {


More information about the llvm-commits mailing list