debug-str.yaml
6.97 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
## Test that yaml2obj emits .debug_str section.
## a) Generate the .debug_str section from the "DWARF" entry.
# RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: llvm-readelf --string-dump=.debug_str %t1.o | FileCheck %s --check-prefix=DWARF-DEFAULT
# DWARF-DEFAULT: String dump of section '.debug_str':
# DWARF-DEFAULT-NEXT: [ 0] a
# DWARF-DEFAULT-NEXT: [ 2] b
# DWARF-DEFAULT-NEXT: [ 4] c
## Check the default sh_type, sh_entsize, sh_info, sh_flags and sh_addralign of the
## .debug_str section header.
# RUN: llvm-readelf -S %t1.o | FileCheck -DSIZE=000006 %s --check-prefix=SHDRS-DEFAULT
# SHDRS-DEFAULT: Name Type Address Off Size ES Flg Lk Inf Al
# SHDRS-DEFAULT: .debug_str PROGBITS 0000000000000000 000040 [[SIZE]] 01 MS 0 0 1
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_str:
- a
- b
- c
## b) Generate the .debug_str section from the raw section content.
# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: llvm-readelf --string-dump=.debug_str %t2.o | FileCheck %s --check-prefix=DWARF-DEFAULT
# RUN: llvm-readelf -S %t2.o | FileCheck %s --check-prefix=SHDRS
# SHDRS: Name Type Address Off Size ES Flg Lk Inf Al
# SHDRS: .debug_str PROGBITS 0000000000000000 000040 000006 01 MS 0 0 0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_PROGBITS
Content: "610062006300"
## c) Generate the .debug_str section when the "Size" is specified.
# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: llvm-readelf -S %t3.o | FileCheck %s --check-prefix=SIZE
# RUN: llvm-readelf --hex-dump=.debug_str %t3.o | FileCheck %s --check-prefix=SIZE-CONTENT
# SIZE: Name Type Address Off Size ES Flg Lk Inf Al
# SIZE: .debug_str PROGBITS 0000000000000000 000040 000010 01 MS 0 0 0
# SIZE-CONTENT: Hex dump of section '.debug_str':
# SIZE-CONTENT-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
# SIZE-CONTENT-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_PROGBITS
Size: 0x10
## d) Test that yaml2obj emits an error message when both the "Size" and the
## "debug_str" entry are specified at the same time.
# RUN: not yaml2obj --docnum=4 %s -o %t4.o 2>&1 | FileCheck %s --check-prefix=ERROR
# ERROR: yaml2obj: error: cannot specify section '.debug_str' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_PROGBITS
Size: 0x10
DWARF:
debug_str:
- a
## e) Test that yaml2obj emits an error message when both the "Content" and the
## "debug_str" entry are specified at the same time.
# RUN: not yaml2obj --docnum=5 %s -o %t5.o 2>&1 | FileCheck %s --check-prefix=ERROR
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_PROGBITS
Content: "6100"
DWARF:
debug_str:
- a
## f) Test that all the properties can be overridden by the section header when
## the "debug_str" entry doesn't exist.
# RUN: yaml2obj --docnum=6 %s -o %t6.o
# RUN: llvm-readelf -S %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
# OVERRIDDEN: [ 1] .sec STRTAB 0000000000000000 000040 000000 00 0 0 0
# OVERRIDDEN: [ 2] .debug_str STRTAB 0000000000002020 000050 000006 02 A 1 1 2
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .sec # Linked by .debug_str.
Type: SHT_STRTAB
- Name: .debug_str
Type: SHT_STRTAB # SHT_PROGBITS by default.
Flags: [SHF_ALLOC] # [SHF_STRINGS, SHF_MERGE] by default.
Link: .sec # 0 by default.
EntSize: 2 # 1 by default.
Info: 1 # 0 by default.
AddressAlign: 2 # 0 by default.
Address: 0x0000000000002020 # 0x00 by default.
Offset: 0x00000050 # 0x40 for the first section.
Size: 6 # Set the "Size" so that we can reuse the check tag "OVERRIDDEN"
## g) Test that all the properties can be overridden by the section header when
## the "debug_str" entry is used.
# RUN: yaml2obj --docnum=7 %s -o %t7.o
# RUN: llvm-readelf --string-dump=.debug_str %t7.o | FileCheck %s --check-prefix=DWARF-DEFAULT
# RUN: llvm-readelf -S %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .sec # Linked by .debug_str.
Type: SHT_STRTAB
- Name: .debug_str
Type: SHT_STRTAB # SHT_PROGBITS by default.
Flags: [SHF_ALLOC] # [SHF_STRINGS, SHF_MERGE] by default.
Link: .sec # 0 by default.
EntSize: 2 # 1 by default.
Info: 1 # 0 by default.
AddressAlign: 2 # 1 by default.
Address: 0x0000000000002020 # 0x00 by default.
Offset: 0x00000050 # 0x40 for the first section.
DWARF:
debug_str:
- a
- b
- c
## h) Test that if we try to initialize the .debug_str section with a "Type" with non-standard
## syntax, e.g., SHT_DYNAMIC, yaml2obj will treat it as a dynamic section and discard the
## content in the "DWARF" entry.
# RUN: yaml2obj --docnum=8 %s -o %t8.o
# RUN: llvm-readelf -S %t8.o | FileCheck %s --check-prefix=DYN-SHDR
# RUN: llvm-readelf -d %t8.o | FileCheck %s --check-prefix=DYNAMIC
# RUN: yaml2obj --docnum=9 %s -o %t9.o
# RUN: llvm-readelf -S %t9.o | FileCheck %s --check-prefix=DYN-SHDR
# RUN: llvm-readelf -d %t9.o | FileCheck %s --check-prefix=DYNAMIC
# DYN-SHDR: Name Type Address Off Size ES Flg Lk Inf Al
# DYN-SHDR: .debug_str DYNAMIC 0000000000000000 000040 000010 10 0 0 0
# DYNAMIC: Dynamic section at offset 0x40 contains 1 entries:
# DYNAMIC-NEXT: Tag Type Name/Value
# DYNAMIC-NEXT: 0x0000000000000000 (NULL) 0x0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_DYNAMIC
Entries:
- Tag: DT_NULL
Value: 0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str
Type: SHT_DYNAMIC
Entries:
- Tag: DT_NULL
Value: 0
DWARF:
debug_str:
- a
## i) Test that the .debug_str section header is emitted if the "debug_str"
## entry is empty.
# RUN: yaml2obj --docnum=10 %s -o %t10.o
# RUN: llvm-readelf -S %t10.o | FileCheck -DSIZE=000000 %s --check-prefix=SHDRS-DEFAULT
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_str: []