1## Test how we dump the .debug_ranges section. 2 3## a) Test dumping the .debug_ranges section from various object files with 4## different endian and bits. 5 6## Dump the .debug_ranges section from a 32-bit little endian object file where 7## the address_size of debug_info is 4. 8# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DLOWOFFSET=0xFFFFFFFF \ 9# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 10# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \ 11# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10 12 13## Dump the .debug_ranges section from a 32-bit big endian object file where the 14## address_size of debug_info is 4. 15# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DENDIAN=MSB -DLOWOFFSET=0xFFFFFFFF \ 16# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 17# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \ 18# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10 19 20## Dump the .debug_ranges section from a 32-bit little endian object file where 21## the address_size of debug_info is 8. 22# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DADDRSIZE1=8 \ 23# RUN: -DADDRSIZE2=8 -DADDRSIZE3=8 -DADDRSIZE4=8 \ 24# RUN: -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 | obj2yaml | \ 25# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \ 26# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \ 27# RUN: -DHIGHOFFSET=0x10 28 29## Dump the .debug_ranges section from a 32-bit big endian object file where the 30## address_size of debug_info is 8. 31# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DENDIAN=MSB -DADDRSIZE1=8 \ 32# RUN: -DADDRSIZE2=8 -DADDRSIZE3=8 -DADDRSIZE4=8 \ 33# RUN: -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 | obj2yaml | \ 34# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \ 35# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 36 37## Dump the .debug_ranges section from a 64-bit little endian object file where 38## the address_size of debug_info is 8. 39# RUN: yaml2obj --docnum=1 %s -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \ 40# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 41# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \ 42# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 43 44## Dump the .debug_ranges section from a 64-bit big endian object file where the 45## address_size of debug_info is 8. 46# RUN: yaml2obj --docnum=1 %s -DENDIAN=MSB -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \ 47# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 48# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \ 49# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 50 51## Dump the .debug_ranges section from a 64-bit little endian object file where 52## the address_size of debug_info is 4. 53# RUN: yaml2obj --docnum=1 %s -DADDRSIZE1=4 -DADDRSIZE2=4 -DADDRSIZE3=4 \ 54# RUN: -DADDRSIZE4=4 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \ 55# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 56# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \ 57# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10 58 59## Dump the .debug_ranges section from a 64-bit big endian object file where the 60## address_size of debug_info is 4. 61# RUN: yaml2obj --docnum=1 %s -DADDRSIZE1=4 -DADDRSIZE2=4 -DADDRSIZE3=4 \ 62# RUN: -DADDRSIZE4=4 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \ 63# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \ 64# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \ 65# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10 66 67 68# BASIC-NOT: debug_ranges 69# BASIC: debug_ranges: 70# BASIC-NEXT: - Offset: 0x0 71# BASIC-NEXT: AddrSize: [[ADDRSIZE]] 72# BASIC-NEXT: Entries: 73# BASIC-NEXT: - LowOffset: 0x10 74# BASIC-NEXT: HighOffset: 0x20 75# BASIC-NEXT: - LowOffset: 0x30 76# BASIC-NEXT: HighOffset: 0x40 77# BASIC-NEXT: - Offset: [[OFFSET]] 78# BASIC-NEXT: AddrSize: [[ADDRSIZE]] 79# BASIC-NEXT: Entries: 80# BASIC-NEXT: - LowOffset: [[LOWOFFSET]] 81# BASIC-NEXT: HighOffset: [[HIGHOFFSET]] 82 83--- !ELF 84FileHeader: 85 Class: ELFCLASS[[BITS=64]] 86 Data: ELFDATA2[[ENDIAN=LSB]] 87 Type: ET_EXEC 88DWARF: 89 ## The debug_ranges parser depends on the address_size field 90 ## of compilation units. We add the .debug_info section to 91 ## assist the parser. 92 debug_info: 93 - Version: 4 94 AddrSize: [[ADDRSIZE1=<none>]] 95 - Version: 4 96 AddrSize: [[ADDRSIZE2=<none>]] 97 debug_ranges: 98 - AddrSize: [[ADDRSIZE3=<none>]] 99 Entries: 100 - LowOffset: 0x10 101 HighOffset: 0x20 102 - LowOffset: 0x30 103 HighOffset: 0x40 104 - AddrSize: [[ADDRSIZE4=<none>]] 105 Entries: 106 - LowOffset: [[LOWOFFSET=0x10]] 107 HighOffset: [[HIGHOFFSET=0x20]] 108 109## b) Test that obj2yaml dumps the .debug_ranges as a raw content section when 110## the parser fails. In this case, the address_size of the two compilation units 111## doesn't match. 112 113# RUN: yaml2obj --docnum=1 -DADDRSIZE1=4 -DADDRSIZE2=8 %s | obj2yaml | \ 114# RUN: FileCheck %s --check-prefix=RAW --implicit-check-not=debug_ranges 115 116# RAW: - Name: .debug_ranges 117# RAW-NEXT: Type: SHT_PROGBITS 118# RAW-NEXT: AddressAlign: 0x1 119# RAW-NEXT: Content: '1000000000000000 120## ^--------------- LowOffset 121# RAW-SAME: {{^}}2000000000000000 122## ^--------------- HighOffset 123# RAW-SAME: {{^}}3000000000000000 124## ^--------------- LowOffset 125# RAW-SAME: {{^}}4000000000000000 126## ^--------------- HighOffset 127# RAW-SAME: {{^}}0000000000000000 128## ^--------------- 129# RAW-SAME: {{^}}0000000000000000 130## ---------------- terminator 131# RAW-SAME: {{^}}1000000000000000 132## ^--------------- LowOffset 133# RAW-SAME: {{^}}2000000000000000 134## ^--------------- HighOffset 135# RAW-SAME: {{^}}0000000000000000 136## ^--------------- 137# RAW-SAME: {{^}}0000000000000000' 138## ---------------- terminator 139 140## c) Test dumping an empty .debug_ranges section. 141 142# RUN: yaml2obj --docnum=2 %s | obj2yaml | \ 143# RUN: FileCheck %s --check-prefix=EMPTY --implicit-check-not=Sections: 144 145# EMPTY: DWARF: 146# EMPTY-NEXT: debug_ranges: [] 147 148--- !ELF 149FileHeader: 150 Class: ELFCLASS64 151 Data: ELFDATA2LSB 152 Type: ET_EXEC 153DWARF: 154 debug_ranges: [] 155 156## d) Test dumping a .debug_ranges section whose section header properties are 157## overridden. 158 159## Override the sh_type field. 160# RUN: yaml2obj --docnum=3 -DTYPE=SHT_STRTAB %s | obj2yaml | \ 161# RUN: FileCheck %s -DTYPE=STRTAB --check-prefixes=COMMON 162 163## Override the sh_flags field. 164# RUN: yaml2obj --docnum=3 -DFLAGS=[SHF_ALLOC] %s | obj2yaml | \ 165# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,FLAGS 166 167## Override the sh_link field. 168# RUN: yaml2obj --docnum=3 -DLINK='.sec' %s | obj2yaml | \ 169# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,LINK 170 171## Override the sh_entsize field. 172# RUN: yaml2obj --docnum=3 -DENTSIZE=3 %s | obj2yaml | \ 173# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ENTSIZE 174 175## Override the sh_info field. 176# RUN: yaml2obj --docnum=3 -DINFO=3 %s | obj2yaml | \ 177# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,INFO 178 179## Override the sh_addralign field. 180# RUN: yaml2obj --docnum=3 -DADDRALIGN=3 %s | obj2yaml | \ 181# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ADDRALIGN 182 183## Override the sh_address field. 184# RUN: yaml2obj --docnum=3 -DADDRESS=0x2020 %s | obj2yaml | \ 185# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ADDRESS 186 187# COMMON: - Name: .debug_ranges 188# COMMON-NEXT: Type: SHT_[[TYPE]] 189# FLAGS-NEXT: Flags: [ SHF_ALLOC ] 190# LINK-NEXT: Link: .sec 191# ENTSIZE-NEXT: EntSize: 0x3 192# INFO-NEXT: Info: 0x3 193# ADDRALIGN-NEXT: AddressAlign: 0x3 194# ADDRESS-NEXT: Address: 0x2020 195 196# COMMON: debug_ranges: 197# COMMON-NEXT: - Offset: 0x0 198# COMMON-NEXT: AddrSize: 0x8 199# COMMON-NEXT: Entries: 200# COMMON-NEXT: - LowOffset: 0x10 201# COMMON-NEXT: HighOffset: 0x20 202 203--- !ELF 204FileHeader: 205 Class: ELFCLASS64 206 Data: ELFDATA2LSB 207 Type: ET_EXEC 208Sections: 209 - Name: .debug_ranges 210 Type: [[TYPE=SHT_PROGBITS]] 211 Flags: [[FLAGS=<none>]] 212 Link: [[LINK=<none>]] 213 EntSize: [[ENTSIZE=<none>]] 214 Info: [[INFO=<none>]] 215 AddressAlign: [[ADDRALIGN=0]] 216 Address: [[ADDRESS=<none>]] 217 - Name: .sec 218 Type: SHT_PROGBITS 219DWARF: 220 debug_info: 221 - Version: 4 222 AddrSize: 8 223 debug_ranges: 224 - Entries: 225 - LowOffset: 0x10 226 HighOffset: 0x20 227