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# RUN: llvm-dwarfdump -debug-rnglists %t.o | \ 7# RUN: FileCheck %s --check-prefix=RNGLISTS 8 9# Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format. 10# This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format. 11# We use very simplified compile unit dies. 12# There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges 13# attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using 14# DW_FORM_rnglistx. 15 16 .section .debug_abbrev,"",@progbits 17 .byte 0x01 # Abbrev code 18 .byte 0x11 # DW_TAG_compile_unit 19 .byte 0x00 # DW_CHILDREN_no 20 .byte 0x74 # DW_AT_rnglists_base 21 .byte 0x17 # DW_FORM_sec_offset 22 .byte 0x55 # DW_AT_ranges 23 .byte 0x17 # DW_FORM_sec_offset 24 .byte 0x00 # EOM(1) 25 .byte 0x00 # EOM(2) 26 .byte 0x02 # Abbrev code 27 .byte 0x11 # DW_TAG_compile_unit 28 .byte 0x00 # DW_CHILDREN_no 29 .byte 0x74 # DW_AT_rnglists_base 30 .byte 0x17 # DW_FORM_sec_offset 31 .byte 0x55 # DW_AT_ranges 32 .byte 0x23 # DW_FORM_rnglistx 33 .byte 0x00 # EOM(1) 34 .byte 0x00 # EOM(2) 35 .byte 0x00 # EOM(3) 36 37# The split CU uses DW_FORM_rnglistx (the only correct option). 38# There is no DW_AT_rnglists_base in split units. 39 .section .debug_abbrev.dwo,"e",@progbits 40 .byte 0x01 # Abbrev code 41 .byte 0x11 # DW_TAG_compile_unit 42 .byte 0x00 # DW_CHILDREN_no 43 .byte 0x55 # DW_AT_ranges 44 .byte 0x23 # DW_FORM_rnglistx 45 .byte 0x00 # EOM(1) 46 .byte 0x00 # EOM(2) 47 .byte 0x00 # EOM(3) 48 49 .section .debug_info,"",@progbits 50 .long 0xffffffff # DWARF64 mark 51 .quad CU1_5_64_end - CU1_5_64_version # Length of Unit 52CU1_5_64_version: 53 .short 5 # DWARF version number 54 .byte 1 # DWARF Unit Type 55 .byte 4 # Address Size (in bytes) 56 .quad .debug_abbrev # Offset Into Abbrev. Section 57# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 58 .byte 1 # Abbreviation code 59 .quad Rnglist_Table0_base # DW_AT_rnglists_base 60 .quad Rnglist_Table0_Rnglist0 # DW_AT_ranges 61CU1_5_64_end: 62 63 .long 0xffffffff # DWARF64 mark 64 .quad CU2_5_64_end - CU2_5_64_version # Length of Unit 65CU2_5_64_version: 66 .short 5 # DWARF version number 67 .byte 1 # DWARF Unit Type 68 .byte 4 # Address Size (in bytes) 69 .quad .debug_abbrev # Offset Into Abbrev. Section 70# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 71 .byte 2 # Abbreviation code 72 .quad Rnglist_Table0_base # DW_AT_rnglists_base 73 .uleb128 1 # DW_AT_ranges 74CU2_5_64_end: 75 76# A CU with an invalid DW_AT_rnglists_base attribute 77 .long 0xffffffff # DWARF64 mark 78 .quad CU3_5_64_end - CU3_5_64_version # Length of Unit 79CU3_5_64_version: 80 .short 5 # DWARF version number 81 .byte 1 # DWARF Unit Type 82 .byte 4 # Address Size (in bytes) 83 .quad .debug_abbrev # Offset Into Abbrev. Section 84# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 85 .byte 2 # Abbreviation code 86 .quad 0x8 # DW_AT_rnglists_base 87 .uleb128 0 # DW_AT_ranges 88CU3_5_64_end: 89 90# A CU DIE with an incorrect DW_AT_ranges attribute 91 .long 0xffffffff # DWARF64 mark 92 .quad CU4_5_64_end - CU4_5_64_version # Length of Unit 93CU4_5_64_version: 94 .short 5 # DWARF version number 95 .byte 1 # DWARF Unit Type 96 .byte 4 # Address Size (in bytes) 97 .quad .debug_abbrev # Offset Into Abbrev. Section 98# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 99 .byte 1 # Abbreviation code 100 .quad Rnglist_Table0_base # DW_AT_rnglists_base 101 .quad 4000 # DW_AT_ranges 102CU4_5_64_end: 103 104 .section .debug_info.dwo,"e",@progbits 105 106# DWARF v5 split CU header. 107 .long 0xffffffff # DWARF64 mark 108 .quad CU_split_5_64_end-CU_split_5_64_version # Length of Unit 109CU_split_5_64_version: 110 .short 5 # DWARF version number 111 .byte 5 # DWARF Unit Type 112 .byte 4 # Address Size (in bytes) 113 .quad 0 # Offset Into Abbrev Section 114 .quad 0xdeadbeefbaadf00d # DWO id 115# The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges. 116 .byte 1 # Abbreviation code 117 .uleb128 1 # DW_AT_ranges 118CU_split_5_64_end: 119 120 .section .debug_rnglists,"",@progbits 121# A rnglist table with 2 range lists. The first one uses DW_RLE_start_end 122# and DW_RLE_start_length. The second one uses DW_RLE_base_address and 123# DW_RLE_offset_pair. The range lists have entries in the offset table. 124 .long 0xffffffff # DWARF64 mark 125 .quad Rnglist_Table0_end - Rnglist_Table0 # table length 126Rnglist_Table0: 127 .short 5 # version 128 .byte 4 # address size 129 .byte 0 # segment selector size 130 .long 2 # offset entry count 131Rnglist_Table0_base: 132# 2 offset entries which can be used by DW_FORM_rnglistx. 133 .quad Rnglist_Table0_Rnglist0 - Rnglist_Table0_base 134 .quad Rnglist_Table0_Rnglist1 - Rnglist_Table0_base 135Rnglist_Table0_Rnglist0: 136 .byte 6 # DW_RLE_start_end 137 .long Range0_start 138 .long Range0_end 139 .byte 7 # DW_RLE_start_length 140 .long Range1_start 141 .uleb128 Range1_end - Range1_start 142 .byte 0 # DW_RLE_end_of_list 143Rnglist_Table0_Rnglist1: 144 .byte 5 # DW_RLE_base_address 145 .long Range0_start 146 .byte 4 # DW_RLE_offset_pair 147 .uleb128 Range1_start - Range0_start 148 .uleb128 Range1_end - Range0_start 149 .byte 0 # DW_RLE_end_of_list 150Rnglist_Table0_end: 151 152# A rnglist table for the split unit with an empty rangelist and one that 153# uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries 154# in the offset table. We use the empty range list so we can test 155# DW_FORM_rnglistx with an index other than 0. 156 .section .debug_rnglists.dwo,"e",@progbits 157 .long 0xffffffff # DWARF64 mark 158 .quad Rnglist_Table0_dwo_end - Rnglist_Table0_dwo # table length 159Rnglist_Table0_dwo: 160 .short 5 # version 161 .byte 4 # address size 162 .byte 0 # segment selector size 163 .long 2 # offset entry count 164Rnglist_Table0_base_dwo: 165# 2 offset entries which can be used by DW_FORM_rnglistx. 166 .quad Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo 167 .quad Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo 168Rnglist_Table0_Rnglist0_dwo: 169 .byte 0 # DW_RLE_start_end 170Rnglist_Table0_Rnglist1_dwo: 171 .byte 5 # DW_RLE_base_address 172 .long Range0_start - .text 173 .byte 4 # DW_RLE_offset_pair 174 .uleb128 Range1_start - Range0_start 175 .uleb128 Range1_end - Range0_start 176 .byte 0 # DW_RLE_end_of_list 177Rnglist_Table0_dwo_end: 178 179.text 180 .space 20 181Range0_start: # Range0: 0x14 - 0x1c 182 .space 10 183Range0_end: 184 .space 12 185Range1_start: # Range1: 0x2a - 0x34 186 .space 10 187Range1_end: 188 189# CHECK: .debug_info contents: 190# CHECK: Compile Unit: 191# CHECK-NOT: Compile Unit: 192# CHECK: DW_TAG_compile_unit 193# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000000000014) 194# CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x0000000000000024 195# CHECK-NEXT: [0x00000014, 0x0000001e) ".text" 196# CHECK-NEXT: [0x0000002a, 0x00000034) ".text") 197 198# CHECK: Compile Unit: 199# CHECK-NOT: Compile Unit: 200# CHECK: DW_TAG_compile_unit 201# CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000000000014) 202# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000034 203# CHECK-NEXT: [0x0000002a, 0x00000034) ".text") 204 205# CHECK: .debug_info.dwo contents: 206# CHECK: Compile Unit: 207# CHECK-NOT: contents: 208# CHECK: DW_TAG_compile_unit 209# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000025 210# CHECK-NEXT: [0x0000002a, 0x00000034)) 211 212#ERR: error: decoding address ranges: invalid range list offset 0x4000500000008 213#ERR: error: decoding address ranges: invalid range list offset 0xfa0 214 215# RNGLISTS: .debug_rnglists contents: 216# RNGLISTS: range list header: 217# RNGLISTS-SAME: length = 0x0000000000000031, 218# RNGLISTS-SAME: format = DWARF64, 219# RNGLISTS-SAME: version = 0x0005, 220# RNGLISTS-SAME: addr_size = 0x04, 221# RNGLISTS-SAME: seg_size = 0x00, 222# RNGLISTS-SAME: offset_entry_count = 0x00000002 223# RNGLISTS-NEXT: offsets: [ 224# RNGLISTS-NEXT: 0x0000000000000010 225# RNGLISTS-NEXT: 0x0000000000000020 226# RNGLISTS-NEXT: ] 227# RNGLISTS-NEXT: ranges: 228# RNGLISTS-NEXT: [0x00000014, 0x0000001e) 229# RNGLISTS-NEXT: [0x0000002a, 0x00000034) 230# RNGLISTS-NEXT: <End of list> 231# RNGLISTS-NEXT: [0x0000002a, 0x00000034) 232# RNGLISTS-NEXT: <End of list> 233 234# RNGLISTS: .debug_rnglists.dwo contents: 235# RNGLISTS: range list header: 236# RNGLISTS-SAME: length = 0x0000000000000022, 237# RNGLISTS-SAME: format = DWARF64, 238# RNGLISTS-SAME: version = 0x0005, 239# RNGLISTS-SAME: addr_size = 0x04, 240# RNGLISTS-SAME: seg_size = 0x00, 241# RNGLISTS-SAME: offset_entry_count = 0x00000002 242# RNGLISTS-NEXT: offsets: [ 243# RNGLISTS-NEXT: 0x0000000000000010 244# RNGLISTS-NEXT: 0x0000000000000011 245# RNGLISTS-NEXT: ] 246# RNGLISTS-NEXT: ranges: 247# RNGLISTS-NEXT: <End of list> 248# RNGLISTS-NEXT: [0x0000002a, 0x00000034) 249# RNGLISTS-NEXT: <End of list> 250