1+ ## Regression test for Issue #402.
2+ ## Ensures that Bloaty doesn't crash when a top-level DIE attribute
3+ ## requires access to the skeleton CU (via 'skeleton_' member) before
4+ ## it was previously initialized.
5+ ## This test uses DW_AT_GNU_dwo_id encoded with DW_FORM_addrx in the
6+ ## compile_unit DIE. This triggers ReadIndirectAddress during ReadTopLevelDIE,
7+ ## which dereferences skeleton_.
8+ ## We also intentionally truncate the debug_info section to trigger
9+ ## an error (confirming we got past the potential crash).
10+
11+ # RUN: %yaml2obj %s -o %t.o
12+ # RUN: not %bloaty -d compileunits %t.o 2>&1 | %FileCheck %s
13+
14+ # CHECK: bloaty: premature EOF reading variable-length DWARF data
15+
16+ --- !ELF
17+ FileHeader:
18+ Class: ELFCLASS64
19+ Data: ELFDATA2LSB
20+ Type: ET_EXEC
21+ Machine: EM_X86_64
22+ Sections:
23+ - Name: .debug_abbrev
24+ Type: SHT_PROGBITS
25+ # Abbrev 1: DW_TAG_compile_unit (0x11), DW_CHILDREN_no (0x00)
26+ # DW_AT_GNU_dwo_id (0x2131) DW_FORM_addrx (0x1b)
27+ # DW_AT_producer (0x25) DW_FORM_block1 (0x0a)
28+ # End (0000)
29+ # 0x2131 in ULEB128 is B1 42
30+ # Terminate abbrev table with an extra 00.
31+ Content: '011100B1421B250A000000'
32+ - Name: .debug_info
33+ Type: SHT_PROGBITS
34+ # DWARF 5 Header: Length(4), Ver(2), Type(1), Addr(1), AbbrevOff(4)
35+ # Length = 12 (0x0C) -> header_rest(8) + body(4)
36+ # Header: 0C000000 0500 01 08 00000000
37+ # Body: Abbrev(1) + Addrx Index(0) + Block Len(255) + Block Data(1 byte)
38+ # Body hex: 01 00 FF 00
39+ Content: '0C00000005000108000000000100FF00'
40+ - Name: .debug_addr
41+ Type: SHT_PROGBITS
42+ # DWARF 5 .debug_addr header:
43+ # Length(4) = 0x0C (12)
44+ # Version(2) = 5
45+ # AddrSize(1) = 8
46+ # SegSelSize(1) = 0
47+ # Address(8) = 0x00...
48+ Content: '0C000000050008000000000000000000'
0 commit comments