File: shstrtab.yaml

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (447 lines) | stat: -rw-r--r-- 14,031 bytes parent folder | download | duplicates (21)
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
## Show that the SectionHeaderStringTable field in the document header is set,
## iff the section name is not ".shstrtab".
## Also show that no section appears in the Sections table for this section,
## unless some property is different to the default.

## Show the case when the name is a custom string (the key should be set).
# RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: obj2yaml %t1.o > %t1.yaml
# RUN: FileCheck %s --input-file=%t1.yaml --check-prefix=CUSTOM

# CUSTOM:      --- !ELF
# CUSTOM-NEXT: FileHeader:
# CUSTOM-NEXT:   Class:           ELFCLASS64
# CUSTOM-NEXT:   Data:            ELFDATA2LSB
# CUSTOM-NEXT:   Type:            ET_EXEC
# CUSTOM-NEXT:   SectionHeaderStringTable: .foo
# CUSTOM-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .foo

## Show the case when the e_shstrndx value is SHN_XINDEX and the name is not
## ".shstrtab" (the key should be set).
# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: obj2yaml %t2.o > %t2.yaml
# RUN: FileCheck %s --input-file=%t2.yaml --check-prefix=XINDEX

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_EXEC
  EShStrNdx: 0xffff
  SectionHeaderStringTable: .foo
Sections:
  - Type: SHT_NULL
    Link: .foo

# XINDEX:      --- !ELF
# XINDEX-NEXT: FileHeader:
# XINDEX-NEXT:   Class:           ELFCLASS64
# XINDEX-NEXT:   Data:            ELFDATA2LSB
# XINDEX-NEXT:   Type:            ET_EXEC
# XINDEX-NEXT:   SectionHeaderStringTable: .foo
# XINDEX-NEXT: Sections:
# XINDEX-NEXT:   - Type:            SHT_NULL
# XINDEX-NEXT:     Link:            .foo
# XINDEX-NEXT:     Size:            0x0
# XINDEX-NEXT: ...

## Show the case when the string table section is also the symbol table's string
## table (the key should be set).
# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: obj2yaml %t3.o > %t3.yaml
# RUN: FileCheck %s --input-file=%t3.yaml --check-prefix=STRTAB

# STRTAB:      --- !ELF
# STRTAB-NEXT: FileHeader:
# STRTAB-NEXT:   Class:           ELFCLASS64
# STRTAB-NEXT:   Data:            ELFDATA2LSB
# STRTAB-NEXT:   Type:            ET_EXEC
# STRTAB-NEXT:   SectionHeaderStringTable: .strtab
# STRTAB-NEXT: Symbols:
# STRTAB-NEXT:   - Name:            boz
# STRTAB-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: ".strtab"
Symbols:
  - Name: boz

## Document the case when the string table section is also the symbol table's
## dynamic string table (the key should be set).
## FIXME: Regardless of whether it is shared with the section header string
##        table or not, the dynstr (and also the dynsym) should be omitted if
##        they match the default behaviour.
# RUN: yaml2obj --docnum=4 %s -o %t4.o
# RUN: obj2yaml %t4.o > %t4.yaml
# RUN: FileCheck %s --input-file=%t4.yaml --check-prefix=DYNSTR

# DYNSTR:      --- !ELF
# DYNSTR-NEXT: FileHeader:
# DYNSTR-NEXT:   Class:           ELFCLASS64
# DYNSTR-NEXT:   Data:            ELFDATA2LSB
# DYNSTR-NEXT:   Type:            ET_EXEC
# DYNSTR-NEXT:   SectionHeaderStringTable: .dynstr
# DYNSTR-NEXT: Sections:
# DYNSTR-NEXT:   - Name:            .dynsym
# DYNSTR-NEXT:     Type:            SHT_DYNSYM
# DYNSTR-NEXT:     Flags:           [ SHF_ALLOC ]
# DYNSTR-NEXT:     Link:            .dynstr
# DYNSTR-NEXT:     AddressAlign:    0x8
# DYNSTR-NEXT:   - Name:            .dynstr
# DYNSTR-NEXT:     Type:            SHT_STRTAB
# DYNSTR-NEXT:     Flags:           [ SHF_ALLOC ]
# DYNSTR-NEXT:     Address:         0x30
# DYNSTR-NEXT:     AddressAlign:    0x1
# DYNSTR-NEXT: DynamicSymbols:
# DYNSTR-NEXT:   - Name:            boz
# DYNSTR-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: ".dynstr"
DynamicSymbols:
  - Name: boz

## Show the case when the name is the default ".shstrtab" (the key should not be
## set).
# RUN: yaml2obj --docnum=5 %s -o %t5.o
# RUN: obj2yaml %t5.o > %t5.yaml
# RUN: FileCheck %s --input-file=%t5.yaml --check-prefix=DEFAULT

# DEFAULT:      --- !ELF
# DEFAULT-NEXT: FileHeader:
# DEFAULT-NEXT:   Class:           ELFCLASS64
# DEFAULT-NEXT:   Data:            ELFDATA2LSB
# DEFAULT-NEXT:   Type:            ET_EXEC
# DEFAULT-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC

## Show the case when the e_shstrndx value is 0 and the name is ".shstrtab" (the
## key should not be set).
# RUN: yaml2obj --docnum=6 %s -o %t6.o
# RUN: obj2yaml %t6.o > %t6.yaml
# RUN: FileCheck %s --input-file=%t6.yaml --check-prefix=DEFXINDEX

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_EXEC
  EShStrNdx: 0xffff
Sections:
  - Type: SHT_NULL
    Link: .shstrtab

# DEFXINDEX:      --- !ELF
# DEFXINDEX-NEXT: FileHeader:
# DEFXINDEX-NEXT:   Class:           ELFCLASS64
# DEFXINDEX-NEXT:   Data:            ELFDATA2LSB
# DEFXINDEX-NEXT:   Type:            ET_EXEC
# DEFXINDEX-NEXT: Sections:
# DEFXINDEX-NEXT:   - Type:            SHT_NULL
# DEFXINDEX-NEXT:     Link:            .shstrtab
# DEFXINDEX-NEXT:     Size:            0x0
# DEFXINDEX-NEXT: ...

## Show that if there are no section headers, the key is not set.
# RUN: yaml2obj --docnum=7 %s -o %t7.o
# RUN: obj2yaml %t7.o > %t7.yaml
# RUN: FileCheck %s --input-file=%t7.yaml --check-prefix=NOHDRS

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
Sections:
  - Type: SectionHeaderTable
    NoHeaders: true

# NOHDRS:      --- !ELF
# NOHDRS-NEXT: FileHeader:
# NOHDRS-NEXT:   Class:  ELFCLASS64
# NOHDRS-NEXT:   Data:   ELFDATA2LSB
# NOHDRS-NEXT:   Type:   ET_EXEC
## FIXME: There should be a SectionHeaderTable key as per the input.
# NOHDRS-NEXT: ...

## Show that a custom-named section header string table can be in a reordered
## section header table.
# RUN: yaml2obj --docnum=8 %s -o %t8.o
# RUN: obj2yaml %t8.o > %t8.yaml
# RUN: FileCheck %s --input-file=%t8.yaml --check-prefix=REORDER

# REORDER:      --- !ELF
# REORDER-NEXT: FileHeader:
# REORDER-NEXT:   Class:           ELFCLASS64
# REORDER-NEXT:   Data:            ELFDATA2LSB
# REORDER-NEXT:   Type:            ET_EXEC
# REORDER-NEXT:   SectionHeaderStringTable: .foo
# REORDER-NEXT: Sections:
# REORDER-NEXT:   - Name:            .baz
# REORDER-NEXT:     Type:            SHT_PROGBITS
# REORDER-NEXT:     Offset:          0x180
# REORDER-NEXT:   - Name:            .bar
# REORDER-NEXT:     Type:            SHT_PROGBITS
## FIXME: This should be at the start of the sections list.
# REORDER-NEXT:   - Type:            SectionHeaderTable
# REORDER-NEXT:     Sections:
# REORDER-NEXT:       - Name:            .baz
# REORDER-NEXT:       - Name:            .foo
# REORDER-NEXT:       - Name:            .bar
# REORDER-NEXT:       - Name:            .strtab
# REORDER-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .foo
Sections:
  - Type: SectionHeaderTable
    Sections:
      - Name: .baz
      - Name: .foo
      - Name: .bar
      ## FIXME: we shouldn't need a .strtab section if there are no symbols.
      - Name: .strtab
  - Name: .baz
    Type: SHT_PROGBITS
  - Name: .bar
    Type: SHT_PROGBITS

## Document what happens when a custom-named section header string table is
## placed in between other sections.
## FIXME: obj2yaml should preserve the ordering in the Sections list, but it
##        doesn't for custom or default named tables.
# RUN: yaml2obj --docnum=9 %s -o %t9.o
# RUN: obj2yaml %t9.o > %t9.yaml
# RUN: FileCheck %s --input-file=%t9.yaml --check-prefix=PLACED

# PLACED:      --- !ELF
# PLACED-NEXT: FileHeader:
# PLACED-NEXT:   Class:           ELFCLASS64
# PLACED-NEXT:   Data:            ELFDATA2LSB
# PLACED-NEXT:   Type:            ET_EXEC
# PLACED-NEXT:   SectionHeaderStringTable: .foo
# PLACED-NEXT: Sections:
# PLACED-NEXT:   - Name:            .baz
# PLACED-NEXT:     Type:            SHT_PROGBITS
# PLACED-NEXT:   - Name:            .bar
# PLACED-NEXT:     Type:            SHT_PROGBITS

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .foo
Sections:
  - Name: .baz
    Type: SHT_PROGBITS
  - Name: .foo
    Type: SHT_STRTAB
  - Name: .bar
    Type: SHT_PROGBITS

## Show that a custom-named section header string table can be given different
## properties.
# RUN: yaml2obj --docnum=10 %s -o %t10.o
# RUN: obj2yaml %t10.o > %t10.yaml
# RUN: FileCheck %s --input-file=%t10.yaml --check-prefix=PROPS

# PROPS:      --- !ELF
# PROPS-NEXT: FileHeader:
# PROPS-NEXT:   Class: ELFCLASS64
# PROPS-NEXT:   Data:  ELFDATA2LSB
# PROPS-NEXT:   Type:  ET_EXEC
# PROPS-NEXT:   SectionHeaderStringTable: .foo
# PROPS-NEXT: Sections:
# PROPS-NEXT:   - Name:  .foo
# PROPS-NEXT:     Type:  SHT_STRTAB
# PROPS-NEXT:     Flags: [ SHF_ALLOC ]
# PROPS-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .foo
Sections:
  - Name:  .foo
    Type:  SHT_STRTAB
    Flags: [ SHF_ALLOC ]

## Show that an error is reported if the section header string table name cannot
## be read.
# RUN: yaml2obj --docnum=11 %s -o %t11.o
# RUNasda: not obj2yaml %t11.o 2>&1 | FileCheck %s --check-prefix=ERR -DFILE=%t11.o

# ERR: Error reading file: [[FILE]]: unable to read section header string table name: a section [index 1] has an invalid sh_name (0x10000) offset which goes past the end of the section name string table

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
Sections:
  - Name:  .shstrtab
    Type:  SHT_STRTAB
    ShName: 0x10000

## Show that the name is uniquified if necessary.

## Case 1: generic name.
# RUN: yaml2obj --docnum=12 %s -o %t12.o
# RUN: obj2yaml %t12.o > %t12.yaml
# RUN: FileCheck %s --input-file=%t12.yaml --check-prefix=UNIQUIFY1

# UNIQUIFY1:      --- !ELF
# UNIQUIFY1-NEXT: FileHeader:
# UNIQUIFY1-NEXT:   Class: ELFCLASS64
# UNIQUIFY1-NEXT:   Data:  ELFDATA2LSB
# UNIQUIFY1-NEXT:   Type:  ET_EXEC
# UNIQUIFY1-NEXT:   SectionHeaderStringTable: '.strings (1)'
# UNIQUIFY1-NEXT: Sections:
# UNIQUIFY1-NEXT:   - Name:  .strings
# UNIQUIFY1-NEXT:     Type:  SHT_PROGBITS
# UNIQUIFY1-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: '.strings (1)'
Sections:
  - Name: '.strings (2)'
    Type: SHT_PROGBITS

## Case 2: '.strtab' when symbols are present.
# RUN: yaml2obj --docnum=13 %s -o %t13.o '-DNAME=".strtab (1)"'
# RUN: obj2yaml %t13.o > %t13.yaml
# RUN: FileCheck %s --input-file=%t13.yaml --check-prefix=UNIQUIFY2 \
# RUN:   -DNAME=.strtab

# UNIQUIFY2:      --- !ELF
# UNIQUIFY2-NEXT: FileHeader:
# UNIQUIFY2-NEXT:   Class: ELFCLASS64
# UNIQUIFY2-NEXT:   Data:  ELFDATA2LSB
# UNIQUIFY2-NEXT:   Type:  ET_EXEC
# UNIQUIFY2-NEXT:   SectionHeaderStringTable: '[[NAME]] (1)'
# UNIQUIFY2-NEXT: Symbols:
# UNIQUIFY2-NEXT:   - Name:  foo
# UNIQUIFY2-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: [[NAME]]
Symbols:
  - Name: foo

## Case 3: '.symtab' when symbols are present.
# RUN: yaml2obj --docnum=13 %s -o %t14.o '-DNAME=".symtab (1)"'
# RUN: obj2yaml %t14.o > %t14.yaml
# RUN: FileCheck %s --input-file=%t14.yaml --check-prefix=UNIQUIFY2 \
# RUN:   -DNAME=.symtab

## Case 4: '.dynstr' when dynamic symbols are present.
# RUN: yaml2obj --docnum=14 %s -o %t15.o '-DNAME=".dynstr (1)"'
# RUN: obj2yaml %t15.o > %t15.yaml
# RUN: FileCheck %s --input-file=%t15.yaml --check-prefix=UNIQUIFY3 \
# RUN:   -DNAME=.dynstr

# UNIQUIFY3:      --- !ELF
# UNIQUIFY3-NEXT: FileHeader:
# UNIQUIFY3-NEXT:   Class: ELFCLASS64
# UNIQUIFY3-NEXT:   Data:  ELFDATA2LSB
# UNIQUIFY3-NEXT:   Type:  ET_EXEC
# UNIQUIFY3-NEXT:   SectionHeaderStringTable: '[[NAME]] (1)'
## FIXME: The .dynsym and .dynstr sections shouldn't need to be emitted, since
##        their values are the default produced by yaml2obj.
# UNIQUIFY3-NEXT: Sections:
# UNIQUIFY3-NEXT:   - Name:            .dynsym
# UNIQUIFY3-NEXT:     Type:            SHT_DYNSYM
# UNIQUIFY3-NEXT:     Flags:           [ SHF_ALLOC ]
# UNIQUIFY3-NEXT:     Link:            .dynstr
# UNIQUIFY3-NEXT:     AddressAlign:    0x8
# UNIQUIFY3-NEXT:   - Name:            .dynstr
# UNIQUIFY3-NEXT:     Type:            SHT_STRTAB
# UNIQUIFY3-NEXT:     Flags:           [ SHF_ALLOC ]
# UNIQUIFY3-NEXT:     Address:         0x30
# UNIQUIFY3-NEXT:     AddressAlign:    0x1
# UNIQUIFY3-NEXT: DynamicSymbols:
# UNIQUIFY3-NEXT:   - Name:  foo
# UNIQUIFY3-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: [[NAME]]
DynamicSymbols:
  - Name: foo

## Case 5: '.dynsym' when dynamic symbols are present.
# RUN: yaml2obj --docnum=14 %s -o %t16.o '-DNAME=".dynsym (1)"'
# RUN: obj2yaml %t16.o > %t16.yaml
# RUN: FileCheck %s --input-file=%t16.yaml --check-prefix=UNIQUIFY3 \
# RUN:   -DNAME=.dynsym

## Case 6: Document what happens for '.debug_str' when DWARF debug strings are
##         requested. The dwarf2yaml code uses the last .debug_* named section
##         to populate the corresponding DWARF block. As a result, the original
##         .debug_str content is lost.
## TODO: We should prevent the dwarf2yaml code from using the section header
##       string table to populate the DWARF block.
# RUN: yaml2obj --docnum=15 %s -o %t17.o
# RUN: obj2yaml %t17.o > %t17.yaml
# RUN: FileCheck %s --input-file=%t17.yaml --check-prefix=UNIQUIFY6

# UNIQUIFY6:      --- !ELF
# UNIQUIFY6-NEXT: FileHeader:
# UNIQUIFY6-NEXT:   Class:           ELFCLASS64
# UNIQUIFY6-NEXT:   Data:            ELFDATA2LSB
# UNIQUIFY6-NEXT:   Type:            ET_EXEC
# UNIQUIFY6-NEXT:   SectionHeaderStringTable: '.debug_str (1)'
# UNIQUIFY6-NEXT: DWARF:
# UNIQUIFY6-NEXT:   debug_str:
# UNIQUIFY6-NEXT:     - ''
# UNIQUIFY6-NEXT:     - .debug_str
# UNIQUIFY6-NEXT:     - .strtab
# UNIQUIFY6-NEXT: ...

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: '.debug_str (1)'
DWARF:
  debug_str:
    - string