1 ## Check how we report warnings when dumping an object with broken relocations.
3 # RUN: yaml2obj %s -o %t64
4 # RUN: llvm-readobj --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=LLVM
5 # RUN: llvm-readelf --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=GNU
8 # LLVM-NEXT: Section (3) .rel.text {
9 # LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_REL section with index 3: unable to read an entry with index 4278124286 from SHT_SYMTAB section with index 6: can't read an entry at 0x17e7e7e7d0: it goes past the end of the section (0x90)
10 # LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 1 in SHT_REL section with index 3: unable to read an entry with index 4278124286 from SHT_SYMTAB section with index 6: can't read an entry at 0x17e7e7e7d0: it goes past the end of the section (0x90)
11 # LLVM-NEXT: 0x2 R_X86_64_NONE -{{$}}
12 # LLVM-NEXT: 0x3 R_X86_64_NONE .sec.symbol1{{$}}
13 # LLVM-NEXT: warning: '[[FILE]]': invalid section index: 255
14 # LLVM-NEXT: 0x4 R_X86_64_NONE <section 255>{{$}}
15 # LLVM-NEXT: 0x5 R_X86_64_NONE .sec.symbol2{{$}}
16 # LLVM-NEXT: warning: '[[FILE]]': a section [index 2] has an invalid sh_name (0xfefefefe) offset which goes past the end of the section name string table
17 # LLVM-NEXT: 0x6 R_X86_64_NONE <section 2>{{$}}
19 # LLVM-NEXT: Section (4) .rela.text {
20 # LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_RELA section with index 4: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
24 # GNU: Relocation section '.rel.text' at offset 0x41 contains 7 entries:
25 # GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
26 # GNU-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_REL section with index 3: unable to read an entry with index 4278124286 from SHT_SYMTAB section with index 6: can't read an entry at 0x17e7e7e7d0: it goes past the end of the section (0x90)
27 # GNU-NEXT: warning: '[[FILE]]': unable to print relocation 1 in SHT_REL section with index 3: unable to read an entry with index 4278124286 from SHT_SYMTAB section with index 6: can't read an entry at 0x17e7e7e7d0: it goes past the end of the section (0x90)
28 # GNU-NEXT: 0000000000000002 0000000000000000 R_X86_64_NONE
29 # GNU-NEXT: 0000000000000003 0000000200000000 R_X86_64_NONE 0000000000000000 .sec.symbol1
30 # GNU-NEXT: warning: '[[FILE]]': invalid section index: 255
31 # GNU-NEXT: 0000000000000004 0000000400000000 R_X86_64_NONE 0000000000000000 <section 255>
32 # GNU-NEXT: 0000000000000005 0000000300000000 R_X86_64_NONE 0000000000000000 .sec.symbol2
33 # GNU-NEXT: warning: '[[FILE]]': a section [index 2] has an invalid sh_name (0xfefefefe) offset which goes past the end of the section name string table
34 # GNU-NEXT: 0000000000000006 0000000500000000 R_X86_64_NONE 0000000000000000 <section 2>
36 # GNU-NEXT: Relocation section '.rela.text' at offset 0xb1 contains 1 entries:
37 # GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
38 # GNU-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_RELA section with index 4: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
40 # RUN: yaml2obj -DTYPE=SHT_CREL %s -o %t64.crel
41 # RUN: llvm-readelf --relocations %t64.crel 2>&1 | FileCheck %s -DFILE=%t64.crel --check-prefix=CREL-GNU
43 # CREL-GNU: Relocation section '.rel.text' at offset 0x41 contains 7 entries:
44 # CREL-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
45 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_CREL section with index 3: unable to read an entry with index 4278124286 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
46 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 1 in SHT_CREL section with index 3: unable to read an entry with index 4278124286 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
47 # CREL-GNU-NEXT: 0000000000000002 0000000000000000 R_X86_64_NONE 0
48 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 3 in SHT_CREL section with index 3: unable to read an entry with index 2 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
49 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 4 in SHT_CREL section with index 3: unable to read an entry with index 4 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
50 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 5 in SHT_CREL section with index 3: unable to read an entry with index 3 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
51 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 6 in SHT_CREL section with index 3: unable to read an entry with index 5 from SHT_NULL section with index 0: section [index 0] has invalid sh_entsize: expected 24, but got 0
53 # CREL-GNU-NEXT: Relocation section '.rela.text' at offset 0x5a contains 1 entries:
54 # CREL-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
55 # CREL-GNU-NEXT: warning: '[[FILE]]': unable to print relocation 0 in SHT_RELA section with index 4: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
71 Type: [[TYPE=SHT_REL]]
74 ## Case 1: There is no symbol with index 0xFEFEFEFE.
79 ## Case 2: Test that no warning is reported for a relocation against a symbol with index 0.
83 ## Case 3: Test a relocation against a named section symbol that has an invalid
84 ## section index (larger than the number of sections).
88 ## Case 4: Test a relocation against an unnamed section symbol that has an invalid
89 ## section index (larger than the number of sections).
93 ## Case 4: Test a relocation against a named section symbol with a section with an invalid
94 ## sh_name offset that goes past the end of the section name string table.
98 ## Case 5: Test a relocation against an unnamed section symbol with a section with an invalid
99 ## sh_name offset that goes past the end of the section name string table.
103 ## Case 6: Test a relocation in a section that is linked to a symbol table that
104 ## has a section type that is neither SHT_SYMTAB nor SHT_DYNSYM.
105 ## In this case the code fails to find a corresponding symbol string table.