1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o 2# RUN: not llvm-dwarfdump -v %t.o 2>&1 | FileCheck %s 3# 4# Test object to verify that llvm-dwarfdump handles an invalid string offsets 5# table. 6# 7# A rudimentary abbrev section. 8 .section .debug_abbrev,"",@progbits 9 .byte 0x01 # Abbrev code 10 .byte 0x11 # DW_TAG_compile_unit 11 .byte 0x00 # DW_CHILDREN_no 12 .byte 0x72 # DW_AT_str_offsets_base 13 .byte 0x17 # DW_FORM_sec_offset 14 .byte 0x00 # EOM(1) 15 .byte 0x00 # EOM(2) 16 .byte 0x00 # EOM(3) 17 18# A rudimentary compile unit to convince dwarfdump that we are dealing with a 19# DWARF v5 string offsets table. 20 .section .debug_info,"",@progbits 21 22# DWARF v5 32 bit CU header. 23 .long CU1_end-CU1_begin # Length of Unit 24CU1_begin: 25 .short 5 # DWARF version number 26 .byte 1 # DWARF Unit Type 27 .byte 8 # Address Size (in bytes) 28 .long .debug_abbrev # Offset Into Abbrev. Section 29 .byte 1 # Abbreviation code: DW_TAG_compile_unit 30 .long 0 # DW_AT_str_offsets_base 31CU1_end: 32 33# DWARF v5 64 bit CU header. 34 .long 0xffffffff 35 .quad CU2_end-CU2_begin # Length of Unit 36CU2_begin: 37 .short 5 # DWARF version number 38 .byte 1 # DWARF Unit Type 39 .byte 8 # Address Size (in bytes) 40 .quad .debug_abbrev # Offset Into Abbrev. Section 41 .byte 1 # Abbreviation code: DW_TAG_compile_unit 42 .quad 0 # DW_AT_str_offsets_base 43CU2_end: 44 .long CU3_end-CU3_begin # Length of Unit 45CU3_begin: 46 .short 5 # DWARF version number 47 .byte 1 # DWARF Unit Type 48 .byte 8 # Address Size (in bytes) 49 .long .debug_abbrev # Offset Into Abbrev. Section 50 .byte 1 # Abbreviation code: DW_TAG_compile_unit 51 .quad .str_off0 # DW_AT_str_offsets_base 52CU3_end: 53 .long CU4_end-CU4_begin # Length of Unit 54CU4_begin: 55 .short 5 # DWARF version number 56 .byte 1 # DWARF Unit Type 57 .byte 8 # Address Size (in bytes) 58 .long .debug_abbrev # Offset Into Abbrev. Section 59 .byte 1 # Abbreviation code: DW_TAG_compile_unit 60 .quad .str_off1 # DW_AT_str_offsets_base 61CU4_end: 62 .long CU5_end-CU5_begin # Length of Unit 63CU5_begin: 64 .short 5 # DWARF version number 65 .byte 1 # DWARF Unit Type 66 .byte 8 # Address Size (in bytes) 67 .long .debug_abbrev # Offset Into Abbrev. Section 68 .byte 1 # Abbreviation code: DW_TAG_compile_unit 69 .long .str_off2_begin # DW_AT_str_offsets_base 70CU5_end: 71 .long CU6_end-CU6_begin # Length of Unit 72CU6_begin: 73 .short 5 # DWARF version number 74 .byte 1 # DWARF Unit Type 75 .byte 8 # Address Size (in bytes) 76 .long .debug_abbrev # Offset Into Abbrev. Section 77 .byte 1 # Abbreviation code: DW_TAG_compile_unit 78 .long .str_off3_begin # DW_AT_str_offsets_base 79CU6_end: 80 .long 0xffffffff 81 .quad CU7_end-CU7_begin # Length of Unit 82CU7_begin: 83 .short 5 # DWARF version number 84 .byte 1 # DWARF Unit Type 85 .byte 8 # Address Size (in bytes) 86 .quad .debug_abbrev # Offset Into Abbrev. Section 87 .byte 1 # Abbreviation code: DW_TAG_compile_unit 88 .quad .str_off4_begin # DW_AT_str_offsets_base 89CU7_end: 90 .long CU8_end-CU8_begin # Length of Unit 91CU8_begin: 92 .short 5 # DWARF version number 93 .byte 1 # DWARF Unit Type 94 .byte 8 # Address Size (in bytes) 95 .long .debug_abbrev # Offset Into Abbrev. Section 96 .byte 1 # Abbreviation code: DW_TAG_compile_unit 97 .long .str_off_end+16 # DW_AT_str_offsets_base 98CU8_end: 99 .long 0xffffffff 100 .quad CU9_end-CU9_begin # Length of Unit 101CU9_begin: 102 .short 5 # DWARF version number 103 .byte 1 # DWARF Unit Type 104 .byte 8 # Address Size (in bytes) 105 .quad .debug_abbrev # Offset Into Abbrev. Section 106 .byte 1 # Abbreviation code: DW_TAG_compile_unit 107 .quad .str_off_end+8 # DW_AT_str_offsets_base 108CU9_end: 109 110 .section .debug_str_offsets,"",@progbits 111# Invalid length 112 .long 0xfffffff4 113 .short 5 # DWARF version 114 .short 0 # Padding 115.str_off0: 116 .long 0 117# Length beyond section bounds 118 .long .str_off_end-.str_off1+8 119 .short 5 # DWARF version 120 .short 0 # Padding 121.str_off1: 122 .long 0 123# Length intrudes on following unit 124 .long .str_off2_end-.str_off2_begin+8 125 .short 5 # DWARF version 126 .short 0 # Padding 127.str_off2_begin: 128 .long 0 129.str_off2_end: 130# Plain contribution, no errors here 131 .long .str_off3_end-.str_off3_begin 132 .short 5 # DWARF version 133 .short 0 # Padding 134.str_off3_begin: 135 .long 0 136.str_off3_end: 137# 32 bit contribution referenced from a 64 bit unit 138 .long .str_off4_end-.str_off4_begin 139 .short 5 # DWARF version 140 .short 0 # Padding 141.str_off4_begin: 142 .long 0 143.str_off4_end: 144.str_off_end: 145 146 147# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: insufficient space for 32 bit header prefix 148# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: insufficient space for 64 bit header prefix 149# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: invalid length 150# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: length exceeds section size 151# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: 32 bit contribution referenced from a 64 bit unit 152# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: section offset exceeds section size 153# CHECK: error: invalid reference to or invalid content in .debug_str_offsets[.dwo]: section offset exceeds section size 154# CHECK: error: overlapping contributions to string offsets table in section .debug_str_offsets. 155