brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.8 KiB · 87aab76 Raw
132 lines · plain
1## Check how we report warnings when dumping an object with broken relocations.2 3# RUN: yaml2obj %s -o %t644# RUN: llvm-readobj --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=LLVM5# RUN: llvm-readelf --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=GNU6 7# LLVM:      Relocations [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: 25514# 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 table17# LLVM-NEXT:     0x6 R_X86_64_NONE <section 2>{{$}}18# LLVM-NEXT:   }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_DYNSYM21# LLVM-NEXT:   }22# LLVM-NEXT: ]23 24# GNU:       Relocation section '.rel.text' at offset 0x41 contains 7 entries:25# GNU-NEXT:      Offset             Info             Type               Symbol's Value  Symbol's Name26# 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_NONE29# GNU-NEXT:  0000000000000003  0000000200000000 R_X86_64_NONE 0000000000000000 .sec.symbol130# GNU-NEXT:  warning: '[[FILE]]': invalid section index: 25531# GNU-NEXT:  0000000000000004  0000000400000000 R_X86_64_NONE 0000000000000000 <section 255>32# GNU-NEXT:  0000000000000005  0000000300000000 R_X86_64_NONE 0000000000000000 .sec.symbol233# 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 table34# GNU-NEXT:  0000000000000006  0000000500000000 R_X86_64_NONE 0000000000000000 <section 2>35# GNU-EMPTY: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 + Addend38# 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_DYNSYM39 40# RUN: yaml2obj -DTYPE=SHT_CREL %s -o %t64.crel41# RUN: llvm-readelf --relocations %t64.crel 2>&1 | FileCheck %s -DFILE=%t64.crel --check-prefix=CREL-GNU42 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 + Addend45# 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 046# 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 047# CREL-GNU-NEXT:  0000000000000002  0000000000000000 R_X86_64_NONE                     048# 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 049# 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 050# 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 051# 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 052# CREL-GNU-EMPTY: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 + Addend55# 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_DYNSYM56 57--- !ELF58FileHeader:59  Class:   ELFCLASS6460  Data:    ELFDATA2LSB61  Type:    ET_REL62  Machine: EM_X86_6463Sections:64  - Name:    .text65    Type:    SHT_PROGBITS66    Content: '00'67  - Name:   .foo68    Type:   SHT_PROGBITS69    ShName: 0xFEFEFEFE70  - Name: .rel.text71    Type: [[TYPE=SHT_REL]]72    Info: .text73    Relocations:74## Case 1: There is no symbol with index 0xFEFEFEFE.75      - Symbol: 0xFEFEFEFE76        Type:   R_X86_64_NONE77      - Symbol: 0xFEFEFEFE78        Type:   R_X86_64_NONE79## Case 2: Test that no warning is reported for a relocation against a symbol with index 0.80      - Offset: 0x281        Symbol: 082        Type:   R_X86_64_NONE83## Case 3: Test a relocation against a named section symbol that has an invalid84##         section index (larger than the number of sections).85      - Offset: 0x386        Symbol: .sec.symbol187        Type:   R_X86_64_NONE88## Case 4: Test a relocation against an unnamed section symbol that has an invalid89##         section index (larger than the number of sections).90      - Offset: 0x491        Symbol: 492        Type:   R_X86_64_NONE93## Case 4: Test a relocation against a named section symbol with a section with an invalid94##         sh_name offset that goes past the end of the section name string table.95      - Offset: 0x596        Symbol: .sec.symbol297        Type:   R_X86_64_NONE98## Case 5: Test a relocation against an unnamed section symbol with a section with an invalid99##         sh_name offset that goes past the end of the section name string table.100      - Offset: 0x6101        Symbol: 5102        Type:   R_X86_64_NONE103## Case 6: Test a relocation in a section that is linked to a symbol table that104##         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.106  - Name: .rela.text107    Type: SHT_RELA108    Info: .text109    Link: .fake.symtab110    Relocations:111      - Offset: 0x7112        Symbol: symbol113        Type:   R_X86_64_NONE114  - Name:    .fake.symtab115    Type:    SHT_PROGBITS116    EntSize: 24117    Size:    48118Symbols:119  - Name:    symbol120    Section: .text121    Value:   0122  - Name:  .sec.symbol1123    Type:  STT_SECTION124    Index: 0xFF125  - Name:  .sec.symbol2126    Type:  STT_SECTION127    Index: 0x2128  - Type:  STT_SECTION129    Index: 0xFF130  - Type:  STT_SECTION131    Index: 0x2132