debug-aranges.yaml
7.42 KB
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
192
193
194
195
196
197
198
199
200
## Test how we dump the .debug_aranges section.
## a) Test dumping the DWARF32/64 address range table from 32/64-bit, little/big endian object files.
## The .debug_aranges should be written to the 'DWARF' entry and the 'Sections' entry should remain empty.
# RUN: yaml2obj --docnum=1 -DBITS=32 -DENDIAN=LSB %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
# RUN: -DLENGTH1=24 -DLENGTH2=24 -DADDRSIZE=0x04 \
# RUN: -DVARADDR=0x0000000000001234 -DVARLEN=0x0000000000005678
# RUN: yaml2obj --docnum=1 -DBITS=32 -DENDIAN=MSB %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
# RUN: -DLENGTH1=24 -DLENGTH2=24 -DADDRSIZE=0x04 \
# RUN: -DVARADDR=0x0000000000001234 -DVARLEN=0x0000000000005678
# RUN: yaml2obj --docnum=1 -DBITS=64 -DENDIAN=LSB %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
# RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x08 \
# RUN: -DVARADDR=0x0000000000001234 -DVARLEN=0x0000000000005678
# RUN: yaml2obj --docnum=1 -DBITS=64 -DENDIAN=MSB %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
# RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x08 \
# RUN: -DVARADDR=0x0000000000001234 -DVARLEN=0x0000000000005678
# BASIC: DWARF:
# BASIC-NEXT: debug_aranges:
# BASIC-NEXT: - Length: 0x00000000000000[[LENGTH1]]
# BASIC-NEXT: Version: 2
# BASIC-NEXT: CuOffset: 0x0000000000001234
# BASIC-NEXT: AddressSize: [[ADDRSIZE]]
# BASIC-NEXT: Descriptors:
# BASIC-NEXT: - Address: 0x0000000000001234
# BASIC-NEXT: Length: 0x0000000000005678
# BASIC-NEXT: - Address: 0x0000000000001234
# BASIC-NEXT: Length: 0x0000000000005678
# BASIC-NEXT: - Format: DWARF64
# BASIC-NEXT: Length: 0x00000000000000[[LENGTH2]]
# BASIC-NEXT: Version: 2
# BASIC-NEXT: CuOffset: 0x1234567890ABCDEF
# BASIC-NEXT: AddressSize: [[ADDRSIZE]]
# BASIC-NEXT: Descriptors:
# BASIC-NEXT: - Address: [[VARADDR]]
# BASIC-NEXT: Length: [[VARLEN]]
# BASIC-NEXT: - Address: 0x0000000000001234
# BASIC-NEXT: Length: 0x0000000000005678
# BASIC-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS]]
Data: ELFDATA2[[ENDIAN]]
Type: ET_EXEC
DWARF:
debug_aranges:
- Version: 2
CuOffset: 0x1234
Descriptors:
- Address: 0x1234
Length: 0x5678
- Address: 0x1234
Length: 0x5678
- Format: DWARF64
Version: 2
CuOffset: 0x1234567890abcdef
Descriptors:
- Address: [[ADDR=0x1234]]
Length: [[LENGTH=0x5678]]
- Address: 0x1234
Length: 0x5678
## b) Test dumping an .debug_aranges section whose section header properties are overridden.
# RUN: yaml2obj --docnum=2 -DTYPE=SHT_STRTAB %s | obj2yaml | FileCheck %s -DTYPE=STRTAB --check-prefixes=ARANGE,SHDR
# RUN: yaml2obj --docnum=2 -DFLAGS=[SHF_ALLOC] %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,FLAGS
# RUN: yaml2obj --docnum=2 -DLINK='.sec' %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,LINK
# RUN: yaml2obj --docnum=2 -DENTSIZE=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ENTSIZE
# RUN: yaml2obj --docnum=2 -DINFO=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,INFO
# RUN: yaml2obj --docnum=2 -DADDRALIGN=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ADDRALIGN
# RUN: yaml2obj --docnum=2 -DADDRESS=0x2020 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ADDRESS
# SHDR: - Name: .debug_aranges
# SHDR-NEXT: Type: SHT_[[TYPE]]
# FLAGS-NEXT: Flags: [ SHF_ALLOC ]
# LINK-NEXT: Link: .sec
# ENTSIZE-NEXT: EntSize: 0x0000000000000003
# INFO-NEXT: Info: 0x0000000000000003
# ADDRALIGN-NEXT: AddressAlign: 0x0000000000000003
# ADDRESS-NEXT: Address: 0x0000000000002020
# ARANGE: DWARF:
# ARANGE-NEXT: debug_aranges:
# ARANGE-NEXT: - Length: 0x000000000000001C
# ARANGE-NEXT: Version: 2
# ARANGE-NEXT: CuOffset: 0x0000000000001234
# ARANGE-NEXT: AddressSize: 0x08
# ARANGE-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_aranges
Type: [[TYPE=SHT_PROGBITS]]
Flags: [[FLAGS=<none>]]
Link: [[LINK='']]
EntSize: [[ENTSIZE=<none>]]
Info: [[INFO=<none>]]
AddressAlign: [[ADDRALIGN=0]]
Address: [[ADDRESS=<none>]]
- Name: .sec
Type: SHT_PROGBITS
DWARF:
debug_aranges:
- Version: 2
CuOffset: 0x1234
## c) Test dumping a .debug_aranges section whose address_size doesn't match the
## object file's address size.
# RUN: yaml2obj --docnum=3 %s | obj2yaml | \
# RUN: FileCheck %s -DLENGTH=0x000000000000001C -DADDRSIZE=0x04 -DADDRLEN=0x0000000012345678 --check-prefix=ADDRSIZE
# ADDRSIZE: DWARF:
# ADDRSIZE-NEXT: debug_aranges:
# ADDRSIZE-NEXT: - Length: [[LENGTH]]
# ADDRSIZE-NEXT: Version: 2
# ADDRSIZE-NEXT: CuOffset: 0x0000000000001234
# ADDRSIZE-NEXT: AddressSize: [[ADDRSIZE]]
# ADDRSIZE-NEXT: Descriptors:
# ADDRSIZE-NEXT: - Address: [[ADDRLEN]]
# ADDRSIZE-NEXT: Length: [[ADDRLEN]]
# ADDRSIZE-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS=64]]
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_aranges:
- Version: 2
CuOffset: 0x1234
AddressSize: [[ADDRSIZE=0x04]]
Descriptors:
- Address: [[ADDRLEN=0x12345678]]
Length: [[ADDRLEN=0x12345678]]
# RUN: yaml2obj --docnum=3 -DBITS=32 -DADDRSIZE=0x08 -DADDRLEN=0x1234567890abcdef %s | \
# RUN: obj2yaml | \
# RUN: FileCheck %s -DLENGTH=0x000000000000002C -DADDRSIZE=0x08 -DADDRLEN=0x1234567890ABCDEF --check-prefix=ADDRSIZE
## d) Test dumping a .debug_aranges section whose length field doesn't match the actual length.
## This makes the DWARF parser fail to parse it and we will dump it as a raw content section.
# RUN: yaml2obj --docnum=4 %s | obj2yaml | FileCheck %s --check-prefix=RAW-CONTENT
# RAW-CONTENT: Sections:
# RAW-CONTENT-NEXT: - Name: .debug_aranges
# RAW-CONTENT-NEXT: Type: SHT_PROGBITS
# RAW-CONTENT-NEXT: AddressAlign: 0x0000000000000001
# RAW-CONTENT-NEXT: Content: '3412000002003412000008000000000000000000000000000000000000000000'
# RAW-CONTENT-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_aranges:
- Length: 0x1234
Version: 2
CuOffset: 0x1234
## e) Test dumping an empty .debug_aranges section.
# RUN: yaml2obj --docnum=5 %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-CONTENT
# EMPTY-CONTENT: DWARF:
# EMPTY-CONTENT-NEXT: debug_aranges: []
# EMPTY-CONTENT-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_aranges: []
## f) Show that dumping a table with a premature terminator entry still uses the
## DWARF tag.
# RUN: yaml2obj --docnum=1 %s -DADDR=0 -DLENGTH=0 -DBITS=64 -DENDIAN=LSB | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
# RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x08 \
# RUN: -DVARADDR=0x0000000000000000 -DVARLEN=0x0000000000000000