1 ## Test that yaml2obj emits a .debug_str_offsets section when requested.
3 ## a) Generate and verify a little endian .debug_str_offsets section.
5 # RUN: yaml2obj -DENDIAN=ELFDATA2LSB --docnum=1 %s -o %t1.le.o
6 # RUN: llvm-readobj --sections --section-data %t1.le.o | \
7 # RUN: FileCheck -DSIZE=48 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF-LE
10 # SHDR-NEXT: Name: .debug_str_offsets (1)
11 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
12 # SHDR-NEXT: Flags [ (0x0)
14 # SHDR-NEXT: Address: 0x0
15 # SHDR-NEXT: Offset: 0x40
16 # SHDR-NEXT: Size: [[SIZE]]
19 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
20 # SHDR-NEXT: EntrySize: 0
21 # DWARF-LE-NEXT: SectionData (
22 # DWARF-LE-NEXT: 0000: 0C000000 05000000 78563412 21436587 |........xV4.!Ce.|
23 ## ^------- unit_length (4-byte)
24 ## ^--- version (2-byte)
25 ## ^--- padding (2-byte)
26 ## ^------- offsets[0] (4-byte)
27 ## ^------- offsets[1] (4-byte)
28 # DWARF-LE-NEXT: 0010: FFFFFFFF 14000000 00000000 05000000 |................|
29 ## ^------------------------- unit_length (12-byte)
30 ## ^--- version (2-byte)
31 ## ^--- padding (2-byte)
32 # DWARF-LE-NEXT: 0020: F0DEBC9A 78563412 89674523 01EFCDAB |....xV4..gE#....|
33 ## ^---------------- offsets[0] (8-byte)
34 ## ^---------------- offsets[1] (8-byte)
52 ## b) Generate and verify a big endian .debug_str_offsets section.
54 # RUN: yaml2obj -DENDIAN=ELFDATA2MSB --docnum=1 %s -o %t1.be.o
55 # RUN: llvm-readobj --sections --section-data %t1.be.o | \
56 # RUN: FileCheck -DSIZE=48 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF-BE
58 # DWARF-BE-NEXT: SectionData (
59 # DWARF-BE-NEXT: 0000: 0000000C 00050000 12345678 87654321 |.........4Vx.eC!|
60 ## ^------- unit_length (4-byte)
61 ## ^--- version (2-byte)
62 ## ^--- padding (2-byte)
63 ## ^------- offsets[0] (4-byte)
64 ## ^------- offsets[1] (4-byte)
65 # DWARF-BE-NEXT: 0010: FFFFFFFF 00000000 00000014 00050000 |................|
66 ## ^------------------------- unit_length (12-byte)
67 ## ^--- version (2-byte)
68 ## ^--- padding (2-byte)
69 # DWARF-BE-NEXT: 0020: 12345678 9ABCDEF0 ABCDEF01 23456789 |.4Vx........#Eg.|
70 ## ^---------------- offsets[0] (8-byte)
71 ## ^---------------- offsets[1] (8-byte)
74 ## c) Test that the length, version and padding fields can be overwritten.
76 # RUN: yaml2obj --docnum=2 %s -o %t2.o
77 # RUN: llvm-readelf --hex-dump=.debug_str_offsets %t2.o | \
78 # RUN: FileCheck %s --check-prefix=OVERWRITE
80 # OVERWRITE: Hex dump of section '.debug_str_offsets':
81 # OVERWRITE-NEXT: 0x00000000 34120000 06001200 4.......
82 ## ^------- unit_length (4-byte)
83 ## ^--- version (2-byte)
84 ## ^--- padding (2-bye)
97 ## d) Test that an empty 'Offsets' field is allowed.
99 # RUN: yaml2obj --docnum=3 %s -o %t3.o
100 # RUN: llvm-readelf --hex-dump=.debug_str_offsets %t3.o | \
101 # RUN: FileCheck %s --check-prefix=EMPTY-OFFSETS
103 # EMPTY-OFFSETS: Hex dump of section '.debug_str_offsets':
104 # EMPTY-OFFSETS-NEXT: 0x00000000 04000000 05000000 ........
105 ## ^------- unit_length (4-byte)
106 ## ^--- version (2-byte)
107 ## ^--- padding (2-byte)
118 ## e) Test that the .debug_str_offsets section header is emitted if the "debug_str_offsets" is empty.
120 # RUN: yaml2obj --docnum=4 %s -o %t4.o
121 # RUN: llvm-readobj --sections --section-data %t4.o | \
122 # RUN: FileCheck -DSIZE=0 -DADDRALIGN=1 %s --check-prefixes=SHDR,EMPTY-CONTENT
124 # EMPTY-CONTENT-NEXT: SectionData (
125 # EMPTY-CONTENT-NEXT: )
133 debug_str_offsets: []
135 ## f) Generate the .debug_str_offsets section from raw section content.
137 # RUN: yaml2obj --docnum=5 %s -o %t5.o
138 # RUN: llvm-readobj --sections --section-data %t5.o | \
139 # RUN: FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT
141 # ARBITRARY-CONTENT: SectionData (
142 # ARBITRARY-CONTENT-NEXT: 0000: 112233
143 # ARBITRARY-CONTENT-NEXT: )
151 - Name: .debug_str_offsets
155 ## g) Generate the .debug_str_offsets section when the "Size" is specified.
157 # RUN: yaml2obj --docnum=6 %s -o %t6.o
158 # RUN: llvm-readelf --hex-dump=.debug_str_offsets %t6.o | \
159 # RUN: FileCheck %s --check-prefix=SIZE
161 # SIZE: Hex dump of section '.debug_str_offsets':
162 # SIZE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
171 - Name: .debug_str_offsets
175 ## h) Test that yaml2obj emits an error message when both the "Size" and the
176 ## "debug_str_offsets" entry are specified at the same time.
178 # RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERROR
180 # ERROR: yaml2obj: error: cannot specify section '.debug_str_offsets' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
188 - Name: .debug_str_offsets
195 ## i) Test that yaml2obj emits an error message when both the "Content" and the
196 ## "debug_str_offsets" entry are specified at the same time.
198 # RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=ERROR
206 - Name: .debug_str_offsets
213 ## j) Test that all the properties can be overridden by the section header when
214 ## the "debug_str_offsets" entry doesn't exist.
216 # RUN: yaml2obj --docnum=9 %s -o %t9.o
217 # RUN: llvm-readelf --sections %t9.o | FileCheck %s --check-prefix=OVERRIDDEN
219 # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
220 # OVERRIDDEN: [ 1] .debug_str_offsets STRTAB 0000000000002020 000050 000008 01 A 2 1 2
221 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000058 000000 00 0 0 0
229 - Name: .debug_str_offsets
230 Type: SHT_STRTAB ## SHT_PROGBITS by default.
231 Flags: [SHF_ALLOC] ## 0 by default.
232 Link: .sec ## 0 by default.
233 EntSize: 1 ## 0 by default.
234 Info: 1 ## 0 by default.
235 AddressAlign: 2 ## 0 by default.
236 Address: 0x2020 ## 0x00 by default.
237 Offset: 0x50 ## 0x40 for the first section.
238 Size: 0x08 ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
239 - Name: .sec ## Linked by .debug_str_offsets.
242 ## k) Test that all the properties can be overridden by the section header when
243 ## the "debug_str_offsets" entry exists.
245 # RUN: yaml2obj --docnum=10 %s -o %t10.o
246 # RUN: llvm-readelf --sections %t10.o | FileCheck %s --check-prefix=OVERRIDDEN
254 - Name: .debug_str_offsets
255 Type: SHT_STRTAB ## SHT_PROGBITS by default.
256 Flags: [SHF_ALLOC] ## 0 by default.
257 Link: .sec ## 0 by default.
258 EntSize: 1 ## 0 by default.
259 Info: 1 ## 0 by default.
260 AddressAlign: 2 ## 1 by default.
261 Address: 0x2020 ## 0x00 by default.
262 Offset: 0x50 ## 0x40 for the first section.
263 - Name: .sec ## Linked by .debug_str_offsets.