|
| 1 | +# Tests that we handle recursive DWO references gracefully without crashing. |
| 2 | +# This reproduces a case where a .dwo file contains a DW_AT_GNU_dwo_name attribute pointing to itself. |
| 3 | + |
| 4 | +# RUN: mkdir -p %t.dir |
| 5 | +# RUN: %yaml2obj %s --docnum=1 -o %t.dir/skeleton.o |
| 6 | +# RUN: %yaml2obj %s --docnum=2 -o %t.dir/recursive.dwo |
| 7 | + |
| 8 | +# Run bloaty from the directory containing the files so relative paths resolve. |
| 9 | +# RUN: cd %t.dir && %bloaty -d compileunits skeleton.o | %FileCheck %s |
| 10 | + |
| 11 | +# If the recursion guard is working, bloaty should read the DWO once, |
| 12 | +# resolve the CU name "recursive.c", and stop. It should NOT crash. |
| 13 | + |
| 14 | +# CHECK: FILE SIZE VM SIZE |
| 15 | +# CHECK: -------------- -------------- |
| 16 | +# CHECK: [ELF Section Headers] |
| 17 | +# CHECK: recursive.c |
| 18 | +# CHECK: TOTAL |
| 19 | + |
| 20 | +# Document 1: skeleton.o |
| 21 | +--- !ELF |
| 22 | +FileHeader: |
| 23 | + Class: ELFCLASS64 |
| 24 | + Data: ELFDATA2LSB |
| 25 | + Type: ET_DYN |
| 26 | + Machine: EM_X86_64 |
| 27 | +ProgramHeaders: |
| 28 | + - Type: PT_LOAD |
| 29 | + Flags: [ PF_X, PF_R ] |
| 30 | + FirstSec: .text |
| 31 | + LastSec: .text |
| 32 | + VAddr: 0x400000 |
| 33 | + Align: 0x1000 |
| 34 | +Sections: |
| 35 | + - Name: .text |
| 36 | + Type: SHT_PROGBITS |
| 37 | + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| 38 | + Address: 0x400000 |
| 39 | + AddressAlign: 0x10 |
| 40 | + Size: 0x100 |
| 41 | + - Name: .debug_addr |
| 42 | + Type: SHT_PROGBITS |
| 43 | + AddressAlign: 0x1 |
| 44 | + Content: '0000400000000000' |
| 45 | +DWARF: |
| 46 | + debug_str: |
| 47 | + - recursive.dwo |
| 48 | + - . |
| 49 | + debug_abbrev: |
| 50 | + - ID: 0 |
| 51 | + Table: |
| 52 | + - Code: 0x1 |
| 53 | + Tag: DW_TAG_compile_unit |
| 54 | + Children: DW_CHILDREN_no |
| 55 | + Attributes: |
| 56 | + - Attribute: DW_AT_GNU_dwo_name |
| 57 | + Form: DW_FORM_strp |
| 58 | + - Attribute: DW_AT_comp_dir |
| 59 | + Form: DW_FORM_strp |
| 60 | + - Attribute: DW_AT_GNU_dwo_id |
| 61 | + Form: DW_FORM_data8 |
| 62 | + - Attribute: DW_AT_GNU_addr_base |
| 63 | + Form: DW_FORM_sec_offset |
| 64 | + debug_info: |
| 65 | + - Version: 4 |
| 66 | + AbbrevTableID: 0 |
| 67 | + AbbrOffset: 0x0 |
| 68 | + AddrSize: 8 |
| 69 | + Entries: |
| 70 | + - AbbrCode: 0x1 |
| 71 | + Values: |
| 72 | + - Value: 0x0 # recursive.dwo |
| 73 | + - Value: 0xe # . |
| 74 | + - Value: 0xfeedfacefeedface |
| 75 | + - Value: 0x0 |
| 76 | + |
| 77 | +# Document 2: recursive.dwo |
| 78 | +--- !ELF |
| 79 | +FileHeader: |
| 80 | + Class: ELFCLASS64 |
| 81 | + Data: ELFDATA2LSB |
| 82 | + Type: ET_REL |
| 83 | + Machine: EM_X86_64 |
| 84 | +DWARF: |
| 85 | + debug_str: |
| 86 | + - recursive.c |
| 87 | + - recursive.dwo |
| 88 | + - . |
| 89 | + debug_abbrev: |
| 90 | + - ID: 0 |
| 91 | + Table: |
| 92 | + - Code: 0x1 |
| 93 | + Tag: DW_TAG_compile_unit |
| 94 | + Children: DW_CHILDREN_no |
| 95 | + Attributes: |
| 96 | + - Attribute: DW_AT_name |
| 97 | + Form: DW_FORM_strp |
| 98 | + - Attribute: DW_AT_GNU_dwo_id |
| 99 | + Form: DW_FORM_data8 |
| 100 | + - Attribute: DW_AT_GNU_dwo_name |
| 101 | + Form: DW_FORM_strp |
| 102 | + - Attribute: DW_AT_comp_dir |
| 103 | + Form: DW_FORM_strp |
| 104 | + - Attribute: DW_AT_low_pc |
| 105 | + Form: DW_FORM_GNU_addr_index |
| 106 | + - Attribute: DW_AT_high_pc |
| 107 | + Form: DW_FORM_data4 |
| 108 | + debug_info: |
| 109 | + - Version: 4 |
| 110 | + AbbrevTableID: 0 |
| 111 | + AbbrOffset: 0x0 |
| 112 | + AddrSize: 8 |
| 113 | + Entries: |
| 114 | + - AbbrCode: 0x1 |
| 115 | + Values: |
| 116 | + - Value: 0x0 # recursive.c |
| 117 | + - Value: 0xfeedfacefeedface |
| 118 | + - Value: 0xc # recursive.dwo |
| 119 | + - Value: 0x1a # . |
| 120 | + - Value: 0x0 # low_pc index 0 -> 0x400000 |
| 121 | + - Value: 0x100 # high_pc size -> 0x100 |
0 commit comments