221 lines · yaml
1## Test that yaml2obj emits .debug_pubnames section.2 3## a) Generate the '.debug_pubnames' section from the 'DWARF' entry.4 5## Generate and verify a 32-bit little endian .debug_pubnames 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 -DSIZE=30 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE10 11# SHDR: Index: 112# SHDR-NEXT: Name: .debug_pubnames (1)13# SHDR-NEXT: Type: SHT_PROGBITS (0x1)14# SHDR-NEXT: Flags [ (0x0)15# SHDR-NEXT: ]16# SHDR-NEXT: Address: 0x017# SHDR-NEXT: Offset: 0x4018# SHDR-NEXT: Size: [[SIZE]]19# SHDR-NEXT: Link: 020# SHDR-NEXT: Info: 021# SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]22# SHDR-NEXT: EntrySize: 023# 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##31# DWARF32-LE-NEXT: 0010: 34126162 63002143 65876465 6600 |4.abc.!Ce.def.|32## ----33## ^-------- name "abc\0"34## ^-------- offset (4-byte)35## ^-------- name "def\0"36# DWARF32-LE-NEXT: )37 38--- !ELF39FileHeader:40 Class: ELFCLASS6441 Data: [[ENDIAN]]42 Type: ET_EXEC43DWARF:44 debug_pubnames:45 Length: 0x123446 Version: 247 UnitOffset: 0x123448 UnitSize: 0x432149 Entries:50 - DieOffset: 0x1234567851 Name: abc52 - DieOffset: 0x8765432153 Name: def54 55## Generate and verify a 32-bit big endian .debug_pubnames section.56 57# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o58# RUN: llvm-readobj --sections --section-data %t1.be.o | \59# RUN: FileCheck -DSIZE=30 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE60 61# DWARF32-BE-NEXT: SectionData (62# DWARF32-BE-NEXT: 0000: 00001234 00020000 12340000 43211234 |...4.....4..C!.4|63## ^------- unit_length (4-byte)64## ^--- version (2-byte)65## ^-------- debug_info_offset (4-byte)66## ^-------- debug_info_length (4-byte)67## ^--- offset (4-byte)68##69# DWARF32-BE-NEXT: 0010: 56786162 63008765 43216465 6600 |Vxabc..eC!def.|70## ----71## ^-------- name "abc\0"72## ^-------- offset (4-byte)73## ^-------- name "def\0"74# DWARF32-BE-NEXT: )75 76## b) Generate the .debug_pubnames section from raw section content.77 78# RUN: yaml2obj --docnum=2 %s -o %t2.o79# RUN: llvm-readobj --sections --section-data %t2.o | \80# RUN: FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT81 82# ARBITRARY-CONTENT: SectionData (83# ARBITRARY-CONTENT-NEXT: 0000: 11223384# ARBITRARY-CONTENT-NEXT: )85 86--- !ELF87FileHeader:88 Class: ELFCLASS6489 Data: ELFDATA2LSB90 Type: ET_EXEC91Sections:92 - Name: .debug_pubnames93 Type: SHT_PROGBITS94 Content: "112233"95 96## c) Generate the .debug_pubnames section when the "Size" is specified.97 98# RUN: yaml2obj --docnum=3 %s -o %t3.o99# RUN: llvm-readobj --sections --section-data %t3.o | \100# RUN: FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE101 102# SIZE: SectionData (103# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|104# SIZE-NEXT: )105 106--- !ELF107FileHeader:108 Class: ELFCLASS64109 Data: ELFDATA2LSB110 Type: ET_EXEC111Sections:112 - Name: .debug_pubnames113 Type: SHT_PROGBITS114 Size: 0x10115 116## d) Test that yaml2obj emits an error message when both the "Size" and the117## "debug_pubnames" entry are specified at the same time.118 119# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR120 121# ERROR: yaml2obj: error: cannot specify section '.debug_pubnames' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time122 123--- !ELF124FileHeader:125 Class: ELFCLASS64126 Data: ELFDATA2LSB127 Type: ET_EXEC128Sections:129 - Name: .debug_pubnames130 Type: SHT_PROGBITS131 Size: 0x10132DWARF:133 debug_pubnames:134 Length: 0x1234135 Version: 2136 UnitOffset: 0x1234137 UnitSize: 0x4321138 Entries: []139 140## e) Test that yaml2obj emits an error message when both the "Content" and the141## "debug_pubnames" entry are specified at the same time.142 143# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR144 145--- !ELF146FileHeader:147 Class: ELFCLASS64148 Data: ELFDATA2LSB149 Type: ET_EXEC150Sections:151 - Name: .debug_pubnames152 Type: SHT_PROGBITS153 Content: "00"154DWARF:155 debug_pubnames:156 Length: 0x1234157 Version: 2158 UnitOffset: 0x1234159 UnitSize: 0x4321160 Entries: []161 162## f) Test that all the properties can be overridden by the section header when163## the "debug_pubnames" entry doesn't exist.164 165# RUN: yaml2obj --docnum=6 %s -o %t6.o166# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN167 168# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al169# OVERRIDDEN: [ 1] .debug_pubnames STRTAB 0000000000002020 000050 00000e 01 A 2 1 2170# OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 00005e 000000 00 0 0 0171 172--- !ELF173FileHeader:174 Class: ELFCLASS64175 Data: ELFDATA2LSB176 Type: ET_EXEC177Sections:178 - Name: .debug_pubnames179 Type: SHT_STRTAB ## SHT_PROGBITS by default.180 Flags: [SHF_ALLOC] ## 0 by default.181 Link: .sec ## 0 by default.182 EntSize: 1 ## 0 by default.183 Info: 1 ## 0 by default.184 AddressAlign: 2 ## 0 by default.185 Address: 0x2020 ## 0x00 by default.186 Offset: 0x50 ## 0x40 for the first section.187 Size: 0x0e ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".188 - Name: .sec ## Linked by .debug_pubnames.189 Type: SHT_STRTAB190 191## g) Test that all the properties can be overridden by the section header when192## the "debug_pubnames" entry exists.193 194# RUN: yaml2obj --docnum=7 %s -o %t7.o195# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN196 197--- !ELF198FileHeader:199 Class: ELFCLASS64200 Data: ELFDATA2LSB201 Type: ET_EXEC202Sections:203 - Name: .debug_pubnames204 Type: SHT_STRTAB ## SHT_PROGBITS by default.205 Flags: [SHF_ALLOC] ## 0 by default.206 Link: .sec ## 0 by default.207 EntSize: 1 ## 0 by default.208 Info: 1 ## 0 by default.209 AddressAlign: 2 ## 1 by default.210 Address: 0x2020 ## 0x00 by default.211 Offset: 0x50 ## 0x40 for the first section.212 - Name: .sec ## Linked by .debug_pubnames.213 Type: SHT_STRTAB214DWARF:215 debug_pubnames:216 Length: 0x1234217 Version: 2218 UnitOffset: 0x1234219 UnitSize: 0x4321220 Entries: []221