| 1 |
## Test llvm-dwarfdump detects and reports invalid DWARF format of the file. |
| 2 |
|
| 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 |
| 6 |
|
| 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 |
| 10 |
|
| 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 |
| 14 |
|
| 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 |
| 18 |
|
| 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) |
| 23 |
|
| 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 |
| 27 |
|
| 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 |
| 31 |
|
| 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 |
| 35 |
|
| 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 |
| 42 |
.ifndef FORMNO |
| 43 |
.uleb128 8 # DW_FORM_string |
| 44 |
.else |
| 45 |
.uleb128 FORMNO |
| 46 |
.endif |
| 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 |
| 65 |
.endif |
| 66 |
|
| 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 |
| 71 |
.Lcu_startp: |
| 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 |
| 76 |
.Lcu_endp: |
| 77 |
|
| 78 |
.ifndef TOOLONG |
| 79 |
.equ TOOLONG, 0 |
| 80 |
.endif |
| 81 |
.long .Lcu_end0-.Lcu_start0 + TOOLONG # Length of Unit |
| 82 |
.Lcu_start0: |
| 83 |
.short 4 # DWARF version number |
| 84 |
.long .debug_abbrev # Offset Into Abbrev. Section |
| 85 |
.byte 8 # Address Size (in bytes) |
| 86 |
.ifndef ABBREVNO |
| 87 |
.uleb128 1 # Abbrev [1] DW_TAG_compile_unit |
| 88 |
.else |
| 89 |
.uleb128 ABBREVNO |
| 90 |
.endif |
| 91 |
.asciz "hand-written DWARF" # DW_AT_producer |
| 92 |
.ifndef CUEND |
| 93 |
.uleb128 0 # End Of Children Mark |
| 94 |
.endif |
| 95 |
.Lcu_end0: |
| 96 |
|
| 97 |
.ifdef SHORTINITLEN |
| 98 |
.byte 0x55 # Too short Length of Unit |
| 99 |
.endif |
| 100 |
.ifdef BADTYPEUNIT |
| 101 |
.long .Lcu_end1-.Lcu_start1 # Length of Unit |
| 102 |
.Lcu_start1: |
| 103 |
.short 5 # DWARF version number |
| 104 |
.byte 2 # DW_UT_type |
| 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 |
| 110 |
.Lcu_end1: |
| 111 |
.endif |