1## If the section header index of a SHT_REL[A] section is smaller than the 2## section header index of the relocated section, we should handle it properly. 3## Normally it is not what compilers would emit, but some custom tools might 4## want to use this feature, which is not restricted by ELF gABI. 5## GNU ld supports this as well. 6 7# RUN: yaml2obj %s -DTYPE=SHT_RELA -o %t1.o 8# RUN: ld.lld -shared %t1.o -o %t1 9# RUN: llvm-readelf --relocs %t1 | FileCheck %s 10 11# RUN: yaml2obj %s -DTYPE=SHT_REL -o %t2.o 12# RUN: ld.lld -shared %t2.o -o %t2 13# RUN: llvm-readelf --relocs %t2 | FileCheck %s 14 15## Check we handle the relocation properly. 16# CHECK: Relocation section '.rela.dyn' at offset 0x238 contains 1 entries: 17# CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend 18# CHECK-NEXT: 00000000000022f0 0000000100000001 R_X86_64_64 0000000000000000 foo + 0 19 20--- !ELF 21FileHeader: 22 Class: ELFCLASS64 23 Data: ELFDATA2LSB 24 Type: ET_REL 25 Machine: EM_X86_64 26Sections: 27 - Name: .relx.data 28 Type: [[TYPE]] 29 Info: .data 30 Relocations: 31 - Symbol: foo 32 Type: R_X86_64_64 33 - Name: .data 34 Type: SHT_PROGBITS 35 Flags: [ SHF_ALLOC, SHF_WRITE ] 36Symbols: 37 - Name: foo 38 Binding: STB_GLOBAL 39