1*c19a2891SJan Kratochvil## Test llvm-dwarfdump detects and reports invalid DWARF format of the file. 2*c19a2891SJan Kratochvil 3*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=CUEND=1 \ 4*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=CUEND %s 5*c19a2891SJan Kratochvil# CUEND: warning: DWARF unit from offset 0x0000000c incl. to offset 0x0000002b excl. tries to read DIEs at offset 0x0000002b 6*c19a2891SJan Kratochvil 7*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=ABBREVSETINVALID=1 \ 8*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=ABBREVSETINVALID %s 9*c19a2891SJan Kratochvil# ABBREVSETINVALID: warning: DWARF unit at offset 0x0000000c contains invalid abbreviation set offset 0x0 10*c19a2891SJan Kratochvil 11*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=ABBREVNO=2 \ 12*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=ABBREVNO %s 13*c19a2891SJan Kratochvil# ABBREVNO: warning: DWARF unit at offset 0x0000000c contains invalid abbreviation 2 at offset 0x00000018, valid abbreviations are 1, 5, 3-4 14*c19a2891SJan Kratochvil 15*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=FORMNO=0xdead \ 16*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=FORMNO %s 17*c19a2891SJan Kratochvil# FORMNO: warning: DWARF unit at offset 0x0000000c contains invalid FORM_* 0xdead at offset 0x00000018 18*c19a2891SJan Kratochvil 19*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=SHORTINITLEN=1 \ 20*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=SHORTINITLEN %s 21*c19a2891SJan Kratochvil# SHORTINITLEN: warning: DWARF unit at 0x0000002c cannot be parsed: 22*c19a2891SJan Kratochvil# SHORTINITLEN-NEXT: warning: unexpected end of data at offset 0x2d while reading [0x2c, 0x30) 23*c19a2891SJan Kratochvil 24*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=BADTYPEUNIT=1 \ 25*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=BADTYPEUNITBEFORE %s 26*c19a2891SJan Kratochvil# BADTYPEUNITBEFORE: warning: DWARF type unit at offset 0x0000002c has its relocated type_offset 0x0000002d pointing inside the header 27*c19a2891SJan Kratochvil 28*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=BADTYPEUNIT=0x100 \ 29*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=BADTYPEUNITAFTER %s 30*c19a2891SJan Kratochvil# BADTYPEUNITAFTER: warning: DWARF type unit from offset 0x0000002c incl. to offset 0x00000045 excl. has its relocated type_offset 0x0000012c pointing past the unit end 31*c19a2891SJan Kratochvil 32*c19a2891SJan Kratochvil# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj --defsym=TOOLONG=1 \ 33*c19a2891SJan Kratochvil# RUN: | llvm-dwarfdump - 2>&1 | FileCheck --check-prefix=TOOLONG %s 34*c19a2891SJan Kratochvil# TOOLONG: warning: DWARF unit from offset 0x0000000c incl. to offset 0x0000002d excl. extends past section size 0x0000002c 35*c19a2891SJan Kratochvil 36*c19a2891SJan Kratochvil .section .debug_abbrev,"",@progbits 37*c19a2891SJan Kratochvil.ifndef ABBREVSETINVALID 38*c19a2891SJan Kratochvil .uleb128 1 # Abbreviation Code 39*c19a2891SJan Kratochvil .uleb128 17 # DW_TAG_compile_unit 40*c19a2891SJan Kratochvil .uleb128 1 # DW_CHILDREN_yes 41*c19a2891SJan Kratochvil .uleb128 37 # DW_AT_producer 42*c19a2891SJan Kratochvil.ifndef FORMNO 43*c19a2891SJan Kratochvil .uleb128 8 # DW_FORM_string 44*c19a2891SJan Kratochvil.else 45*c19a2891SJan Kratochvil .uleb128 FORMNO 46*c19a2891SJan Kratochvil.endif 47*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 1 DW_AT_* 48*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 1 DW_FORM_* 49*c19a2891SJan Kratochvil .uleb128 5 # Abbreviation Code 50*c19a2891SJan Kratochvil .uleb128 10 # DW_TAG_label 51*c19a2891SJan Kratochvil .uleb128 0 # DW_CHILDREN_no 52*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 4 DW_AT_* 53*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 4 DW_FORM_* 54*c19a2891SJan Kratochvil .uleb128 3 # Abbreviation Code 55*c19a2891SJan Kratochvil .uleb128 10 # DW_TAG_label 56*c19a2891SJan Kratochvil .uleb128 0 # DW_CHILDREN_no 57*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 3 DW_AT_* 58*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 3 DW_FORM_* 59*c19a2891SJan Kratochvil .uleb128 4 # Abbreviation Code 60*c19a2891SJan Kratochvil .uleb128 10 # DW_TAG_label 61*c19a2891SJan Kratochvil .uleb128 0 # DW_CHILDREN_no 62*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 4 DW_AT_* 63*c19a2891SJan Kratochvil .uleb128 0 # end abbrev 4 DW_FORM_* 64*c19a2891SJan Kratochvil .uleb128 0 # end abbrevs section 65*c19a2891SJan Kratochvil.endif 66*c19a2891SJan Kratochvil 67*c19a2891SJan Kratochvil .section .debug_info,"",@progbits 68*c19a2891SJan Kratochvil## The first CU is here to shift the next CU being really tested to non-zero CU 69*c19a2891SJan Kratochvil## offset to check more for error messages. 70*c19a2891SJan Kratochvil .long .Lcu_endp-.Lcu_startp # Length of Unit 71*c19a2891SJan Kratochvil.Lcu_startp: 72*c19a2891SJan Kratochvil .short 4 # DWARF version number 73*c19a2891SJan Kratochvil .long .debug_abbrev # Offset Into Abbrev. Section 74*c19a2891SJan Kratochvil .byte 8 # Address Size (in bytes) 75*c19a2891SJan Kratochvil .uleb128 0 # End Of Children Mark 76*c19a2891SJan Kratochvil.Lcu_endp: 77*c19a2891SJan Kratochvil 78*c19a2891SJan Kratochvil.ifndef TOOLONG 79*c19a2891SJan Kratochvil.equ TOOLONG, 0 80*c19a2891SJan Kratochvil.endif 81*c19a2891SJan Kratochvil .long .Lcu_end0-.Lcu_start0 + TOOLONG # Length of Unit 82*c19a2891SJan Kratochvil.Lcu_start0: 83*c19a2891SJan Kratochvil .short 4 # DWARF version number 84*c19a2891SJan Kratochvil .long .debug_abbrev # Offset Into Abbrev. Section 85*c19a2891SJan Kratochvil .byte 8 # Address Size (in bytes) 86*c19a2891SJan Kratochvil.ifndef ABBREVNO 87*c19a2891SJan Kratochvil .uleb128 1 # Abbrev [1] DW_TAG_compile_unit 88*c19a2891SJan Kratochvil.else 89*c19a2891SJan Kratochvil .uleb128 ABBREVNO 90*c19a2891SJan Kratochvil.endif 91*c19a2891SJan Kratochvil .asciz "hand-written DWARF" # DW_AT_producer 92*c19a2891SJan Kratochvil.ifndef CUEND 93*c19a2891SJan Kratochvil .uleb128 0 # End Of Children Mark 94*c19a2891SJan Kratochvil.endif 95*c19a2891SJan Kratochvil.Lcu_end0: 96*c19a2891SJan Kratochvil 97*c19a2891SJan Kratochvil.ifdef SHORTINITLEN 98*c19a2891SJan Kratochvil .byte 0x55 # Too short Length of Unit 99*c19a2891SJan Kratochvil.endif 100*c19a2891SJan Kratochvil.ifdef BADTYPEUNIT 101*c19a2891SJan Kratochvil .long .Lcu_end1-.Lcu_start1 # Length of Unit 102*c19a2891SJan Kratochvil.Lcu_start1: 103*c19a2891SJan Kratochvil .short 5 # DWARF version number 104*c19a2891SJan Kratochvil .byte 2 # DW_UT_type 105*c19a2891SJan Kratochvil .byte 8 # Address Size (in bytes) 106*c19a2891SJan Kratochvil .long .debug_abbrev # Offset Into Abbrev. Section 107*c19a2891SJan Kratochvil .quad 0xbaddefacedfacade # Type Signature 108*c19a2891SJan Kratochvil .long BADTYPEUNIT # Type DIE Offset 109*c19a2891SJan Kratochvil .uleb128 0 # End Of Children Mark 110*c19a2891SJan Kratochvil.Lcu_end1: 111*c19a2891SJan Kratochvil.endif 112