File: relocation-errors.test

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (92 lines) | stat: -rw-r--r-- 4,266 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
## Check how we report warnings when dumping an object with broken relocations.

# RUN: yaml2obj %s -o %t64
# RUN: llvm-readobj --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=LLVM
# RUN: llvm-readelf --relocations %t64 2>&1 | FileCheck %s -DFILE=%t64 --check-prefix=GNU

# LLVM:      Relocations [
# LLVM-NEXT:   Section (3) .rel.text {
# LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 1 in section 3: unable to access section [index 6] data at 0x17e7e7e8b0: offset goes past the end of file
# LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 2 in section 3: unable to access section [index 6] data at 0x17e7e7e8b0: offset goes past the end of file
# LLVM-NEXT:     0x2 R_X86_64_NONE - 0x0
# LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 4 in section 3: invalid section index: 255
# LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 5 in section 3: a section [index 2] has an invalid sh_name (0xfefefefe) offset which goes past the end of the section name string table
# LLVM-NEXT:   }
# LLVM-NEXT:   Section (4) .rela.text {
# LLVM-NEXT: warning: '[[FILE]]': unable to print relocation 1 in section 4: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM
# LLVM-NEXT:   }
# LLVM-NEXT: ]

# GNU:       Relocation section '.rel.text' at offset 0x41 contains 5 entries:
# GNU-NEXT:      Offset             Info             Type               Symbol's Value  Symbol's Name
# GNU-NEXT:  warning: '[[FILE]]': unable to print relocation 1 in section 3: unable to access section [index 6] data at 0x17e7e7e8b0: offset goes past the end of file
# GNU-NEXT:  warning: '[[FILE]]': unable to print relocation 2 in section 3: unable to access section [index 6] data at 0x17e7e7e8b0: offset goes past the end of file
# GNU-NEXT:  0000000000000002  0000000000000000 R_X86_64_NONE
# GNU-NEXT:  warning: '[[FILE]]': unable to print relocation 4 in section 3: invalid section index: 255
# GNU-NEXT:  warning: '[[FILE]]': unable to print relocation 5 in section 3: a section [index 2] has an invalid sh_name (0xfefefefe) offset which goes past the end of the section name string table
# GNU-EMPTY:
# GNU-NEXT:  Relocation section '.rela.text' at offset 0x91 contains 1 entries:
# GNU-NEXT:      Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
# GNU-NEXT:  warning: '[[FILE]]': unable to print relocation 1 in section 4: invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name:    .text
    Type:    SHT_PROGBITS
    Content: '00'
  - Name:   .foo
    Type:   SHT_PROGBITS
    ShName: 0xFEFEFEFE
  - Name: .rel.text
    Type: SHT_REL
    Info: .text
    Relocations:
## Case 1: There is no symbol with index 0xFEFEFEFE.
      - Symbol: 0xFEFEFEFE
        Type:   R_X86_64_NONE
      - Symbol: 0xFEFEFEFE
        Type:   R_X86_64_NONE
## Case 2: Test that no warning is reported for a relocation against a symbol with index 0.
      - Offset: 0x2
        Symbol: 0
        Type:   R_X86_64_NONE
## Case 3: Test a relocation against a section symbol that has an invalid
##         section index (larger than the number of sections).
      - Offset: 0x3
        Symbol: .sec.symbol1
        Type:   R_X86_64_NONE
## Case 4: Test a relocation against a section symbol that has an invalid
##         sh_name offset that goes past the end of the section name string table.
      - Offset: 0x4
        Symbol: .sec.symbol2
        Type:   R_X86_64_NONE
## Case 5: Test a relocation in a section that is linked to a symbol table that
##         has a section type that is neither SHT_SYMTAB nor SHT_DYNSYM.
##         In this case the code fails to find a corresponding symbol string table.
  - Name: .rela.text
    Type: SHT_RELA
    Info: .text
    Link: .fake.symtab
    Relocations:
      - Offset: 0x5
        Symbol: symbol
        Type:   R_X86_64_NONE
  - Name:    .fake.symtab
    Type:    SHT_PROGBITS
    EntSize: 24
    Size:    48
Symbols:
  - Name:    symbol
    Section: .text
    Value:   0
  - Name:  .sec.symbol1
    Type:  STT_SECTION
    Index: 0xFF
  - Name:  .sec.symbol2
    Type:  STT_SECTION
    Index: 0x2