297 lines · plain
1# This test ensures that dwarfdump doesn't crash for malformed DWARF where a2# DIE references itself.3#4# Source:5# void f();6# __attribute__((always_inline)) void g() {7# f();8# }9# void h() {10# g();11# };12#13# Compile with:14# clang inlined.c -S -g -o inlined.s15#16# RUN: llvm-mc %s -filetype obj -triple x86_64-apple-darwin -o - \17# RUN: | llvm-dwarfdump -debug-info - \18# RUN: | FileCheck %s19 20# CHECK: 0x0000005a: DW_TAG_inlined_subroutine21# CHECK-NEXT: DW_AT_abstract_origin (0x0000005a)22 23 .section __TEXT,__text,regular,pure_instructions24 .macosx_version_min 10, 1325 .globl _g ## -- Begin function g26 .p2align 4, 0x9027_g: ## @g28Lfunc_begin0:29 .file 1 "inlined.c"30 .loc 1 2 0 ## inlined.c:2:031 .cfi_startproc32## %bb.0: ## %entry33 pushq %rbp34 .cfi_def_cfa_offset 1635 .cfi_offset %rbp, -1636 movq %rsp, %rbp37 .cfi_def_cfa_register %rbp38Ltmp0:39 .loc 1 3 3 prologue_end ## inlined.c:3:340 movb $0, %al41 callq _f42 .loc 1 4 1 ## inlined.c:4:143 popq %rbp44 retq45Ltmp1:46Lfunc_end0:47 .cfi_endproc48 ## -- End function49 .globl _h ## -- Begin function h50 .p2align 4, 0x9051_h: ## @h52Lfunc_begin1:53 .loc 1 5 0 ## inlined.c:5:054 .cfi_startproc55## %bb.0: ## %entry56 pushq %rbp57 .cfi_def_cfa_offset 1658 .cfi_offset %rbp, -1659 movq %rsp, %rbp60 .cfi_def_cfa_register %rbp61Ltmp2:62 .loc 1 3 3 prologue_end ## inlined.c:3:363 movb $0, %al64 callq _f65Ltmp3:66 .loc 1 7 1 ## inlined.c:7:167 popq %rbp68 retq69Ltmp4:70Lfunc_end1:71 .cfi_endproc72 ## -- End function73 .section __DWARF,__debug_str,regular,debug74Linfo_string:75 .asciz "clang version 7.0.0 " ## string offset=076 .asciz "inlined.c" ## string offset=2177 .asciz "/private/tmp" ## string offset=3178 .asciz "g" ## string offset=4479 .asciz "h" ## string offset=4680 .section __DWARF,__debug_abbrev,regular,debug81Lsection_abbrev:82 .byte 1 ## Abbreviation Code83 .byte 17 ## DW_TAG_compile_unit84 .byte 1 ## DW_CHILDREN_yes85 .byte 37 ## DW_AT_producer86 .byte 14 ## DW_FORM_strp87 .byte 19 ## DW_AT_language88 .byte 5 ## DW_FORM_data289 .byte 3 ## DW_AT_name90 .byte 14 ## DW_FORM_strp91 .byte 16 ## DW_AT_stmt_list92 .byte 23 ## DW_FORM_sec_offset93 .byte 27 ## DW_AT_comp_dir94 .byte 14 ## DW_FORM_strp95 .byte 17 ## DW_AT_low_pc96 .byte 1 ## DW_FORM_addr97 .byte 18 ## DW_AT_high_pc98 .byte 6 ## DW_FORM_data499 .byte 0 ## EOM(1)100 .byte 0 ## EOM(2)101 .byte 2 ## Abbreviation Code102 .byte 46 ## DW_TAG_subprogram103 .byte 0 ## DW_CHILDREN_no104 .byte 17 ## DW_AT_low_pc105 .byte 1 ## DW_FORM_addr106 .byte 18 ## DW_AT_high_pc107 .byte 6 ## DW_FORM_data4108 .byte 64 ## DW_AT_frame_base109 .byte 24 ## DW_FORM_exprloc110 .byte 49 ## DW_AT_abstract_origin111 .byte 19 ## DW_FORM_ref4112 .byte 0 ## EOM(1)113 .byte 0 ## EOM(2)114 .byte 3 ## Abbreviation Code115 .byte 46 ## DW_TAG_subprogram116 .byte 0 ## DW_CHILDREN_no117 .byte 3 ## DW_AT_name118 .byte 14 ## DW_FORM_strp119 .byte 58 ## DW_AT_decl_file120 .byte 11 ## DW_FORM_data1121 .byte 59 ## DW_AT_decl_line122 .byte 11 ## DW_FORM_data1123 .byte 63 ## DW_AT_external124 .byte 25 ## DW_FORM_flag_present125 .byte 32 ## DW_AT_inline126 .byte 11 ## DW_FORM_data1127 .byte 0 ## EOM(1)128 .byte 0 ## EOM(2)129 .byte 4 ## Abbreviation Code130 .byte 46 ## DW_TAG_subprogram131 .byte 1 ## DW_CHILDREN_yes132 .byte 17 ## DW_AT_low_pc133 .byte 1 ## DW_FORM_addr134 .byte 18 ## DW_AT_high_pc135 .byte 6 ## DW_FORM_data4136 .byte 64 ## DW_AT_frame_base137 .byte 24 ## DW_FORM_exprloc138 .byte 3 ## DW_AT_name139 .byte 14 ## DW_FORM_strp140 .byte 58 ## DW_AT_decl_file141 .byte 11 ## DW_FORM_data1142 .byte 59 ## DW_AT_decl_line143 .byte 11 ## DW_FORM_data1144 .byte 63 ## DW_AT_external145 .byte 25 ## DW_FORM_flag_present146 .byte 0 ## EOM(1)147 .byte 0 ## EOM(2)148 .byte 5 ## Abbreviation Code149 .byte 29 ## DW_TAG_inlined_subroutine150 .byte 0 ## DW_CHILDREN_no151 .byte 49 ## DW_AT_abstract_origin152 .byte 19 ## DW_FORM_ref4153 .byte 17 ## DW_AT_low_pc154 .byte 1 ## DW_FORM_addr155 .byte 18 ## DW_AT_high_pc156 .byte 6 ## DW_FORM_data4157 .byte 88 ## DW_AT_call_file158 .byte 11 ## DW_FORM_data1159 .byte 89 ## DW_AT_call_line160 .byte 11 ## DW_FORM_data1161 .byte 0 ## EOM(1)162 .byte 0 ## EOM(2)163 .byte 0 ## EOM(3)164 .section __DWARF,__debug_info,regular,debug165Lsection_info:166Lcu_begin0:167 .long 107 ## Length of Unit168 .short 4 ## DWARF version number169Lset0 = Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section170 .long Lset0171 .byte 8 ## Address Size (in bytes)172 .byte 1 ## Abbrev [1] 0xb:0x64 DW_TAG_compile_unit173 .long 0 ## DW_AT_producer174 .short 12 ## DW_AT_language175 .long 21 ## DW_AT_name176Lset1 = Lline_table_start0-Lsection_line ## DW_AT_stmt_list177 .long Lset1178 .long 31 ## DW_AT_comp_dir179 .quad Lfunc_begin0 ## DW_AT_low_pc180Lset2 = Lfunc_end1-Lfunc_begin0 ## DW_AT_high_pc181 .long Lset2182 .byte 2 ## Abbrev [2] 0x2a:0x13 DW_TAG_subprogram183 .quad Lfunc_begin0 ## DW_AT_low_pc184Lset3 = Lfunc_end0-Lfunc_begin0 ## DW_AT_high_pc185 .long Lset3186 .byte 1 ## DW_AT_frame_base187 .byte 86188 .long 61 ## DW_AT_abstract_origin189 .byte 3 ## Abbrev [3] 0x3d:0x8 DW_TAG_subprogram190 .long 44 ## DW_AT_name191 .byte 1 ## DW_AT_decl_file192 .byte 2 ## DW_AT_decl_line193 ## DW_AT_external194 .byte 1 ## DW_AT_inline195 .byte 4 ## Abbrev [4] 0x45:0x29 DW_TAG_subprogram196 .quad Lfunc_begin1 ## DW_AT_low_pc197Lset4 = Lfunc_end1-Lfunc_begin1 ## DW_AT_high_pc198 .long Lset4199 .byte 1 ## DW_AT_frame_base200 .byte 86201 .long 46 ## DW_AT_name202 .byte 1 ## DW_AT_decl_file203 .byte 5 ## DW_AT_decl_line204 ## DW_AT_external205 .byte 5 ## Abbrev [5] 0x5a:0x13 DW_TAG_inlined_subroutine206 .long 90 ## DW_AT_abstract_origin <- We modified the value so the DIE references itself.207 .quad Ltmp2 ## DW_AT_low_pc208Lset5 = Ltmp3-Ltmp2 ## DW_AT_high_pc209 .long Lset5210 .byte 1 ## DW_AT_call_file211 .byte 6 ## DW_AT_call_line212 .byte 0 ## End Of Children Mark213 .byte 0 ## End Of Children Mark214 .section __DWARF,__debug_ranges,regular,debug215Ldebug_range:216 .section __DWARF,__debug_macinfo,regular,debug217Ldebug_macinfo:218Lcu_macro_begin0:219 .byte 0 ## End Of Macro List Mark220 .section __DWARF,__apple_names,regular,debug221Lnames_begin:222 .long 1212240712 ## Header Magic223 .short 1 ## Header Version224 .short 0 ## Header Hash Function225 .long 2 ## Header Bucket Count226 .long 2 ## Header Hash Count227 .long 12 ## Header Data Length228 .long 0 ## HeaderData Die Offset Base229 .long 1 ## HeaderData Atom Count230 .short 1 ## DW_ATOM_die_offset231 .short 6 ## DW_FORM_data4232 .long 0 ## Bucket 0233 .long 1 ## Bucket 1234 .long 177676 ## Hash in Bucket 0235 .long 177677 ## Hash in Bucket 1236 .long LNames0-Lnames_begin ## Offset in Bucket 0237 .long LNames1-Lnames_begin ## Offset in Bucket 1238LNames0:239 .long 44 ## g240 .long 2 ## Num DIEs241 .long 42242 .long 90243 .long 0244LNames1:245 .long 46 ## h246 .long 1 ## Num DIEs247 .long 69248 .long 0249 .section __DWARF,__apple_objc,regular,debug250Lobjc_begin:251 .long 1212240712 ## Header Magic252 .short 1 ## Header Version253 .short 0 ## Header Hash Function254 .long 1 ## Header Bucket Count255 .long 0 ## Header Hash Count256 .long 12 ## Header Data Length257 .long 0 ## HeaderData Die Offset Base258 .long 1 ## HeaderData Atom Count259 .short 1 ## DW_ATOM_die_offset260 .short 6 ## DW_FORM_data4261 .long -1 ## Bucket 0262 .section __DWARF,__apple_namespac,regular,debug263Lnamespac_begin:264 .long 1212240712 ## Header Magic265 .short 1 ## Header Version266 .short 0 ## Header Hash Function267 .long 1 ## Header Bucket Count268 .long 0 ## Header Hash Count269 .long 12 ## Header Data Length270 .long 0 ## HeaderData Die Offset Base271 .long 1 ## HeaderData Atom Count272 .short 1 ## DW_ATOM_die_offset273 .short 6 ## DW_FORM_data4274 .long -1 ## Bucket 0275 .section __DWARF,__apple_types,regular,debug276Ltypes_begin:277 .long 1212240712 ## Header Magic278 .short 1 ## Header Version279 .short 0 ## Header Hash Function280 .long 1 ## Header Bucket Count281 .long 0 ## Header Hash Count282 .long 20 ## Header Data Length283 .long 0 ## HeaderData Die Offset Base284 .long 3 ## HeaderData Atom Count285 .short 1 ## DW_ATOM_die_offset286 .short 6 ## DW_FORM_data4287 .short 3 ## DW_ATOM_die_tag288 .short 5 ## DW_FORM_data2289 .short 4 ## DW_ATOM_type_flags290 .short 11 ## DW_FORM_data1291 .long -1 ## Bucket 0292 293.subsections_via_symbols294 .section __DWARF,__debug_line,regular,debug295Lsection_line:296Lline_table_start0:297