| 1 |
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o |
| 2 |
# RUN: not llvm-dwarfdump -verify %t.o | FileCheck --check-prefix=VERIFY %s |
| 3 |
|
| 4 |
# Check that the verifier correctly diagnoses various error conditions with |
| 5 |
# the usage of string indices/offsets and string offsets tables. |
| 6 |
|
| 7 |
.section .debug_line_str,"MS",@progbits,1 |
| 8 |
str_comp_dir: |
| 9 |
.asciz "llvm/test/tools/llvm-dwarfdump/X86" |
| 10 |
|
| 11 |
.section .debug_str,"MS",@progbits,1 |
| 12 |
str_producer: |
| 13 |
.asciz "Handmade DWARF producer" |
| 14 |
|
| 15 |
.section .debug_str_offsets,"",@progbits |
| 16 |
# The string offsets table |
| 17 |
.long .debug_str_offsets_segment0_end-.debug_str_offsets_base0+4 |
| 18 |
.short 5 # DWARF version |
| 19 |
.short 0 # Padding |
| 20 |
.debug_str_offsets_base0: |
| 21 |
.long str_producer |
| 22 |
.long 1000 # Invalid string address. |
| 23 |
.debug_str_offsets_segment0_end: |
| 24 |
|
| 25 |
# A simple abbrev section with a basic compile unit DIE. |
| 26 |
.section .debug_abbrev,"",@progbits |
| 27 |
.byte 0x01 # Abbrev code |
| 28 |
.byte 0x11 # DW_TAG_compile_unit |
| 29 |
.byte 0x00 # DW_CHILDREN_no |
| 30 |
.byte 0x25 # DW_AT_producer |
| 31 |
.byte 0x1a # DW_FORM_strx |
| 32 |
.byte 0x1b # DW_AT_comp_dir |
| 33 |
.byte 0x1f # DW_FORM_line_strp |
| 34 |
.byte 0x72 # DW_AT_str_offsets_base |
| 35 |
.byte 0x17 # DW_FORM_sec_offset |
| 36 |
.byte 0x00 # EOM(1) |
| 37 |
.byte 0x00 # EOM(2) |
| 38 |
.byte 0x00 # EOM(3) |
| 39 |
|
| 40 |
.section .debug_info,"",@progbits |
| 41 |
|
| 42 |
# The first unit's CU DIE has an invalid DW_AT_str_offsets_base which |
| 43 |
# renders any string index unresolvable. |
| 44 |
|
| 45 |
# DWARF v5 CU header. |
| 46 |
.long CU1_5_end-CU1_5_version # Length of Unit |
| 47 |
CU1_5_version: |
| 48 |
.short 5 # DWARF version number |
| 49 |
.byte 1 # DWARF Unit Type |
| 50 |
.byte 8 # Address Size (in bytes) |
| 51 |
.long .debug_abbrev # Offset Into Abbrev. Section |
| 52 |
# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. |
| 53 |
.byte 1 # Abbreviation code |
| 54 |
.byte 0 # Index of string for DW_AT_producer. |
| 55 |
.long str_comp_dir # Offset of debug line string for DW_AT_comp_dir |
| 56 |
.long 1000 # Bad value for DW_AT_str_offsets_base |
| 57 |
.byte 0 # NULL |
| 58 |
CU1_5_end: |
| 59 |
|
| 60 |
# The second unit's CU DIE uses an invalid string index. |
| 61 |
|
| 62 |
# DWARF v5 CU header |
| 63 |
.long CU2_5_end-CU2_5_version # Length of Unit |
| 64 |
CU2_5_version: |
| 65 |
.short 5 # DWARF version number |
| 66 |
.byte 1 # DWARF Unit Type |
| 67 |
.byte 8 # Address Size (in bytes) |
| 68 |
.long .debug_abbrev # Offset Into Abbrev. Section |
| 69 |
# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. |
| 70 |
.byte 1 # Abbreviation code |
| 71 |
.byte 100 # Invalid string index |
| 72 |
.long str_comp_dir # Offset of debug line string for DW_AT_comp_dir |
| 73 |
.long .debug_str_offsets_base0 |
| 74 |
.byte 0 # NULL |
| 75 |
CU2_5_end: |
| 76 |
|
| 77 |
# The third unit's CU DIE uses a valid string index but the entry in the |
| 78 |
# string offsets table is invalid. |
| 79 |
|
| 80 |
# DWARF v5 CU header |
| 81 |
.long CU3_5_end-CU3_5_version # Length of Unit |
| 82 |
CU3_5_version: |
| 83 |
.short 5 # DWARF version number |
| 84 |
.byte 1 # DWARF Unit Type |
| 85 |
.byte 8 # Address Size (in bytes) |
| 86 |
.long .debug_abbrev # Offset Into Abbrev. Section |
| 87 |
# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. |
| 88 |
.byte 1 # Abbreviation code |
| 89 |
.byte 1 # Index of string for DW_AT_producer. |
| 90 |
.long str_comp_dir # Offset of debug line string for DW_AT_comp_dir |
| 91 |
.long .debug_str_offsets_base0 |
| 92 |
.byte 0 # NULL |
| 93 |
CU3_5_end: |
| 94 |
|
| 95 |
# The fourth unit's CU DIE has an invalid offset for the debug line string. |
| 96 |
|
| 97 |
# DWARF v5 CU header |
| 98 |
.long CU4_5_end-CU4_5_version # Length of Unit |
| 99 |
CU4_5_version: |
| 100 |
.short 5 # DWARF version number |
| 101 |
.byte 1 # DWARF Unit Type |
| 102 |
.byte 8 # Address Size (in bytes) |
| 103 |
.long .debug_abbrev # Offset Into Abbrev. Section |
| 104 |
# The compile-unit DIE, which has DW_AT_producer and DW_AT_str_offsets. |
| 105 |
.byte 1 # Abbreviation code |
| 106 |
.byte 0 # Index of string for DW_AT_producer. |
| 107 |
.long 99999 # Invalid offset of debug line string for DW_AT_comp_dir |
| 108 |
.long .debug_str_offsets_base0 |
| 109 |
.byte 0 # NULL |
| 110 |
CU4_5_end: |
| 111 |
|
| 112 |
# VERIFY-DAG: error: DW_FORM_strx used without a valid string offsets table: |
| 113 |
# VERIFY-DAG: error: DW_FORM_strx uses index 100, which is too large: |
| 114 |
# VERIFY-DAG: error: DW_FORM_strx uses index 1, but the referenced string offset |
| 115 |
# VERIFY-DAG-SAME: is beyond .debug_str bounds: |
| 116 |
# VERIFY-DAG: error: DW_FORM_line_strp offset 99999 is beyond .debug_line_str bounds |