1 ## Test that yaml2obj emits .debug_gnu_pubnames section.
3 ## a) Generate the '.debug_gnu_pubnames' section from the 'DWARF' entry.
5 ## Generate and verify a 32-bit little endian .debug_gnu_pubnames section.
7 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o
8 # RUN: llvm-readobj --sections --section-data %t1.le.o | \
9 # RUN: FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE
12 # SHDR-NEXT: Name: .debug_gnu_pubnames (1)
13 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
14 # SHDR-NEXT: Flags [ (0x0)
16 # SHDR-NEXT: Address: 0x0
17 # SHDR-NEXT: Offset: 0x40
18 # SHDR-NEXT: Size: [[SIZE]]
21 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
22 # SHDR-NEXT: EntrySize: 0
23 # DWARF32-LE-NEXT: SectionData (
24 # DWARF32-LE-NEXT: 0000: 34120000 02003412 00002143 00007856 |4.....4...!C..xV|
25 ## ^------- unit_length (4-byte)
26 ## ^--- version (2-byte)
27 ## ^-------- debug_info_offset (4-byte)
28 ## ^-------- debug_info_length (4-byte)
29 ## ^--- offset (4-byte)
30 # DWARF32-LE-NEXT: 0010: 34123061 62630021 43658730 64656600 |4.0abc.!Ce.0def.|
32 ## ^- descriptor (1-byte)
33 ## ^-------- name "abc\0"
34 ## ^-------- offset (4-byte)
35 ## ^- descriptor (1-byte)
36 ## ^------- name "def\0"
51 - DieOffset: 0x12345678
54 - DieOffset: 0x87654321
58 ## Generate and verify a 32-bit big endian .debug_gnu_pubnames section.
60 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o
61 # RUN: llvm-readobj --sections --section-data %t1.be.o | \
62 # RUN: FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE
64 # DWARF32-BE-NEXT: SectionData (
65 # DWARF32-BE-NEXT: 0000: 00001234 00020000 12340000 43211234 |...4.....4..C!.4|
66 ## ^------- unit_length (4-byte)
67 ## ^--- version (2-byte)
68 ## ^-------- debug_info_offset (4-byte)
69 ## ^-------- debug_info_length (4-byte)
70 ## ^--- offset (4-byte)
71 # DWARF32-BE-NEXT: 0010: 56783061 62630087 65432130 64656600 |Vx0abc..eC!0def.|
73 ## ^- descriptor (1-byte)
74 ## ^-------- name "abc\0"
75 ## ^-------- offset (4-byte)
76 ## ^- descriptor (1-byte)
77 ## ^------- name "def\0"
80 ## b) Generate the .debug_gnu_pubnames section from raw section content.
82 # RUN: yaml2obj --docnum=2 %s -o %t2.o
83 # RUN: llvm-readobj --sections --section-data %t2.o | \
84 # RUN: FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT
86 # ARBITRARY-CONTENT: SectionData (
87 # ARBITRARY-CONTENT-NEXT: 0000: 112233
88 # ARBITRARY-CONTENT-NEXT: )
96 - Name: .debug_gnu_pubnames
100 ## c) Generate the .debug_gnu_pubnames section when the "Size" is specified.
102 # RUN: yaml2obj --docnum=3 %s -o %t3.o
103 # RUN: llvm-readobj --sections --section-data %t3.o | \
104 # RUN: FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE
106 # SIZE: SectionData (
107 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
116 - Name: .debug_gnu_pubnames
120 ## d) Test that yaml2obj emits an error message when both the "Size" and the
121 ## "debug_gnu_pubnames" entry are specified at the same time.
123 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR
125 # ERROR: yaml2obj: error: cannot specify section '.debug_gnu_pubnames' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
133 - Name: .debug_gnu_pubnames
144 ## e) Test that yaml2obj emits an error message when both the "Content" and the
145 ## "debug_gnu_pubnames" entry are specified at the same time.
147 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR
155 - Name: .debug_gnu_pubnames
166 ## f) Test that all the properties can be overridden by the section header when
167 ## the "debug_gnu_pubnames" entry doesn't exist.
169 # RUN: yaml2obj --docnum=6 %s -o %t6.o
170 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
172 # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
173 # OVERRIDDEN: [ 1] .debug_gnu_pubnames STRTAB 0000000000002020 000050 00000e 01 A 2 1 2
174 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 00005e 000000 00 0 0 0
182 - Name: .debug_gnu_pubnames
183 Type: SHT_STRTAB ## SHT_PROGBITS by default.
184 Flags: [SHF_ALLOC] ## 0 by default.
185 Link: .sec ## 0 by default.
186 EntSize: 1 ## 0 by default.
187 Info: 1 ## 0 by default.
188 AddressAlign: 2 ## 0 by default.
189 Address: 0x2020 ## 0x00 by default.
190 Offset: 0x50 ## 0x40 for the first section.
191 Size: 0x0e ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
192 - Name: .sec ## Linked by .debug_gnu_pubnames.
195 ## g) Test that all the properties can be overridden by the section header when
196 ## the "debug_gnu_pubnames" entry exists.
198 # RUN: yaml2obj --docnum=7 %s -o %t7.o
199 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
207 - Name: .debug_gnu_pubnames
208 Type: SHT_STRTAB ## SHT_PROGBITS by default.
209 Flags: [SHF_ALLOC] ## 0 by default.
210 Link: .sec ## 0 by default.
211 EntSize: 1 ## 0 by default.
212 Info: 1 ## 0 by default.
213 AddressAlign: 2 ## 1 by default.
214 Address: 0x2020 ## 0x00 by default.
215 Offset: 0x50 ## 0x40 for the first section.
216 - Name: .sec ## Linked by .debug_gnu_pubnames.
226 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
228 # RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY
230 # MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
231 # MISSING-KEY-NEXT: - DieOffset: 0x12345678
232 # MISSING-KEY-NEXT: ^
233 # MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
247 - DieOffset: 0x12345678