aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/tools/llvm-readobj/ELF/sframe-header.test
blob: e7c0db0d957c18cfeadc34d7331b9c7dbcb870b9 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
## Check parsing and dumping of the SFrame header.
# RUN: yaml2obj --docnum=1 %s -o %t.1
# RUN: llvm-readobj --sframe=.sframe_bad_sh_size --sframe=.sframe_1b \
# RUN:   --sframe=.sframe_bad_magic --sframe=.sframe_bad_version \
# RUN:   --sframe=.sframe_6b --sframe=.sframe_short_auxheader \
# RUN:   --sframe=.sframe_header %t.1 2>&1 | \
# RUN:   FileCheck %s --strict-whitespace --match-full-lines \
# RUN:   -DFILE=%t.1 --check-prefix=CASE1

## Check big-endian support and the handling of --sframe argument default.
# RUN: yaml2obj --docnum=2 %s -o %t.2
# RUN: llvm-readobj --sframe %t.2 2>&1 | \
# RUN:   FileCheck %s --strict-whitespace --match-full-lines \
# RUN:   -DFILE=%t.2 --check-prefix=CASE2

## Check handling of corrupted elf files (bad sh_name)
# RUN: yaml2obj --docnum=3 %s -o %t.3
# RUN: not llvm-readobj --sframe %t.3 2>&1 | \
# RUN:   FileCheck %s --strict-whitespace --match-full-lines \
# RUN:   -DFILE=%t.3 --check-prefix=CASE3

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
Sections:
  - Name:  .sframe_bad_sh_size
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ShSize: 0xfffff
# CASE1-LABEL:SFrame section '.sframe_bad_sh_size' {
#       CASE1:{{.*}}: warning: '[[FILE]]': The end of the file was unexpectedly encountered
  - Name:  .sframe_1b
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [ 0x00 ]
# CASE1-LABEL:SFrame section '.sframe_1b' {
#       CASE1:{{.*}}: warning: '[[FILE]]': invalid sframe section: unexpected end of data at offset 0x1 while reading [0x0, 0x4)

  - Name:  .sframe_bad_magic
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [ 0xde, 0xad, 0xbe, 0xef]
# CASE1-LABEL:SFrame section '.sframe_bad_magic' {
#       CASE1:{{.*}}: warning: '[[FILE]]': invalid sframe section: invalid magic number (0xadde)

  - Name:  .sframe_bad_version
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [
      0xe2, 0xde, 0x01, 0x00  # Preamble (magic, version, flags)
    ]
# CASE1-LABEL:SFrame section '.sframe_bad_version' {
#       CASE1:{{.*}}: warning: '[[FILE]]': invalid sframe section: invalid/unsupported version number (1)

  - Name:  .sframe_6b
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [
      0xe2, 0xde, 0x02, 0x00,  # Preamble (magic, version, flags)
      0x01, 0x02
    ]
# CASE1-LABEL:SFrame section '.sframe_6b' {
#       CASE1:{{.*}}: warning: '[[FILE]]': invalid sframe section: unexpected end of data at offset 0x6 while reading [0x0, 0x1c)

  - Name:  .sframe_short_auxheader
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [
      0xe2, 0xde, 0x02, 0x06,  # Preamble (magic, version, flags)
      # Header:
      0x03, 0x42, 0x47, 0x08,  # ABI, Fixed FP offset, Fixed RA Offset, AUX header length
      0x01, 0x00, 0x00, 0x00,  # Number of FDEs
      0x10, 0x00, 0x00, 0x00,  # Number of FREs
      0x00, 0x10, 0x00, 0x00,  # FRE length
      0x00, 0x00, 0x00, 0x00,  # FDE offset
      0x00, 0x01, 0x00, 0x00,  # FRE offset
      0xde, 0xad, 0xbe, 0xef,  # AUX header
    ]
# CASE1-LABEL:SFrame section '.sframe_short_auxheader' {
#       CASE1:  Header {
#  CASE1-NEXT:    Magic: 0xDEE2
#  CASE1-NEXT:    Version: V2 (0x2)
#  CASE1-NEXT:    Flags [ (0x6)
#  CASE1-NEXT:      FDEFuncStartPCRel (0x4){{ *}}
#  CASE1-NEXT:      FramePointer (0x2){{ *}}
#  CASE1-NEXT:    ]
#  CASE1-NEXT:    ABI: AMD64EndianLittle (0x3)
#  CASE1-NEXT:    CFA fixed FP offset (unused): 66
#  CASE1-NEXT:    CFA fixed RA offset: 71
#  CASE1-NEXT:    Auxiliary header length: 8
#  CASE1-NEXT:    Num FDEs: 1
#  CASE1-NEXT:    Num FREs: 16
#  CASE1-NEXT:    FRE subsection length: 4096
#  CASE1-NEXT:    FDE subsection offset: 0
#  CASE1-NEXT:    FRE subsection offset: 256
#  CASE1-NEXT:{{.*}}: warning: '[[FILE]]': unexpected end of data at offset 0x20 while reading [0x1c, 0x24)
#  CASE1-NEXT:  }
#  CASE1-NEXT:{{.*}}: warning: '[[FILE]]': unexpected end of data at offset 0x20 while reading [0x24, 0x38)
#  CASE1-NEXT:}

  - Name:  .sframe_header
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [
      0xe2, 0xde, 0x02, 0x06,  # Preamble (magic, version, flags)
      # Header:
      0x03, 0x42, 0x47, 0x04,  # ABI, Fixed FP offset, Fixed RA Offset, AUX header length
      0x00, 0x00, 0x00, 0x00,  # Number of FDEs
      0x10, 0x00, 0x00, 0x00,  # Number of FREs
      0x00, 0x10, 0x00, 0x00,  # FRE length
      0x00, 0x00, 0x00, 0x00,  # FDE offset
      0x00, 0x01, 0x00, 0x00,  # FRE offset
      0xde, 0xad, 0xbe, 0xef,  # AUX header
    ]
# CASE1-LABEL:SFrame section '.sframe_header' {
#       CASE1:  Header {
#  CASE1-NEXT:    Magic: 0xDEE2
#  CASE1-NEXT:    Version: V2 (0x2)
#  CASE1-NEXT:    Flags [ (0x6)
#  CASE1-NEXT:      FDEFuncStartPCRel (0x4){{ *}}
#  CASE1-NEXT:      FramePointer (0x2){{ *}}
#  CASE1-NEXT:    ]
#  CASE1-NEXT:    ABI: AMD64EndianLittle (0x3)
#  CASE1-NEXT:    CFA fixed FP offset (unused): 66
#  CASE1-NEXT:    CFA fixed RA offset: 71
#  CASE1-NEXT:    Auxiliary header length: 4
#  CASE1-NEXT:    Num FDEs: 0
#  CASE1-NEXT:    Num FREs: 16
#  CASE1-NEXT:    FRE subsection length: 4096
#  CASE1-NEXT:    FDE subsection offset: 0
#  CASE1-NEXT:    FRE subsection offset: 256
#  CASE1-NEXT:    Auxiliary header: [0xDE, 0xAD, 0xBE, 0xEF]
#  CASE1-NEXT:  }
#  CASE1-NEXT:  Function Index [
#  CASE1-NEXT:  ]
#  CASE1-NEXT:}

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2MSB
  Type:  ET_EXEC
Sections:
  - Name:  .sframe
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ContentArray: [
      0xde, 0xe2, 0x02, 0x01,  # Preamble (magic, version, flags)
      # Header:
      0x01, 0x42, 0x47, 0x00,  # ABI, Fixed FP offset, Fixed RA Offset, AUX header length
      0x00, 0x00, 0x00, 0x00,  # Number of FDEs
      0x00, 0x00, 0x00, 0x10,  # Number of FREs
      0x00, 0x00, 0x10, 0x00,  # FRE length
      0x00, 0x00, 0x00, 0x00,  # FDE offset
      0x00, 0x00, 0x01, 0x00,  # FRE offset
    ]
# CASE2-LABEL:SFrame section '.sframe' {
#       CASE2:  Header {
#  CASE2-NEXT:    Magic: 0xDEE2
#  CASE2-NEXT:    Version: V2 (0x2)
#  CASE2-NEXT:    Flags [ (0x1)
#  CASE2-NEXT:      FDESorted (0x1){{ *}}
#  CASE2-NEXT:    ]
#  CASE2-NEXT:    ABI: AArch64EndianBig (0x1)
#  CASE2-NEXT:    CFA fixed FP offset (unused): 66
#  CASE2-NEXT:    CFA fixed RA offset (unused): 71
#  CASE2-NEXT:    Auxiliary header length: 0
#  CASE2-NEXT:    Num FDEs: 0
#  CASE2-NEXT:    Num FREs: 16
#  CASE2-NEXT:    FRE subsection length: 4096
#  CASE2-NEXT:    FDE subsection offset: 0
#  CASE2-NEXT:    FRE subsection offset: 256
#  CASE2-NEXT:    Auxiliary header: []
#  CASE2-NEXT:  }
#  CASE2-NEXT:  Function Index [
#  CASE2-NEXT:  ]
#  CASE2-NEXT:}

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2MSB
  Type:  ET_EXEC
Sections:
  - Name:  .corrupted
    Type:  SHT_GNU_SFRAME
    Flags: [ SHF_ALLOC ]
    ShName: 0x10000
# CASE3:{{.*}}: error: '[[FILE]]': a section [index 1] has an invalid sh_name (0x10000) offset which goes past the end of the section name string table