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
57 ## Case 1: There is no symbol with index 0xFEFEFEFE.
62 ## Case 2: Test that no warning is reported for a relocation against a symbol with index 0.
66 ## Case 3: Test a relocation against a named section symbol that has an invalid
67 ## section index (larger than the number of sections).
71 ## Case 4: Test a relocation against an unnamed section symbol that has an invalid
72 ## section index (larger than the number of sections).
76 ## Case 4: Test a relocation against a named section symbol with a section with an invalid
77 ## sh_name offset that goes past the end of the section name string table.
81 ## Case 5: Test a relocation against an unnamed section symbol with a section with an invalid
82 ## sh_name offset that goes past the end of the section name string table.
86 ## Case 6: Test a relocation in a section that is linked to a symbol table that
87 ## has a section type that is neither SHT_SYMTAB nor SHT_DYNSYM.
88 ## In this case the code fails to find a corresponding symbol string table.