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