1# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o 2# RUN: not llvm-dwarfdump -v -debug-info %t.o 2> %t.err | FileCheck %s 3# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR --implicit-check-not=error 4# RUN: not llvm-dwarfdump -lookup 10 %t.o 2> %t2.err 5# RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR --implicit-check-not=error 6 7# Test object to verify dwarfdump handles v5 range lists. 8# We use very simplified compile unit dies. 9# There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges 10# attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using 11# DW_FORM_rnglistx. 12 13 .section .debug_abbrev,"",@progbits 14 .byte 0x01 # Abbrev code 15 .byte 0x11 # DW_TAG_compile_unit 16 .byte 0x00 # DW_CHILDREN_no 17 .byte 0x74 # DW_AT_rnglists_base 18 .byte 0x17 # DW_FORM_sec_offset 19 .byte 0x55 # DW_AT_ranges 20 .byte 0x17 # DW_FORM_sec_offset 21 .byte 0x00 # EOM(1) 22 .byte 0x00 # EOM(2) 23 .byte 0x02 # Abbrev code 24 .byte 0x11 # DW_TAG_compile_unit 25 .byte 0x00 # DW_CHILDREN_no 26 .byte 0x74 # DW_AT_rnglists_base 27 .byte 0x17 # DW_FORM_sec_offset 28 .byte 0x55 # DW_AT_ranges 29 .byte 0x23 # DW_FORM_rnglistx 30 .byte 0x00 # EOM(1) 31 .byte 0x00 # EOM(2) 32 .byte 0x00 # EOM(3) 33 34# The split CU uses DW_FORM_rnglistx (the only correct option). 35# There is no DW_AT_rnglists_base in split units. 36 .section .debug_abbrev.dwo,"e",@progbits 37 .byte 0x01 # Abbrev code 38 .byte 0x11 # DW_TAG_compile_unit 39 .byte 0x00 # DW_CHILDREN_no 40 .byte 0x55 # DW_AT_ranges 41 .byte 0x23 # DW_FORM_rnglistx 42 .byte 0x00 # EOM(1) 43 .byte 0x00 # EOM(2) 44 .byte 0x00 # EOM(3) 45 46 .section .debug_info,"",@progbits 47 .long CU1_5_end-CU1_5_version # Length of Unit 48CU1_5_version: 49 .short 5 # DWARF version number 50 .byte 1 # DWARF Unit Type 51 .byte 4 # Address Size (in bytes) 52 .long .debug_abbrev # Offset Into Abbrev. Section 53# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 54 .byte 1 # Abbreviation code 55 .long Rnglist_Table0_base # DW_AT_rnglists_base 56 .long Rnglist_Table0_Rnglist0 # DW_AT_ranges 57 .byte 0 # NULL 58 .byte 0 # NULL 59CU1_5_end: 60 61 .long CU2_5_end-CU2_5_version # Length of Unit 62CU2_5_version: 63 .short 5 # DWARF version number 64 .byte 1 # DWARF Unit Type 65 .byte 4 # Address Size (in bytes) 66 .long .debug_abbrev # Offset Into Abbrev. Section 67# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 68 .byte 2 # Abbreviation code 69 .long Rnglist_Table0_base # DW_AT_rnglists_base 70 .uleb128 1 # DW_AT_ranges 71 .byte 0 # NULL 72CU2_5_end: 73# A CU with an invalid DW_AT_rnglists_base attribute 74 .long CU3_5_end-CU3_5_version # Length of Unit 75CU3_5_version: 76 .short 5 # DWARF version number 77 .byte 1 # DWARF Unit Type 78 .byte 4 # Address Size (in bytes) 79 .long .debug_abbrev # Offset Into Abbrev. Section 80# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 81 .byte 2 # Abbreviation code 82 .long 0x8 # DW_AT_rnglists_base 83 .long 0 # DW_AT_ranges 84 .byte 0 # NULL 85CU3_5_end: 86# A CU DIE with an incorrect DW_AT_ranges attribute 87 .long CU4_5_end-CU4_5_version # Length of Unit 88CU4_5_version: 89 .short 5 # DWARF version number 90 .byte 1 # DWARF Unit Type 91 .byte 4 # Address Size (in bytes) 92 .long .debug_abbrev # Offset Into Abbrev. Section 93# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 94 .byte 1 # Abbreviation code 95 .long Rnglist_Table0_base # DW_AT_rnglists_base 96 .long 4000 # DW_AT_ranges 97 .byte 0 # NULL 98CU4_5_end: 99 100 .section .debug_info.dwo,"e",@progbits 101 102# DWARF v5 split CU header. 103 .long CU_split_5_end-CU_split_5_version # Length of Unit 104CU_split_5_version: 105 .short 5 # DWARF version number 106 .byte 5 # DWARF Unit Type 107 .byte 4 # Address Size (in bytes) 108 .long 0 # Offset Into Abbrev Section 109 .quad 0xdeadbeefbaadf00d # DWO id 110# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 111 .byte 1 # Abbreviation code 112 .uleb128 1 # DW_AT_ranges 113 .byte 0 # NULL 114CU_split_5_end: 115 116 .section .debug_rnglists,"",@progbits 117# A rnglist table with 2 range lists. The first one uses DW_RLE_start_end 118# and DW_RLE_start_length. The second one uses DW_RLE_base_address and 119# DW_RLE_offset_pair. The range lists have entries in the offset table. 120 .long Rnglist_Table0_end - Rnglist_Table0 # table length 121Rnglist_Table0: 122 .short 5 # version 123 .byte 4 # address size 124 .byte 0 # segment selector size 125 .long 2 # offset entry count 126Rnglist_Table0_base: 127# 2 offset entries which can be used by DW_FORM_rnglistx. 128 .long Rnglist_Table0_Rnglist0 - Rnglist_Table0_base 129 .long Rnglist_Table0_Rnglist1 - Rnglist_Table0_base 130Rnglist_Table0_Rnglist0: 131 .byte 6 # DW_RLE_start_end 132 .long Range0_start 133 .long Range0_end 134 .byte 7 # DW_RLE_start_length 135 .long Range1_start 136 .uleb128 Range1_end - Range1_start 137 .byte 0 # DW_RLE_end_of_list 138Rnglist_Table0_Rnglist1: 139 .byte 5 # DW_RLE_base_address 140 .long Range0_start 141 .byte 4 # DW_RLE_offset_pair 142 .uleb128 Range1_start - Range0_start 143 .uleb128 Range1_end - Range0_start 144 .byte 0 # DW_RLE_end_of_list 145Rnglist_Table0_end: 146 147# A rnglist table for the split unit with an empty rangelist and one that 148# uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries 149# in the offset table. We use the empty range list so we can test 150# DW_FORM_rnglistx with an index other than 0. 151 .section .debug_rnglists.dwo,"e",@progbits 152 .long Rnglist_Table0_dwo_end - Rnglist_Table0_dwo # table length 153Rnglist_Table0_dwo: 154 .short 5 # version 155 .byte 4 # address size 156 .byte 0 # segment selector size 157 .long 2 # offset entry count 158Rnglist_Table0_base_dwo: 159# 2 offset entries which can be used by DW_FORM_rnglistx. 160 .long Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo 161 .long Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo 162Rnglist_Table0_Rnglist0_dwo: 163 .byte 0 # DW_RLE_start_end 164Rnglist_Table0_Rnglist1_dwo: 165 .byte 5 # DW_RLE_base_address 166 .long Range0_start - .text 167 .byte 4 # DW_RLE_offset_pair 168 .uleb128 Range1_start - Range0_start 169 .uleb128 Range1_end - Range0_start 170 .byte 0 # DW_RLE_end_of_list 171Rnglist_Table0_dwo_end: 172 173.text 174 .space 20 175Range0_start: # Range0: 0x14 - 0x1c 176 .space 10 177Range0_end: 178 .space 12 179Range1_start: # Range1: 0x2a - 0x34 180 .space 10 181Range1_end: 182 183# CHECK: .debug_info contents: 184# CHECK: Compile Unit: 185# CHECK-NOT: Compile Unit: 186# CHECK: DW_TAG_compile_unit 187# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c) 188# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000014 189# CHECK-NEXT: [0x00000014, 0x0000001e) ".text" 190# CHECK-NEXT: [0x0000002a, 0x00000034) ".text") 191 192# CHECK: Compile Unit: 193# CHECK-NOT: Compile Unit: 194# CHECK: DW_TAG_compile_unit 195# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c) 196# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000024 197# CHECK-NEXT: [0x0000002a, 0x00000034) ".text") 198 199# CHECK: .debug_info.dwo contents: 200# CHECK: Compile Unit: 201# CHECK-NOT: contents: 202# CHECK: DW_TAG_compile_unit 203# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000015 204# CHECK-NEXT: [0x0000002a, 0x00000034)) 205 206#ERR: error: decoding address ranges: invalid range list offset 0xfa0 207