llvm-for-llvmta/test/tools/obj2yaml/ELF/DWARF/debug-ranges.yaml

227 lines
8.5 KiB
YAML
Raw Permalink Normal View History

2022-04-25 10:02:23 +02:00
## Test how we dump the .debug_ranges section.
## a) Test dumping the .debug_ranges section from various object files with
## different endian and bits.
## Dump the .debug_ranges section from a 32-bit little endian object file where
## the address_size of debug_info is 4.
# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DLOWOFFSET=0xFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \
# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 32-bit big endian object file where the
## address_size of debug_info is 4.
# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DENDIAN=MSB -DLOWOFFSET=0xFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \
# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 32-bit little endian object file where
## the address_size of debug_info is 8.
# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DADDRSIZE1=8 \
# RUN: -DADDRSIZE2=8 -DADDRSIZE3=8 -DADDRSIZE4=8 \
# RUN: -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \
# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 32-bit big endian object file where the
## address_size of debug_info is 8.
# RUN: yaml2obj --docnum=1 %s -DBITS=32 -DENDIAN=MSB -DADDRSIZE1=8 \
# RUN: -DADDRSIZE2=8 -DADDRSIZE3=8 -DADDRSIZE4=8 \
# RUN: -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \
# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 64-bit little endian object file where
## the address_size of debug_info is 8.
# RUN: yaml2obj --docnum=1 %s -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \
# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 64-bit big endian object file where the
## address_size of debug_info is 8.
# RUN: yaml2obj --docnum=1 %s -DENDIAN=MSB -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x8 \
# RUN: -DOFFSET=0x30 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 64-bit little endian object file where
## the address_size of debug_info is 4.
# RUN: yaml2obj --docnum=1 %s -DADDRSIZE1=4 -DADDRSIZE2=4 -DADDRSIZE3=4 \
# RUN: -DADDRSIZE4=4 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \
# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10
## Dump the .debug_ranges section from a 64-bit big endian object file where the
## address_size of debug_info is 4.
# RUN: yaml2obj --docnum=1 %s -DADDRSIZE1=4 -DADDRSIZE2=4 -DADDRSIZE3=4 \
# RUN: -DADDRSIZE4=4 -DLOWOFFSET=0xFFFFFFFFFFFFFFFF \
# RUN: -DHIGHOFFSET=0x10 | obj2yaml | \
# RUN: FileCheck %s --check-prefix=BASIC -DADDRSIZE=0x4 \
# RUN: -DOFFSET=0x18 -DLOWOFFSET=0xFFFFFFFF -DHIGHOFFSET=0x10
# BASIC-NOT: debug_ranges
# BASIC: debug_ranges:
# BASIC-NEXT: - Offset: 0x0
# BASIC-NEXT: AddrSize: [[ADDRSIZE]]
# BASIC-NEXT: Entries:
# BASIC-NEXT: - LowOffset: 0x10
# BASIC-NEXT: HighOffset: 0x20
# BASIC-NEXT: - LowOffset: 0x30
# BASIC-NEXT: HighOffset: 0x40
# BASIC-NEXT: - Offset: [[OFFSET]]
# BASIC-NEXT: AddrSize: [[ADDRSIZE]]
# BASIC-NEXT: Entries:
# BASIC-NEXT: - LowOffset: [[LOWOFFSET]]
# BASIC-NEXT: HighOffset: [[HIGHOFFSET]]
--- !ELF
FileHeader:
Class: ELFCLASS[[BITS=64]]
Data: ELFDATA2[[ENDIAN=LSB]]
Type: ET_EXEC
DWARF:
## The debug_ranges parser depends on the address_size field
## of compilation units. We add the .debug_info section to
## assist the parser.
debug_info:
- Version: 4
AddrSize: [[ADDRSIZE1=<none>]]
- Version: 4
AddrSize: [[ADDRSIZE2=<none>]]
debug_ranges:
- AddrSize: [[ADDRSIZE3=<none>]]
Entries:
- LowOffset: 0x10
HighOffset: 0x20
- LowOffset: 0x30
HighOffset: 0x40
- AddrSize: [[ADDRSIZE4=<none>]]
Entries:
- LowOffset: [[LOWOFFSET=0x10]]
HighOffset: [[HIGHOFFSET=0x20]]
## b) Test that obj2yaml dumps the .debug_ranges as a raw content section when
## the parser fails. In this case, the address_size of the two compilation units
## doesn't match.
# RUN: yaml2obj --docnum=1 -DADDRSIZE1=4 -DADDRSIZE2=8 %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=RAW --implicit-check-not=debug_ranges
# RAW: - Name: .debug_ranges
# RAW-NEXT: Type: SHT_PROGBITS
# RAW-NEXT: AddressAlign: 0x1
# RAW-NEXT: Content: '1000000000000000
## ^--------------- LowOffset
# RAW-SAME: {{^}}2000000000000000
## ^--------------- HighOffset
# RAW-SAME: {{^}}3000000000000000
## ^--------------- LowOffset
# RAW-SAME: {{^}}4000000000000000
## ^--------------- HighOffset
# RAW-SAME: {{^}}0000000000000000
## ^---------------
# RAW-SAME: {{^}}0000000000000000
## ---------------- terminator
# RAW-SAME: {{^}}1000000000000000
## ^--------------- LowOffset
# RAW-SAME: {{^}}2000000000000000
## ^--------------- HighOffset
# RAW-SAME: {{^}}0000000000000000
## ^---------------
# RAW-SAME: {{^}}0000000000000000'
## ---------------- terminator
## c) Test dumping an empty .debug_ranges section.
# RUN: yaml2obj --docnum=2 %s | obj2yaml | \
# RUN: FileCheck %s --check-prefix=EMPTY --implicit-check-not=Sections:
# EMPTY: DWARF:
# EMPTY-NEXT: debug_ranges: []
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_ranges: []
## d) Test dumping a .debug_ranges section whose section header properties are
## overridden.
## Override the sh_type field.
# RUN: yaml2obj --docnum=3 -DTYPE=SHT_STRTAB %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=STRTAB --check-prefixes=COMMON
## Override the sh_flags field.
# RUN: yaml2obj --docnum=3 -DFLAGS=[SHF_ALLOC] %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,FLAGS
## Override the sh_link field.
# RUN: yaml2obj --docnum=3 -DLINK='.sec' %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,LINK
## Override the sh_entsize field.
# RUN: yaml2obj --docnum=3 -DENTSIZE=3 %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ENTSIZE
## Override the sh_info field.
# RUN: yaml2obj --docnum=3 -DINFO=3 %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,INFO
## Override the sh_addralign field.
# RUN: yaml2obj --docnum=3 -DADDRALIGN=3 %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ADDRALIGN
## Override the sh_address field.
# RUN: yaml2obj --docnum=3 -DADDRESS=0x2020 %s | obj2yaml | \
# RUN: FileCheck %s -DTYPE=PROGBITS --check-prefixes=COMMON,ADDRESS
# COMMON: - Name: .debug_ranges
# COMMON-NEXT: Type: SHT_[[TYPE]]
# FLAGS-NEXT: Flags: [ SHF_ALLOC ]
# LINK-NEXT: Link: .sec
# ENTSIZE-NEXT: EntSize: 0x3
# INFO-NEXT: Info: 0x3
# ADDRALIGN-NEXT: AddressAlign: 0x3
# ADDRESS-NEXT: Address: 0x2020
# COMMON: debug_ranges:
# COMMON-NEXT: - Offset: 0x0
# COMMON-NEXT: AddrSize: 0x8
# COMMON-NEXT: Entries:
# COMMON-NEXT: - LowOffset: 0x10
# COMMON-NEXT: HighOffset: 0x20
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_ranges
Type: [[TYPE=SHT_PROGBITS]]
Flags: [[FLAGS=<none>]]
Link: [[LINK=<none>]]
EntSize: [[ENTSIZE=<none>]]
Info: [[INFO=<none>]]
AddressAlign: [[ADDRALIGN=0]]
Address: [[ADDRESS=<none>]]
- Name: .sec
Type: SHT_PROGBITS
DWARF:
debug_info:
- Version: 4
AddrSize: 8
debug_ranges:
- Entries:
- LowOffset: 0x10
HighOffset: 0x20