340 lines · yaml
1## Test that yaml2obj emits .debug_abbrev section.2 3## a) Generate the .debug_abbrev section from the "DWARF" entry.4 5# RUN: yaml2obj --docnum=1 %s -o %t1.o6# RUN: llvm-readobj --sections --section-data %t1.o | \7# RUN: FileCheck -DSIZE=59 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT8 9# SHDR: Index: 110# SHDR-NEXT: Name: .debug_abbrev (1)11# SHDR-NEXT: Type: SHT_PROGBITS (0x1)12# SHDR-NEXT: Flags [ (0x0)13# SHDR-NEXT: ]14# SHDR-NEXT: Address: 0x015# SHDR-NEXT: Offset: 0x4016# SHDR-NEXT: Size: [[SIZE]]17# SHDR-NEXT: Link: 018# SHDR-NEXT: Info: 019# SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]20# SHDR-NEXT: EntrySize: 021# CONTENT-NEXT: SectionData (22# CONTENT-NEXT: 000: 01110125 0E13050323## ^- abbreviation code ULEB128 ^- DW_FORM_strp ULEB12824## ^- DW_TAG_compile_unit ULEB128 ^- DW_AT_language ULEB12825## ^- DW_CHILDREN_yes 1-byte ^- DW_FORM_data2 ULEB12826## ^- DW_AT_producer ULEB128 ^- DW_AT_name ULEB12827##28## CONTENT: 1A000002 2E011101 |...%............|29## ^- DW_AT_strx ULEB128 ^- DW_TAG_subprogram ULEB12830## ^--- attr terminator ^- DW_CHILDREN_yes 1-byte31## ^- abbreviation code ULEB128 ^- DW_AT_low_pc ULEB12832## ^- DW_FORM_addr ULEB12833##34# CONTENT-NEXT: 0010: 121B0000 0306008135## ^- DW_AT_high_pc ULEB128 ^- abbreviation code ULEB12836## ^- DW_FORM_addrx ULEB128 ^- Tag: value UELB12837## ^--- attr terminator ^- DW_CHILDREN_no 1-byte38## ^- DW_AT_call_pc ULEB128 (0x81)39##40# CONTENT: 01810104 02A04021 |..............@!|41## -- ^- Form: reserved ULEB12842## ^--- Form: invalid ULEB128 (0x81) ^--- Attribute: reserved ULEB128 (0x2020)43## ^- Attribute: reserved ULEB128 ^- DW_FORM_implicit_const ULEB12844##45# CONTENT-NEXT: 0020: CEC2F105 0000000146## ^------- Value SLEB128 (12345678) ^--- attr terminator47## ^- abbrev terminator48## ^- abbreviation code ULEB12849# CONTENT: 1101250E 0000022E |..........%.....|50## ^- DW_TAG_compile_unit ULEB128 ^--- attr terminator51## ^- DW_CHILDREN_yes 1-byte ^- abbreviation code ULEB12852## ^- DW_AT_producer ULEB128 ^- DW_TAG_subprogram ULEB12853## ^- DW_FORM_strp ULEB12854# CONTENT-NEXT: 0030: 01110100 00031100 000000 |...........|55## ^- DW_CHILDREN_yes 1-byte ^--- attr terminator56## ^- DW_AT_low_pc ULEB128 ^- abbrev table terminator57## ^- DW_FORM_addr UELB12858## ^---- attr terminator59## ^- abbrev code ULEB128 (0x03)60## ^- DW_TAG_compile_unit61## ^- DW_CHILDREN_no62# CONTENT-NEXT: )63 64--- !ELF65FileHeader:66 Class: ELFCLASS6467 Data: ELFDATA2LSB68 Type: ET_EXEC69DWARF:70 debug_abbrev:71 - Table:72 - Code: 173 Tag: DW_TAG_compile_unit74 Children: DW_CHILDREN_yes75 Attributes:76 - Attribute: DW_AT_producer77 Form: DW_FORM_strp78 - Attribute: DW_AT_language79 Form: DW_FORM_data280 - Attribute: DW_AT_name81 Form: DW_FORM_strx82 - Code: 283 Tag: DW_TAG_subprogram84 Children: DW_CHILDREN_yes85 Attributes:86 - Attribute: DW_AT_low_pc87 Form: DW_FORM_addr88 - Attribute: DW_AT_high_pc89 Form: DW_FORM_addrx90 - Code: 391 ## Test a reserved tag value.92 Tag: 0x0693 Children: DW_CHILDREN_no94 Attributes:95 ## Test an attribute value that is more than one byte.96 - Attribute: DW_AT_call_pc97 ## Test a form value that is more than one byte.98 Form: 0x8199 ## Test a reserved attribute value.100 - Attribute: 0x04101 ## Test a reserved form value.102 Form: 0x02103 - Attribute: 0x2020104 ## Test one special attribute form DW_FORM_implicit_const,105 ## who is followed by a SLEB128 value.106 Form: DW_FORM_implicit_const107 Value: 12345678108 - Table:109 - Code: 1110 Tag: DW_TAG_compile_unit111 Children: DW_CHILDREN_yes112 Attributes:113 - Attribute: DW_AT_producer114 Form: DW_FORM_strp115 - Code: 2116 Tag: DW_TAG_subprogram117 Children: DW_CHILDREN_yes118 Attributes:119 - Attribute: DW_AT_low_pc120 Form: DW_FORM_addr121 ## Test that if the 'Attributes' field is not specified, yaml2obj emits122 ## a terminating entry, 0 for the attribute, 0 for the form.123 - Tag: DW_TAG_compile_unit124 Children: DW_CHILDREN_no125 126## b) Generate the .debug_abbrev section from raw section content.127 128# RUN: yaml2obj --docnum=2 %s -o %t2.o129# RUN: llvm-readobj --sections --section-data %t2.o | \130# RUN: FileCheck -DADDRALIGN=0 -DSIZE=3 %s --check-prefixes=SHDR,ARBITRARY-CONTENT131 132# ARBITRARY-CONTENT-NEXT: SectionData (133# ARBITRARY-CONTENT-NEXT: 0000: 112233134# ARBITRARY-CONTENT-NEXT: )135 136--- !ELF137FileHeader:138 Class: ELFCLASS64139 Data: ELFDATA2LSB140 Type: ET_EXEC141Sections:142 - Name: .debug_abbrev143 Type: SHT_PROGBITS144 Content: "112233"145 146## c) Generate the .debug_abbrev section when the "Size" is specified.147 148# RUN: yaml2obj --docnum=3 %s -o %t3.o149# RUN: llvm-readobj --sections --section-data %t3.o | \150# RUN: FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE151 152# SIZE-NEXT: SectionData (153# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|154# SIZE-NEXT: )155 156--- !ELF157FileHeader:158 Class: ELFCLASS64159 Data: ELFDATA2LSB160 Type: ET_EXEC161Sections:162 - Name: .debug_abbrev163 Type: SHT_PROGBITS164 Size: 0x10165 166## d) Test that yaml2obj emits an error message when both the "Size" and the167## "debug_abbrev" entry are specified at the same time.168 169# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR170 171# ERROR: yaml2obj: error: cannot specify section '.debug_abbrev' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time172 173--- !ELF174FileHeader:175 Class: ELFCLASS64176 Data: ELFDATA2LSB177 Type: ET_EXEC178Sections:179 - Name: .debug_abbrev180 Type: SHT_PROGBITS181 Size: 0x10182DWARF:183 debug_abbrev:184 - Table:185 - Code: 1186 Tag: DW_TAG_compile_unit187 Children: DW_CHILDREN_no188 189## e) Test that yaml2obj emits an error message when both the "Content" and the190## "debug_abbrev" entry are specified at the same time.191 192# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR193 194--- !ELF195FileHeader:196 Class: ELFCLASS64197 Data: ELFDATA2LSB198 Type: ET_EXEC199Sections:200 - Name: .debug_abbrev201 Type: SHT_PROGBITS202 Content: "00"203DWARF:204 debug_abbrev:205 - Table:206 - Code: 1207 Tag: DW_TAG_compile_unit208 Children: DW_CHILDREN_no209 210## f) Test that all the properties can be overridden by the section header when211## the "debug_abbrev" entry doesn't exist.212 213# RUN: yaml2obj --docnum=6 %s -o %t6.o214# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN215 216# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al217# OVERRIDDEN: [ 1] .debug_abbrev STRTAB 0000000000002020 000050 000006 01 A 2 1 2218# OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000056 000000 00 0 0 0219 220--- !ELF221FileHeader:222 Class: ELFCLASS64223 Data: ELFDATA2LSB224 Type: ET_EXEC225Sections:226 - Name: .debug_abbrev227 Type: SHT_STRTAB ## SHT_PROGBITS by default.228 Flags: [SHF_ALLOC] ## 0 by default.229 Link: .sec ## 0 by default.230 EntSize: 1 ## 0 by default.231 Info: 1 ## 0 by default.232 AddressAlign: 2 ## 0 by default.233 Address: 0x2020 ## 0x00 by default.234 Offset: 0x50 ## 0x40 for the first section.235 Size: 0x06 ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".236 - Name: .sec ## Linked by .debug_abbrev.237 Type: SHT_STRTAB238 239## g) Test that all the properties can be overridden by the section header when240## the "debug_abbrev" entry exists.241 242# RUN: yaml2obj --docnum=7 %s -o %t7.o243# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN244 245--- !ELF246FileHeader:247 Class: ELFCLASS64248 Data: ELFDATA2LSB249 Type: ET_EXEC250Sections:251 - Name: .debug_abbrev252 Type: SHT_STRTAB ## SHT_PROGBITS by default.253 Flags: [SHF_ALLOC] ## 0 by default.254 Link: .sec ## 0 by default.255 EntSize: 1 ## 0 by default.256 Info: 1 ## 0 by default.257 AddressAlign: 2 ## 1 by default.258 Address: 0x2020 ## 0x00 by default.259 Offset: 0x50 ## 0x40 for the first section.260 - Name: .sec ## Linked by .debug_abbrev.261 Type: SHT_STRTAB262DWARF:263 debug_abbrev:264 - Table:265 - Code: 1266 Tag: DW_TAG_compile_unit267 Children: DW_CHILDREN_no268 269## h) Test that yaml2obj automatically generates abbreviation codes for us.270 271# RUN: yaml2obj --docnum=8 %s -o %t8.o272# RUN: llvm-readelf --hex-dump=.debug_abbrev %t8.o | FileCheck %s --check-prefix=CODE273 274# CODE: 0x00000000 01110000 00022e00 0000042e 00000004275## ^- abbreviation code ULEB128276## ^- abbreviation code ULEB128277## ^- abbreviation code (ULEB128) 0x04278## ^- abbreviation code (ULEB128) 0x04279##280# CODE-NEXT: 0x00000010 2e000000 052e0000 00062e00 00000001281## ^- abbreviation code ULEB128282## ^- abbreviation code ULEB128283## ^- abbreviation code ULEB128284# CODE-NEXT: 0x00000020 11000000 022e0000 0000285## ^- abbreviation code ULEB128286 287--- !ELF288FileHeader:289 Class: ELFCLASS64290 Data: ELFDATA2LSB291 Type: ET_EXEC292DWARF:293 debug_abbrev:294 - Table:295 - Tag: DW_TAG_compile_unit296 Children: DW_CHILDREN_no297 - Tag: DW_TAG_subprogram298 Children: DW_CHILDREN_no299 - Code: 4300 Tag: DW_TAG_subprogram301 Children: DW_CHILDREN_no302 - Code: 4303 Tag: DW_TAG_subprogram304 Children: DW_CHILDREN_no305 - Tag: DW_TAG_subprogram306 Children: DW_CHILDREN_no307 - Tag: DW_TAG_subprogram308 Children: DW_CHILDREN_no309 - Table:310 ## Test that the abbrev codes in a new table start from 1 by default.311 - Tag: DW_TAG_compile_unit312 Children: DW_CHILDREN_no313 - Tag: DW_TAG_subprogram314 Children: DW_CHILDREN_no315 316## i) Test that yaml2obj emits an error message when there are non-empty compilation units317## and multiple abbrev tables are assigned the same ID.318 319## RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=ID-COLLISION320 321# ID-COLLISION: yaml2obj: error: the ID (1) of abbrev table with index 1 has been used by abbrev table with index 0322 323--- !ELF324FileHeader:325 Class: ELFCLASS64326 Data: ELFDATA2LSB327 Type: ET_EXEC328 Machine: EM_X86_64329DWARF:330 debug_abbrev:331 - ID: 1332 - ID: 1333 debug_info:334 - Version: 4335 AbbrOffset: 0x00336 Entries:337 - AbbrCode: 1338 Values:339 - Value: 0x1234340