xref: /llvm-project/llvm/test/tools/llvm-readobj/XCOFF/relocations-invalid.test (revision a00ff71668202b2ee3e16a23f9b16dad01001def)
1## Check we report warnings when relocations are broken.
2
3# RUN: yaml2obj --docnum=1 %s -o %t1
4# RUN: llvm-readobj --relocs --expand-relocs %t1 2>&1 | \
5# RUN:   FileCheck %s -DFILE=%t1 --check-prefix=INVALID-REL
6
7# INVALID-REL:      Relocations [
8# INVALID-REL-NEXT:   warning: '[[FILE]]': The end of the file was unexpectedly encountered: relocations with offset 0x222 and size 0x0 go past the end of the file
9# INVALID-REL-NEXT: ]
10
11--- !XCOFF
12FileHeader:
13  MagicNumber:   0x1DF
14Sections:
15  - Name:        .text
16    Flags:       [ STYP_TEXT ]
17## Case 1: Incorrect offset to relocation entries.
18    FileOffsetToRelocations: 0x222
19
20# RUN: yaml2obj --docnum=2 %s -o %t2
21# RUN: llvm-readobj --relocs --expand-relocs %t2 2>&1 | \
22# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=INVALID-SYM
23
24# INVALID-SYM:      Relocations [
25# INVALID-SYM-NEXT:   Section (index: 1) .text {
26# INVALID-SYM-NEXT:     warning: '[[FILE]]': symbol index 33 exceeds symbol count 0
27# INVALID-SYM-NEXT:   }
28# INVALID-SYM-NEXT: ]
29
30--- !XCOFF
31FileHeader:
32  MagicNumber:   0x1DF
33Sections:
34  - Name:        .text
35    Flags:       [ STYP_TEXT ]
36    Relocations:
37      - Address: 0x80
38## Case 2: There is no symbol with index 0x21.
39        Symbol:  0x21
40