1077 lines · yaml
1## Test that yaml2obj emits .debug_info section.2 3## a) Generate the .debug_info section from the "DWARF" entry.4 5## Generate and verify a DWARF32 little endian .debug_info (DWARFv5) section.6 7# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o8# RUN: llvm-readobj --sections --section-data %t1.le.o | \9# RUN: FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE-CONTENT10 11# SHDR: Index: [[INDEX]]12# SHDR-NEXT: Name: .debug_info ([[NAME]])13# SHDR-NEXT: Type: SHT_PROGBITS (0x1)14# SHDR-NEXT: Flags [ (0x0)15# SHDR-NEXT: ]16# SHDR-NEXT: Address: 0x017# SHDR-NEXT: Offset: [[OFFSET]]18# SHDR-NEXT: Size: [[SIZE]]19# SHDR-NEXT: Link: 020# SHDR-NEXT: Info: 021# SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]22# SHDR-NEXT: EntrySize: 023# DWARF32-LE-CONTENT-NEXT: SectionData (24# DWARF32-LE-CONTENT-NEXT: 0000: 34120000 05000304 34120000 0178563425## ^------- unit_length (4-byte)26## ^--- version (2-byte)27## ^- unit_type (1-byte) DW_UT_type28## ^- address_size (1-byte)29## ^------- debug_abbrev_offset (4-byte)30## ^- abbreviation code (LEB128) 0x0131## ^----- Form: DW_FORM_addr (4-byte)32# DWARF32-LE-CONTENT-NEXT: 0010: 12020012 34020000 00123434 1278563433## --34## ^--- Form: DW_FORM_block2 size (2-byte)35## ^- ^- Form: DW_FORM_block2 body (2-byte)36## ^-------- Form: DW_FORM_block4 size (4-byte)37## ^-^- Form: DW_FORM_block4 body (2-byte)38## ^---- Form: DW_FORM_data2 (2-byte)39## ^----- Form: DW_FORM_data4 (4-byte)40# DWARF32-LE-CONTENT-NEXT: 0020: 12F0DEBC 9A785634 12616263 6400021241## --42## ^----------------- Form: DW_FORM_data8 (8-byte)43## ^---------- Form: DW_FORM_string "abcd\0"44## ^- Form: DW_FORM_block size (ULEB128)45## ^- Form: DW_FORM_block body (2-byte)46# DWARF32-LE-CONTENT-NEXT: 0030: 34021234 1201B424 78563412 B424785647## ^- Form: DW_FORM_block body48## ^- Form: DW_FORM_block1 size (1-byte)49## ^-^- Form: DW_FORM_block1 body (2-byte)50## ^- Form: DW_FORM_data1 (1-byte)51## ^- Form: DW_FORM_flag (1-byte)52## ^--- Form: DW_FORM_sdata (SLEB128) 0x123453## ^------- Form: DW_FORM_strp (4-byte)54## ^--- Form: DW_FORM_udata (ULEB128) 0x123455## ^--- Form: DW_FORM_ref_addr (4-byte)56# DWARF32-LE-CONTENT-NEXT: 0040: 34121234 12785634 12F0DEBC 9A78563457## ----58## ^- Form: DW_FORM_ref1 (1-byte)59## ^---- Form: DW_FORM_ref2 (2-byte)60## ^-------- Form: DW_FORM_ref4 (4-byte)61## ^-------------- Form: DW_FORM_ref8 (8-byte)62# DWARF32-LE-CONTENT-NEXT: 0050: 12B42408 65666768 00341200 0002123463## --64## ^--- Form: DW_FORM_ref_udata (ULEB128) 0x123465## ^- Form: DW_FORM_indirect (ULEB128) DW_FORM_string66## ^---------- "efgh\0"67## ^-------- Form: DW_FORM_sec_offset (4-byte)68## ^- Form: DW_FORM_exprloc size (ULEB128) 0x0269## ^-^- Form: DW_FORM_exprloc body (2-byte)70# DWARF32-LE-CONTENT-NEXT: 0060: B424B424 78563412 78563412 7856341271## ^--- Form: DW_FORM_strx (ULEB128)72## ^--- Form: DW_FORM_addrx (ULEB128)73## ^------- Form: DW_FORM_ref_sup4 (4-byte)74## ^------- Form: DW_FORM_strp_sup (4-byte)75## ^------- Form: DW_FORM_line_strp (4-byte)76# DWARF32-LE-CONTENT-NEXT: 0070: F0DEBC9A 78563412 B424B424 F0DEBC9A77## ^---------------- Form: DW_FORM_ref_sig8 (8-byte)78## ^--- Form: DW_FORM_loclistx (ULEB128)79## ^--- Form: DW_FORM_rnglistx (ULEB128)80## ^------- Form: DW_FORM_ref_sup8 (8-byte)81# DWARF32-LE-CONTENT-NEXT: 0080: 78563412 12341278 56341212 3412785682## --------83## ^- Form: DW_FORM_strx1 (1-byte)84## ^--- Form: DW_FORM_strx2 (2-byte)85## ^-------- Form: DW_FORM_strx4 (4-byte)86## ^- Form: DW_FORM_addrx1 (1-byte)87## ^--- Form: DW_FORM_addrx2 (1-byte)88## ^--- Form: DW_FORM_addrx4 (4-byte)89# DWARF32-LE-CONTENT-NEXT: 0090: 34123412 00000500 01043412 0000007890## ----91## ^-------- unit_length (4-byte)92## ^--- version (2-byte)93## ^- unit_type (1-byte)94## ^- address_size (1-byte)95## ^-------- debug_abbrev_offset (4-byte)96## ^- abbrev code (ULEB128) 0x0097## ^- unit_length (4-byte)98# DWARF32-LE-CONTENT-NEXT: 00A0: 56000004 00785600 00040178 5634120299## ------100## ^---- version (2-byte)101## ^-------- debug_abbrev_offset (4-byte)102## ^- address_size (1-byte)103## ^- abbrev code (ULEB128) 0x01104## ^-------- Form: DW_FORM_addr105## ^- Form: DW_FORM_block2 size (2-byte)106# DWARF32-LE-CONTENT-NEXT: 00B0: 001234107## --108## ^-^- Form: DW_FORM_block2 body (2-byte)109# DWARF32-LE-CONTENT-NEXT: )110 111--- !ELF112FileHeader:113 Class: ELFCLASS64114 Data: [[ENDIAN]]115 Type: ET_EXEC116DWARF:117 debug_abbrev:118 - Table:119 - Code: 1120 Tag: DW_TAG_compile_unit121 Children: DW_CHILDREN_no122 Attributes:123 - Attribute: 0x01124 Form: DW_FORM_addr ## 0x01125 - Attribute: 0x01126 Form: DW_FORM_block2 ## 0x03127 - Attribute: 0x01128 Form: DW_FORM_block4 ## 0x04129 - Attribute: 0x01130 Form: DW_FORM_data2 ## 0x05131 - Attribute: 0x01132 Form: DW_FORM_data4 ## 0x06133 - Attribute: 0x01134 Form: DW_FORM_data8 ## 0x07135 - Attribute: 0x01136 Form: DW_FORM_string ## 0x08137 - Attribute: 0x01138 Form: DW_FORM_block ## 0x09139 - Attribute: 0x01140 Form: DW_FORM_block1 ## 0x0a141 - Attribute: 0x01142 Form: DW_FORM_data1 ## 0x0b143 - Attribute: 0x01144 Form: DW_FORM_flag ## 0x0c145 - Attribute: 0x01146 Form: DW_FORM_sdata ## 0x0d147 - Attribute: 0x01148 Form: DW_FORM_strp ## 0x0e149 - Attribute: 0x01150 Form: DW_FORM_udata ## 0x0f151 - Attribute: 0x01152 Form: DW_FORM_ref_addr ## 0x10153 - Attribute: 0x01154 Form: DW_FORM_ref1 ## 0x11155 - Attribute: 0x01156 Form: DW_FORM_ref2 ## 0x12157 - Attribute: 0x01158 Form: DW_FORM_ref4 ## 0x13159 - Attribute: 0x01160 Form: DW_FORM_ref8 ## 0x14161 - Attribute: 0x01162 Form: DW_FORM_ref_udata ## 0x15163 - Attribute: 0x01164 Form: DW_FORM_indirect ## 0x16165 - Attribute: 0x01166 Form: DW_FORM_sec_offset ## 0x17167 - Attribute: 0x01168 Form: DW_FORM_exprloc ## 0x18169 - Attribute: 0x01170 Form: DW_FORM_strx ## 0x1a171 - Attribute: 0x01172 Form: DW_FORM_addrx ## 0x1b173 - Attribute: 0x01174 Form: DW_FORM_ref_sup4 ## 0x1c175 - Attribute: 0x01176 Form: DW_FORM_strp_sup ## 0x1d177 - Attribute: 0x01178 Form: DW_FORM_data16 ## 0x1e179 - Attribute: 0x01180 Form: DW_FORM_line_strp ## 0x1f181 - Attribute: 0x01182 Form: DW_FORM_ref_sig8 ## 0x20183 - Attribute: 0x01184 Form: DW_FORM_implicit_const ## 0x21185 Value: 0x01186 - Attribute: 0x01187 Form: DW_FORM_loclistx ## 0x22188 - Attribute: 0x01189 Form: DW_FORM_rnglistx ## 0x23190 - Attribute: 0x01191 Form: DW_FORM_ref_sup8 ## 0x24192 - Attribute: 0x01193 Form: DW_FORM_strx1 ## 0x25194 - Attribute: 0x01195 Form: DW_FORM_strx2 ## 0x26196 - Attribute: 0x01197 Form: DW_FORM_strx3 ## 0x27198 - Attribute: 0x01199 Form: DW_FORM_strx4 ## 0x28200 - Attribute: 0x01201 Form: DW_FORM_addrx1 ## 0x29202 - Attribute: 0x01203 Form: DW_FORM_addrx2 ## 0x2a204 - Attribute: 0x01205 Form: DW_FORM_addrx3 ## 0x2b206 - Attribute: 0x01207 Form: DW_FORM_addrx4 ## 0x2c208 debug_info:209 - Length: 0x1234210 Version: 5211 UnitType: DW_UT_partial212 AbbrOffset: 0x1234213 AddrSize: 4214 Entries:215 - AbbrCode: 1216 Values:217 - Value: 0x12345678 ## DW_FORM_addr218 - BlockData: ## DW_FORM_block2219 - 0x12220 - 0x34221 - BlockData: ## DW_FORM_block4222 - 0x12223 - 0x34224 - Value: 0x1234 ## DW_FORM_data2225 - Value: 0x12345678 ## DW_FORM_data4226 - Value: 0x123456789abcdef0 ## DW_FORM_data8227 - CStr: abcd ## DW_FORM_string228 - BlockData: ## DW_FORM_block229 - 0x12230 - 0x34231 - BlockData: ## DW_FORM_block1232 - 0x12233 - 0x34234 - Value: 0x12 ## DW_FORM_data1235 - Value: 0x01 ## DW_FORM_flag236 - Value: 0x1234 ## DW_FORM_sdata237 - Value: 0x12345678 ## DW_FORM_strp238 - Value: 0x1234 ## DW_FORM_udata239 - Value: 0x12345678 ## DW_FORM_ref_addr240 - Value: 0x12 ## DW_FORM_ref1241 - Value: 0x1234 ## DW_FORM_ref2242 - Value: 0x12345678 ## DW_FORM_ref4243 - Value: 0x123456789abcdef0 ## DW_FORM_ref8244 - Value: 0x1234 ## DW_FORM_ref_udata245 - Value: 0x08 ## DW_FORM_indirect. The following value's form is 0x08, which is DW_FORM_string.246 - CStr: efgh247 - Value: 0x1234 ## DW_FORM_sec_offset248 - BlockData: ## DW_FORM_exprloc249 - 0x12250 - 0x34251 - Value: 0x1234 ## DW_FORM_strx252 - Value: 0x1234 ## DW_FORM_addrx253 - Value: 0x12345678 ## DW_FORM_ref_sup4254 - Value: 0x12345678 ## DW_FORM_strp_sup255 - Value: 0x1234 ## DW_FORM_data16 (unimplemented)256 - Value: 0x12345678 ## DW_FORM_line_strp257 - Value: 0x123456789abcdef0 ## DW_FORM_ref_sig8258 - Value: 0x1234 ## DW_FORM_implicit_const (unimplemented)259 - Value: 0x1234 ## DW_FORM_loclistx260 - Value: 0x1234 ## DW_FORM_rnglistx261 - Value: 0x123456789abcdef0 ## DW_FORM_ref_sup8262 - Value: 0x12 ## DW_FORM_strx1263 - Value: 0x1234 ## DW_FORM_strx2264 - Value: 0x123456 ## DW_FORM_strx3 (unimplemented)265 - Value: 0x12345678 ## DW_FORM_strx4266 - Value: 0x12 ## DW_FORM_addrx1267 - Value: 0x1234 ## DW_FORM_addrx2268 - Value: 0x123456 ## DW_FORM_addrx3 (unimplemented)269 - Value: 0x12345678 ## DW_FORM_addrx4270 - Length: 0x1234271 Version: 5272 ## Test another unit type.273 UnitType: DW_UT_compile274 AbbrOffset: 0x1234275 AddrSize: 4276 Entries:277 - AbbrCode: 0278 Values: []279 - Length: 0x5678280 ## Test DWARFv4281 Version: 4282 AbbrevTableID: 0283 AbbrOffset: 0x5678284 AddrSize: 4285 Entries:286 - AbbrCode: 1287 Values:288 - Value: 0x12345678 ## DW_FORM_addr289 - BlockData: ## DW_FORM_block2290 - 0x12291 - 0x34292 293## Generate and verify a DWARF32 big endian .debug_info (DWARFv4) section.294 295# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o296# RUN: llvm-readobj --sections --section-data %t1.be.o | \297# RUN: FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE-CONTENT298 299# DWARF32-BE-CONTENT-NEXT: SectionData (300# DWARF32-BE-CONTENT-NEXT: 0000: 00001234 00050304 00001234 01123456301## ^------- unit_length (4-byte)302## ^--- version (2-byte)303## ^- unit_type (1-byte) DW_UT_type304## ^- address_size (1-byte)305## ^------- debug_abbrev_offset (4-byte)306## ^- abbreviation code (LEB128) 0x01307## ^----- Form: DW_FORM_addr (4-byte)308# DWARF32-BE-CONTENT-NEXT: 0010: 78000212 34000000 02123412 34123456309## --310## ^--- Form: DW_FORM_block2 size (2-byte)311## ^- ^- Form: DW_FORM_block2 body (2-byte)312## ^-------- Form: DW_FORM_block4 size (4-byte)313## ^-^- Form: DW_FORM_block4 body (2-byte)314## ^---- Form: DW_FORM_data2 (2-byte)315## ^----- Form: DW_FORM_data4 (4-byte)316# DWARF32-BE-CONTENT-NEXT: 0020: 78123456 789ABCDE F0616263 64000212317## --318## ^----------------- Form: DW_FORM_data8 (8-byte)319## ^---------- Form: DW_FORM_string "abcd\0"320## ^- Form: DW_FORM_block size (ULEB128)321## ^- Form: DW_FORM_block body (2-byte)322# DWARF32-BE-CONTENT-NEXT: 0030: 34021234 1201B424 12345678 B4241234323## ^- Form: DW_FORM_block body324## ^- Form: DW_FORM_block1 size (1-byte)325## ^-^- Form: DW_FORM_block1 body (2-byte)326## ^- Form: DW_FORM_data1 (1-byte)327## ^- Form: DW_FORM_flag (1-byte)328## ^--- Form: DW_FORM_sdata (SLEB128) 0x1234329## ^------- Form: DW_FORM_strp (4-byte)330## ^--- Form: DW_FORM_udata (ULEB128) 0x1234331## ^--- Form: DW_FORM_ref_addr (4-byte)332# DWARF32-BE-CONTENT-NEXT: 0040: 56781212 34123456 78123456 789ABCDE333## ----334## ^- Form: DW_FORM_ref1 (1-byte)335## ^---- Form: DW_FORM_ref2 (2-byte)336## ^-------- Form: DW_FORM_ref4 (4-byte)337## ^-------------- Form: DW_FORM_ref8 (8-byte)338# DWARF32-BE-CONTENT-NEXT: 0050: F0B42408 65666768 00000012 34021234339## --340## ^--- Form: DW_FORM_ref_udata (ULEB128) 0x1234341## ^- Form: DW_FORM_indirect (ULEB128) DW_FORM_string342## ^---------- "efgh\0"343## ^-------- Form: DW_FORM_sec_offset (4-byte)344## ^- Form: DW_FORM_exprloc size (ULEB128) 0x02345## ^-^- Form: DW_FORM_exprloc body (2-byte)346# DWARF32-BE-CONTENT-NEXT: 0060: B424B424 12345678 12345678 12345678347## ^--- Form: DW_FORM_strx (ULEB128)348## ^--- Form: DW_FORM_addrx (ULEB128)349## ^------- Form: DW_FORM_ref_sup4 (4-byte)350## ^------- Form: DW_FORM_strp_sup (4-byte)351## ^------- Form: DW_FORM_line_strp (4-byte)352# DWARF32-BE-CONTENT-NEXT: 0070: 12345678 9ABCDEF0 B424B424 12345678353## ^---------------- Form: DW_FORM_ref_sig8 (8-byte)354## ^--- Form: DW_FORM_loclistx (ULEB128)355## ^--- Form: DW_FORM_rnglistx (ULEB128)356## ^------- Form: DW_FORM_ref_sup8 (8-byte)357# DWARF32-BE-CONTENT-NEXT: 0080: 9ABCDEF0 12123412 34567812 12341234358## --------359## ^- Form: DW_FORM_strx1 (1-byte)360## ^--- Form: DW_FORM_strx2 (2-byte)361## ^-------- Form: DW_FORM_strx4 (4-byte)362## ^- Form: DW_FORM_addrx1 (1-byte)363## ^--- Form: DW_FORM_addrx2 (1-byte)364## ^--- Form: DW_FORM_addrx4 (4-byte)365# DWARF32-BE-CONTENT-NEXT: 0090: 56780000 12340005 01040000 12340000366## ----367## ^-------- unit_length (4-byte)368## ^--- version (2-byte)369## ^- unit_type (1-byte)370## ^- address_size (1-byte)371## ^-------- debug_abbrev_offset (4-byte)372## ^- abbrev code (ULEB128) 0x00373## ^- unit_length (4-byte)374# DWARF32-BE-CONTENT-NEXT: 00A0: 00567800 04000056 78040112 34567800375## ------376## ^---- version (2-byte)377## ^-------- debug_abbrev_offset (4-byte)378## ^- address_size (1-byte)379## ^- abbrev code (ULEB128) 0x01380## ^-------- Form: DW_FORM_addr381## ^- Form: DW_FORM_block2 size (2-byte)382# DWARF32-BE-CONTENT-NEXT: 00B0: 021234383## --384## ^-^- Form: DW_FORM_block2 body (2-byte)385# DWARF32-BE-CONTENT-NEXT: )386 387## b) Generate the .debug_info section from raw section content.388 389# RUN: yaml2obj --docnum=2 %s -o %t2.o390# RUN: llvm-readobj --sections --section-data %t2.o | \391# RUN: FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=3 -DADDRALIGN=0 %s --check-prefixes=SHDR,ARBITRARY-CONTENT392 393# ARBITRARY-CONTENT-NEXT: SectionData (394# ARBITRARY-CONTENT-NEXT: 0000: 112233395# ARBITRARY-CONTENT-NEXT: )396 397--- !ELF398FileHeader:399 Class: ELFCLASS64400 Data: ELFDATA2LSB401 Type: ET_EXEC402Sections:403 - Name: .debug_info404 Type: SHT_PROGBITS405 Content: "112233"406 407## c) Generate the .debug_info section when the "Size" is specified.408 409# RUN: yaml2obj --docnum=3 %s -o %t3.o410# RUN: llvm-readobj --sections --section-data %t3.o | \411# RUN: FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE412 413# SIZE-NEXT: SectionData (414# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000415# SIZE-NEXT: )416 417--- !ELF418FileHeader:419 Class: ELFCLASS64420 Data: ELFDATA2LSB421 Type: ET_EXEC422Sections:423 - Name: .debug_info424 Type: SHT_PROGBITS425 Size: 0x10426 427## d) Test that yaml2obj emits an error message when both the "Size" and the428## "debug_info" entry are specified at the same time.429 430# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT431 432# AMBIGUOUS-CONTENT: yaml2obj: error: cannot specify section '.debug_info' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time433 434--- !ELF435FileHeader:436 Class: ELFCLASS64437 Data: ELFDATA2LSB438 Type: ET_EXEC439Sections:440 - Name: .debug_info441 Type: SHT_PROGBITS442 Size: 0x10443DWARF:444 debug_abbrev:445 - Table:446 - Code: 1447 Tag: DW_TAG_compile_unit448 Children: DW_CHILDREN_no449 debug_info:450 - Length: 0x1234451 Version: 5452 UnitType: DW_UT_compile453 AbbrOffset: 0x1234454 Entries: []455 456## e) Test that yaml2obj emits an error message when both the "Content" and the457## "debug_info" entry are specified at the same time.458 459# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT460 461--- !ELF462FileHeader:463 Class: ELFCLASS64464 Data: ELFDATA2LSB465 Type: ET_EXEC466Sections:467 - Name: .debug_info468 Type: SHT_PROGBITS469 Content: "00"470DWARF:471 debug_abbrev:472 - Table:473 - Code: 1474 Tag: DW_TAG_compile_unit475 Children: DW_CHILDREN_no476 debug_info:477 - Length: 0x1234478 Version: 5479 UnitType: DW_UT_compile480 AbbrOffset: 0x1234481 Entries: []482 483## f) Test that all the properties can be overridden by the section header when484## the "debug_info" entry doesn't exist.485 486# RUN: yaml2obj --docnum=6 %s -o %t6.o487# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN488 489# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al490# OVERRIDDEN: [ 1] .debug_info STRTAB 0000000000002020 000050 00000d 01 A 2 1 2491# OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 00005d 000000 00 0 0 0492 493--- !ELF494FileHeader:495 Class: ELFCLASS64496 Data: ELFDATA2LSB497 Type: ET_EXEC498Sections:499 - Name: .debug_info500 Type: SHT_STRTAB ## SHT_PROGBITS by default.501 Flags: [SHF_ALLOC] ## 0 by default.502 Link: .sec ## 0 by default.503 EntSize: 1 ## 0 by default.504 Info: 1 ## 0 by default.505 AddressAlign: 2 ## 0 by default.506 Address: 0x2020 ## 0x00 by default.507 Offset: 0x50 ## 0x40 for the first section.508 Size: 0x0d ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".509 - Name: .sec ## Linked by .debug_info.510 Type: SHT_STRTAB511 512## g) Test that all the properties can be overridden by the section header when513## the "debug_info" entry exists.514 515# RUN: yaml2obj --docnum=7 %s -o %t7.o516# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN517 518--- !ELF519FileHeader:520 Class: ELFCLASS64521 Data: ELFDATA2LSB522 Type: ET_EXEC523Sections:524 - Name: .debug_info525 Type: SHT_STRTAB ## SHT_PROGBITS by default.526 Flags: [SHF_ALLOC] ## 0 by default.527 Link: .sec ## 0 by default.528 EntSize: 1 ## 0 by default.529 Info: 1 ## 0 by default.530 AddressAlign: 2 ## 0 by default.531 Address: 0x2020 ## 0x00 by default.532 Offset: 0x50 ## 0x40 for the first section.533 - Name: .sec ## Linked by .debug_info.534 Type: SHT_STRTAB535DWARF:536 debug_abbrev:537 - Table:538 - Code: 1539 Tag: DW_TAG_compile_unit540 Children: DW_CHILDREN_no541 debug_info:542 - Length: 0x1234543 Version: 5544 UnitType: DW_UT_compile545 AbbrOffset: 0x1234546 Entries:547 - AbbrCode: 0548 Values: []549 550## h) Test that yaml2obj doesn't crash when the 'Entries' of a compilation unit is empty.551 552# RUN: yaml2obj --docnum=8 %s -o %t8.o553# RUN: llvm-readelf --hex-dump=.debug_info %t8.o | \554# RUN: FileCheck %s --check-prefix=EMPTY-ENTRIES --match-full-lines555 556# EMPTY-ENTRIES: Hex dump of section '.debug_info':557# EMPTY-ENTRIES-NEXT: 0x00000000 34120000 05000104 34120000 4.......4...558# EMPTY-ENTRIES-EMPTY:559## ^- 'Entries' is empty560 561--- !ELF562FileHeader:563 Class: ELFCLASS32564 Data: ELFDATA2LSB565 Type: ET_EXEC566DWARF:567 debug_info:568 - Length: 0x1234569 Version: 5570 UnitType: DW_UT_compile571 AbbrOffset: 0x1234572 Entries: []573 574## h) Test that yaml2obj emits values in the DIE according to the abbreviation whose575## index is equal to the value in 'AbbrevCode'.576 577# RUN: yaml2obj --docnum=9 %s -o %t9.o578# RUN: llvm-readelf --hex-dump=.debug_info %t9.o | \579# RUN: FileCheck %s --check-prefix=FORM --match-full-lines580 581# FORM: Hex dump of section '.debug_info':582# FORM-NEXT: 0x00000000 34120000 05000104 34120000 02341221 4.......4....4.!583## ^------- unit_length (4-byte)584## ^- abbreviation code (ULEB128)585## ^--- Form: DW_FORM_data2 (2-byte)586## ^- Form: DW_FORM_data4 (4-byte)587# FORM-NEXT: 0x00000010 43658701 21436587 341200 Ce..!Ce.4..588## ------589## ^- abbreviation code (ULEB128)590## ^------- Form: DW_FORM_data4 (4-byte)591## ^--- Form: DW_FORM_data2 (2-byte)592## ^- abbreviation code (ULEB128)593# FORM-EMPTY:594 595--- !ELF596FileHeader:597 Class: ELFCLASS32598 Data: ELFDATA2LSB599 Type: ET_EXEC600DWARF:601 debug_abbrev:602 - Table:603 - Tag: DW_TAG_compile_unit604 Children: DW_CHILDREN_yes605 Attributes:606 - Attribute: DW_AT_low_pc607 Form: DW_FORM_data4608 - Attribute: DW_AT_high_pc609 Form: DW_FORM_data2610 - Tag: DW_TAG_subprogram611 Children: DW_CHILDREN_no612 Attributes:613 - Attribute: DW_AT_low_pc614 Form: DW_FORM_data2615 - Attribute: DW_AT_high_pc616 Form: DW_FORM_data4617 debug_info:618 - Length: 0x1234619 Version: 5620 UnitType: DW_UT_compile621 AbbrOffset: 0x1234622 Entries:623 ## Test that yaml2obj emits values when the abbrev code is specified.624 - AbbrCode: 2625 Values:626 - Value: 0x1234627 - Value: 0x87654321628 ## Test that yaml2obj emits values when the abbrev code is specified to629 ## be lower than the first abbrev.630 - AbbrCode: 1631 Values:632 - Value: 0x87654321633 - Value: 0x1234634 ## Test that yaml2obj ignores the contents of entries with abbrev code 0.635 - AbbrCode: 0636 Values:637 - Value: 0x1234638 639## i) Test that yaml2obj reports an error when 'debug_info' has values in its640## entries but 'debug_abbrev' doesn't have enough attributes for them.641 642# RUN: not yaml2obj --docnum=10 %s -o %t10.o 2>&1 | \643# RUN: FileCheck %s --check-prefixes=ERROR644 645# ERROR: yaml2obj: error: abbrev code must be less than or equal to the number of entries in abbreviation table646 647--- !ELF648FileHeader:649 Class: ELFCLASS64650 Data: ELFDATA2LSB651 Type: ET_EXEC652DWARF:653 debug_abbrev:654 - Table: []655 debug_info:656 - Length: 0x1234657 Version: 5658 UnitType: DW_UT_compile659 AbbrOffset: 0x1234660 Entries:661 - AbbrCode: 1662 Values:663 - Value: 0x1234664 665## j) Test that yaml2obj emits the correct DWARFv5 unit headers.666 667# RUN: yaml2obj --docnum=11 %s -o %t11.o668# RUN: llvm-readelf --hex-dump=.debug_info %t11.o | \669# RUN: FileCheck %s --check-prefix=DWARFV5-HEADER670 671# DWARFV5-HEADER: Hex dump of section '.debug_info':672# DWARFV5-HEADER-NEXT: 0x00000000 ffffffff 0d000000 00000000 05000108 ................673## ^------------------------- unit_length (12-byte)674## ^--- version (2-byte)675## ^- unit_type (1-byte)676## ^- address_size (1-byte)677# DWARFV5-HEADER-NEXT: 0x00000010 34120000 00000000 00150000 00050002 4...............678## ^---------------- debug_abbrev_offset (8-byte)679## ^- End of children (1-byte)680## ^-------- unit_length (4-byte)681## ^--- version (2-byte)682## ^- unit_type (1-byte)683# DWARFV5-HEADER-NEXT: 0x00000020 08341200 000df0ad baefbead de180000 .4..............684## ^- address_size (1-byte)685## ^-------- debug_abbrev_offset (4-byte)686## ^----------------- type_signature (8-byte)687## \/ ^----- type_offset (4-byte)688# DWARFV5-HEADER-NEXT: 0x00000030 0000ffff ffff1d00 00000000 00000500 ................689## ^- End of children (1-byte)690## ^-------------------------- unit_length (12-byte)691## ^--- version (2-byte)692# DWARFV5-HEADER-NEXT: 0x00000040 02083412 00000000 00000df0 adbaefbe ..4.............693## ^- unit_type (1-byte)694## ^- address_size (1-byte)695## ^----------------- debug_abbrev_offset (8-byte)696## \/-- ^------------ type_signature (8-byte)697# DWARFV5-HEADER-NEXT: 0x00000050 adde2800 00000000 00000011 00000005 ..(.............698## ^----------------- type_offset (8-byte)699## ^- End of children (1-byte)700## ^-------- unit_length (4-byte)701## \/ ^- version (2-byte)702# DWARFV5-HEADER-NEXT: 0x00000060 00040834 1200000d f0adbaef beadde00 ...4............703## ^- unit_type (1-byte)704## ^- address_size (1-byte)705## ^-------- debug_abbrev_offset (4-byte)706## ^----------------- type_signature (8-byte)707## ^- End of children (1-byte)708 709 710 711--- !ELF712FileHeader:713 Class: ELFCLASS64714 Data: ELFDATA2LSB715 Type: ET_EXEC716DWARF:717 debug_info:718 - Format: DWARF64719 Version: 5720 UnitType: DW_UT_compile721 AbbrOffset: 0x1234722 Entries:723 - AbbrCode: 0724 - Version: 5725 UnitType: DW_UT_type726 AbbrOffset: 0x1234727 TypeSignature: 0xdeadbeefbaadf00d728 TypeOffset: 24729 Entries:730 - AbbrCode: 0731 - Format: DWARF64732 Version: 5733 UnitType: DW_UT_type734 AbbrOffset: 0x1234735 TypeSignature: 0xdeadbeefbaadf00d736 TypeOffset: 40737 Entries:738 - AbbrCode: 0739 - Version: 5740 UnitType: DW_UT_skeleton741 AbbrOffset: 0x1234742 DwoID: 0xdeadbeefbaadf00d743 Entries:744 - AbbrCode: 0745 746## DWARFv4 unit header.747 748# RUN: yaml2obj --docnum=12 %s -o %t12.o749# RUN: llvm-readelf --hex-dump=.debug_info %t12.o | \750# RUN: FileCheck %s --check-prefix=DWARFV4-HEADER751 752# DWARFV4-HEADER: Hex dump of section '.debug_info':753# DWARFV4-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 04003412 ..............4.754## ^------------------------- unit_length (12-byte)755## ^--- version (2-byte)756## ^--- debug_abbrev_offset (8-byte)757# DWARFV4-HEADER-NEXT: 0x00000010 00000000 000008 .......758## -------------759## ^- address_size (1-byte)760 761--- !ELF762FileHeader:763 Class: ELFCLASS64764 Data: ELFDATA2LSB765 Type: ET_EXEC766DWARF:767 debug_info:768 - Format: DWARF64769 Length: 0x0c770 Version: 4771 AbbrOffset: 0x1234772 Entries: []773 774## k) Test that yaml2obj is able to emit a correct length for compilation units.775 776# RUN: yaml2obj --docnum=13 %s -o %t13.o777# RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \778# RUN: FileCheck %s --check-prefix=INFER-LENGTH779 780# INFER-LENGTH: Hex dump of section '.debug_info':781# INFER-LENGTH-NEXT: 0x00000000 37000000 04000000 00000801 00000000 7...............782## ^------- unit_length (0x37)783## ^--- version (2-byte)784## ^-------- debug_abbrev_offset (4-byte)785## ^- address_size (1-byte)786## ^- abbrev code (ULEB128) 0x01787## ^------- Form: DW_FORM_strp (4-byte)788# INFER-LENGTH-NEXT: 0x00000010 0c001600 00000000 00001e00 00002011 .............. .789## ^--- Form: DW_FORM_data2 (2-byte)790## ^-------- Form: DW_FORM_strp (4-byte)791## ^-------- Form: DW_FORM_sec_offset (4-byte)792## ^-------- Form: DW_FORM_strp (4-byte)793## ^--- Form: DW_FORM_addr (8-byte)794# INFER-LENGTH-NEXT: 0x00000020 00000000 00003300 00000220 11000000 ......3.... ....795## -------------796## ^-------- Form: DW_FORM_data4 (4-byte)797## ^- abbrev code (ULEB128) 0x02798## ^---------- Form: DW_FORM_addr (8-byte)799# INFER-LENGTH-NEXT: 0x00000030 00000006 00000038 000000 .......8...800## ------801## ^-------- Form: DW_FORM_data4 (4-byte)802## ^-------- Form: DW_FORM_strp (4-byte)803 804## The handwritten DIEs should look like:805 806## 0x0000000b: DW_TAG_compile_unit [1] *807## DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = "clang version 10.0.0 ")808## DW_AT_language [DW_FORM_data2] (DW_LANG_C99)809## DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000016] = "hello.c")810## DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)811## DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000001e] = "/home/v/x/llvm/playground")812## DW_AT_low_pc [DW_FORM_addr] (0x0000000000001120)813## DW_AT_high_pc [DW_FORM_data4] (0x00000033)814## 815## 0x0000002a: DW_TAG_subprogram [2] 816## DW_AT_low_pc [DW_FORM_addr] (0x0000000000001120)817## DW_AT_high_pc [DW_FORM_data4] (0x00000006)818## DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000038] = "main")819 820--- !ELF821FileHeader:822 Class: ELFCLASS64823 Data: ELFDATA2LSB824 Type: ET_EXEC825DWARF:826 debug_str:827 - "clang version 10.0.0 "828 - "hello.c"829 - "/home/v/x/llvm/playground"830 - "main"831 debug_abbrev:832 - Table:833 - Code: 1834 Tag: DW_TAG_compile_unit835 Children: DW_CHILDREN_yes836 Attributes:837 - Attribute: DW_AT_producer838 Form: DW_FORM_strp839 - Attribute: DW_AT_language840 Form: DW_FORM_data2841 - Attribute: DW_AT_name842 Form: DW_FORM_strp843 - Attribute: DW_AT_stmt_list844 Form: DW_FORM_sec_offset845 - Attribute: DW_AT_comp_dir846 Form: DW_FORM_strp847 - Attribute: DW_AT_low_pc848 Form: DW_FORM_addr849 - Attribute: DW_AT_high_pc850 Form: DW_FORM_data4851 - Code: 2852 Tag: DW_TAG_subprogram853 Children: DW_CHILDREN_no854 Attributes:855 - Attribute: DW_AT_low_pc856 Form: DW_FORM_addr857 - Attribute: DW_AT_high_pc858 Form: DW_FORM_data4859 - Attribute: DW_AT_name860 Form: DW_FORM_strp861 debug_info:862 - Version: 4863 AbbrOffset: 0x00864 Entries:865 - AbbrCode: 1866 Values:867 - Value: 0x00 ## DW_AT_producer [DW_FORM_strp]868 - Value: 0x0c ## DW_LANG_C99, DW_AT_language [DW_FORM_data2]869 - Value: 0x16 ## DW_AT_name [DW_FORM_strp]870 - Value: 0x00 ## DW_AT_stmt_list [DW_FORM_sec_offset]871 - Value: 0x1e ## DW_AT_comp_dir [DW_FORM_strp]872 - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]873 - Value: 0x33 ## DW_AT_high_pc [DW_FORM_data4]874 - AbbrCode: 2875 Values:876 - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]877 - Value: 0x06 ## DW_AT_high_pc [DW_FORM_data4]878 - Value: 0x38 ## DW_AT_name [DW_FORM_strp]879 880## l) Test that if we don't specify the 'Values' key for an entry, yaml2obj will only emit the abbrev_code.881 882# RUN: yaml2obj --docnum=14 %s -o %t14.o883# RUN: llvm-readelf --hex-dump=.debug_info %t14.o | \884# RUN: FileCheck %s --check-prefix=NO-VALUES885 886# NO-VALUES: Hex dump of section '.debug_info':887# NO-VALUES-NEXT: 0x00000000 0a000000 04000000 00000801 0002 ..............888## ^------- unit_length (4-byte)889## ^--- version (2-byte)890## ^-------- debug_abbrev_offset (4-byte)891## ^- address_size (1-byte)892## ^- abbrev_code (ULEB128) 0x01893## ^- abbrev_code (ULEB128) 0x00894## ^- abbrev_code (ULEB128) 0x02895 896--- !ELF897FileHeader:898 Class: ELFCLASS64899 Data: ELFDATA2LSB900 Type: ET_EXEC901DWARF:902 debug_info:903 - Version: 4904 AbbrOffset: 0x00905 Entries:906 - AbbrCode: 1907 - AbbrCode: 0908 - AbbrCode: 2909 910## m) Test that yaml2obj is able to infer the address size from the object file.911 912# RUN: yaml2obj --docnum=15 -DBITS=64 %s -o %t15.64-bit.o913# RUN: llvm-readelf --hex-dump=.debug_info %t15.64-bit.o | \914# RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=08915 916# ADDRSIZE: Hex dump of section '.debug_info':917# ADDRSIZE-NEXT: 0x00000000 07000000 04000000 0000[[ADDRSIZE]] ...........918 919# RUN: yaml2obj --docnum=15 -DBITS=32 %s -o %t15.32-bit.o920# RUN: llvm-readelf --hex-dump=.debug_info %t15.32-bit.o | \921# RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=04922 923--- !ELF924FileHeader:925 Class: ELFCLASS[[BITS]]926 Data: ELFDATA2LSB927 Type: ET_EXEC928DWARF:929 debug_info:930 - Version: 4931 AbbrOffset: 0x00932 933## n) Test that yaml2obj emits an error message when a compilation unit has values but there is no associated abbrev table.934 935## RUN: not yaml2obj --docnum=16 %s 2>&1 | FileCheck %s --check-prefix=NO-ABBREV936 937# NO-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0938 939--- !ELF940FileHeader:941 Class: ELFCLASS64942 Data: ELFDATA2LSB943 Type: ET_EXEC944 Machine: EM_X86_64945DWARF:946 debug_info:947 - Version: 4948 AbbrOffset: 0x00949 Entries:950 - AbbrCode: 1951 Values:952 - Value: 0x1234953 954## o) Test that yaml2obj is able to generate compilation units according to the955## associated abbrev table that is referenced by the 'AbbrevTableID' and infer956## the value of the debug_abbrev_offset field.957 958# RUN: yaml2obj --docnum=17 %s -o %t17.o959# RUN: llvm-readelf --hex-dump=.debug_info %t17.o | FileCheck %s --check-prefix=MULTI-TABLES960 961# MULTI-TABLES: Hex dump of section '.debug_info':962# MULTI-TABLES-NEXT: 0x00000000 0c000000 04000800 00000801 34120000 ............4...963## ^------- unit_length (4-byte)964## ^--- version (2-byte)965## ^-------- debug_abbrev_offset (4-byte)966## ^- address_size (1-byte)967## ^- abbrev_code (ULEB128) 0x01968## ^------- Form: DW_FORM_data4 (4-byte) 0x1234969# MULTI-TABLES-NEXT: 0x00000010 0c000000 04000800 00000801 21430000 ............!C..970## ^------- unit_length (4-byte)971## ^--- version (2-byte)972## ^-------- debug_abbrev_offset (4-byte)973## ^- address_size (1-byte)974## ^- abbrev_code (ULEB128) 0x01975## ^------- Form: DW_FORM_data4 (4-byte) 0x4321976# MULTI-TABLES-NEXT: 0x00000020 10000000 04000000 00000801 78560000 ............xV..977## ^------- unit_length (4-byte)978## ^--- version (2-byte)979## ^-------- debug_abbrev_offset (4-byte)980## ^- address_size (1-byte)981## ^- abbrev_code (ULEB128) 0x01982## ^------- Form: DW_FORM_addr (8-byte) 0x5678983# MULTI-TABLES-NEXT: 0x00000030 00000000 0b000000 04001000 00000801 ................984## --------985## ^------- unit_length (4-byte)986## ^--- version (2-byte)987## ^-------- debug_abbrev_offset (4-byte)988## ^- address_size (1-byte)989## ^- abbrev_code (ULEB128) 0x01990# MULTI-TABLES-NEXT: 0x00000040 e58e02 ...991## ^----- Form: DW_FORM_udata (ULEB128) 0x8765992 993--- !ELF994FileHeader:995 Class: ELFCLASS64996 Data: ELFDATA2LSB997 Type: ET_EXEC998DWARF:999 debug_abbrev:1000 - Table:1001 - Code: 11002 Tag: DW_TAG_compile_unit1003 Children: DW_CHILDREN_no1004 Attributes:1005 - Attribute: DW_AT_low_pc1006 Form: DW_FORM_addr1007 - ID: 21008 Table:1009 - Code: 11010 Tag: DW_TAG_compile_unit1011 Children: DW_CHILDREN_no1012 Attributes:1013 - Attribute: DW_AT_low_pc1014 Form: DW_FORM_data41015 - ID: 11016 Table:1017 - Code: 11018 Tag: DW_TAG_compile_unit1019 Children: DW_CHILDREN_no1020 Attributes:1021 - Attribute: DW_AT_low_pc1022 Form: DW_FORM_udata1023 debug_info:1024 - Version: 41025 AbbrevTableID: 21026 Entries:1027 - AbbrCode: 11028 Values:1029 - Value: 0x12341030 - Version: 41031 AbbrevTableID: 21032 Entries:1033 - AbbrCode: 11034 Values:1035 - Value: 0x43211036 - Version: 41037 AbbrevTableID: 01038 Entries:1039 - AbbrCode: 11040 Values:1041 - Value: 0x56781042 - Version: 41043 AbbrevTableID: 11044 Entries:1045 - AbbrCode: 11046 Values:1047 - Value: 0x87651048 1049## p) Test that when the debug_abbrev_offset field isn't specified and there is no associated1050## abbrev table, yaml2obj will assign 0 to the debug_abbrev_offset field.1051 1052# RUN: yaml2obj --docnum=18 %s -o %t18.o1053# RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET1054 1055# ZERO-OFFSET: Hex dump of section '.debug_info':1056# ZERO-OFFSET-NEXT: 0x00000000 07000000 04000000 000008 ...........1057## ^------- unit_length (4-byte)1058## ^--- version (2-byte)1059## ^-------- debug_abbrev_offset (4-byte)1060## ^- address_size (1-byte)1061 1062--- !ELF1063FileHeader:1064 Class: ELFCLASS641065 Data: ELFDATA2LSB1066 Type: ET_EXEC1067DWARF:1068 debug_info:1069 - Version: 41070 AbbrevTableID: [[ABBREVID=<none>]]1071 1072## q) Test that when we assign an invalid 'AbbrevTableID' that doesn't point to an abbrev table,1073## yaml2obj will assign 0 to the debug_abbrev_offset field.1074 1075# RUN: yaml2obj --docnum=18 -DABBREVID=2 %s -o %t18.o1076# RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET1077