1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o 3# RUN: ld.lld --gdb-index %t1.o -o %t 2>&1 | FileCheck --check-prefix=LLD %s 4# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s 5 6# FIXME: Remove this once lld correctly returns non-zero on errors like this 7# There's no other behavior to test hidden behind this error - lld only parses 8# the CU for the address ranges, it doesn't need to decode any strings. 9# LLD-NOT: error: 10 11## The code contains DWARF v5 sections .debug_rnglists and .debug_addr. 12## Check we are able to build the correct address 13## area using address range lists. 14 15# CHECK: .gdb_index contents: 16# CHECK: Address area offset = 0x28, has 2 entries: 17# CHECK-NEXT: Low/High address = [0x201120, 0x201121) (Size: 0x1), CU id = 0 18# CHECK-NEXT: Low/High address = [0x201121, 0x201123) (Size: 0x2), CU id = 0 19 20.text 21.section .text._Z3zedv,"ax",@progbits 22.Lfunc_begin0: 23 retq 24.Lfunc_end0: 25 26.section .text.main,"ax",@progbits 27.Lfunc_begin1: 28 retq 29 retq 30.Lfunc_end1: 31 32.section .debug_str_offsets,"",@progbits 33.long 32 34.short 5 35.short 0 36.Lstr_offsets_base0: 37 .long .Linfo_string0 38 .long .Linfo_string0 39 .long .Linfo_string0 40 .long .Linfo_string0 41 .long .Linfo_string0 42 .long .Linfo_string0 43 .long .Linfo_string0 44 45.section .debug_str,"MS",@progbits,1 46.Linfo_string0: 47 .asciz "stub" 48 49.section .debug_abbrev,"",@progbits 50 .byte 1 # Abbreviation Code 51 .byte 17 # DW_TAG_compile_unit 52 .byte 1 # DW_CHILDREN_yes 53 .byte 37 # DW_AT_producer 54 .byte 37 # DW_FORM_strx1 55 .byte 19 # DW_AT_language 56 .byte 5 # DW_FORM_data2 57 .byte 3 # DW_AT_name 58 .byte 37 # DW_FORM_strx1 59 .byte 114 # DW_AT_str_offsets_base 60 .byte 23 # DW_FORM_sec_offset 61 .byte 16 # DW_AT_stmt_list 62 .byte 23 # DW_FORM_sec_offset 63 .byte 27 # DW_AT_comp_dir 64 .byte 37 # DW_FORM_strx1 65 .byte 115 # DW_AT_addr_base 66 .byte 23 # DW_FORM_sec_offset 67 .byte 17 # DW_AT_low_pc 68 .byte 1 # DW_FORM_addr 69 .byte 85 # DW_AT_ranges 70 .byte 35 # DW_FORM_rnglistx 71 .byte 116 # DW_AT_rnglists_base 72 .byte 23 # DW_FORM_sec_offset 73 .byte 0 # EOM(1) 74 .byte 0 # EOM(2) 75 .byte 2 # Abbreviation Code 76 .byte 46 # DW_TAG_subprogram 77 .byte 0 # DW_CHILDREN_no 78 .byte 17 # DW_AT_low_pc 79 .byte 27 # DW_FORM_addrx 80 .byte 18 # DW_AT_high_pc 81 .byte 6 # DW_FORM_data4 82 .byte 64 # DW_AT_frame_base 83 .byte 24 # DW_FORM_exprloc 84 .byte 110 # DW_AT_linkage_name 85 .byte 37 # DW_FORM_strx1 86 .byte 3 # DW_AT_name 87 .byte 37 # DW_FORM_strx1 88 .byte 58 # DW_AT_decl_file 89 .byte 11 # DW_FORM_data1 90 .byte 59 # DW_AT_decl_line 91 .byte 11 # DW_FORM_data1 92 .byte 73 # DW_AT_type 93 .byte 19 # DW_FORM_ref4 94 .byte 63 # DW_AT_external 95 .byte 25 # DW_FORM_flag_present 96 .byte 0 # EOM(1) 97 .byte 0 # EOM(2) 98 .byte 3 # Abbreviation Code 99 .byte 46 # DW_TAG_subprogram 100 .byte 0 # DW_CHILDREN_no 101 .byte 17 # DW_AT_low_pc 102 .byte 27 # DW_FORM_addrx 103 .byte 18 # DW_AT_high_pc 104 .byte 6 # DW_FORM_data4 105 .byte 64 # DW_AT_frame_base 106 .byte 24 # DW_FORM_exprloc 107 .byte 3 # DW_AT_name 108 .byte 37 # DW_FORM_strx1 109 .byte 58 # DW_AT_decl_file 110 .byte 11 # DW_FORM_data1 111 .byte 59 # DW_AT_decl_line 112 .byte 11 # DW_FORM_data1 113 .byte 73 # DW_AT_type 114 .byte 19 # DW_FORM_ref4 115 .byte 63 # DW_AT_external 116 .byte 25 # DW_FORM_flag_present 117 .byte 0 # EOM(1) 118 .byte 0 # EOM(2) 119 .byte 4 # Abbreviation Code 120 .byte 36 # DW_TAG_base_type 121 .byte 0 # DW_CHILDREN_no 122 .byte 3 # DW_AT_name 123 .byte 37 # DW_FORM_strx1 124 .byte 62 # DW_AT_encoding 125 .byte 11 # DW_FORM_data1 126 .byte 11 # DW_AT_byte_size 127 .byte 11 # DW_FORM_data1 128 .byte 0 # EOM(1) 129 .byte 0 # EOM(2) 130 .byte 0 # EOM(3) 131 132.section .debug_info,"",@progbits 133.Lcu_begin0: 134 .long 75 # Length of Unit 135 .short 5 # DWARF version number 136 .byte 1 # DWARF Unit Type 137 .byte 8 # Address Size (in bytes) 138 .long .debug_abbrev # Offset Into Abbrev. Section 139 140 .byte 1 # Abbrev [1] 0xc:0x43 DW_TAG_compile_unit 141 .byte 0 # DW_AT_producer 142 .short 4 # DW_AT_language 143 .byte 1 # DW_AT_name 144 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base 145 .long 0 # DW_AT_stmt_list 146 .byte 2 # DW_AT_comp_dir 147 .long .Laddr_table_base0 # DW_AT_addr_base 148 .quad 0 # DW_AT_low_pc 149 .byte 0 # DW_AT_ranges 150 .long .Lrnglists_table_base0 # DW_AT_rnglists_base 151 152 .byte 2 # Abbrev [2] 0x2b:0x10 DW_TAG_subprogram 153 .byte 0 # DW_AT_low_pc 154 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 155 .byte 1 # DW_AT_frame_base 156 .byte 86 157 .byte 3 # DW_AT_linkage_name 158 .byte 4 # DW_AT_name 159 .byte 1 # DW_AT_decl_file 160 .byte 1 # DW_AT_decl_line 161 .long 74 # DW_AT_type 162 # DW_AT_external 163 164 .byte 3 # Abbrev [3] 0x3b:0xf DW_TAG_subprogram 165 .byte 1 # DW_AT_low_pc 166 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc 167 .byte 1 # DW_AT_frame_base 168 .byte 86 169 .byte 6 # DW_AT_name 170 .byte 1 # DW_AT_decl_file 171 .byte 5 # DW_AT_decl_line 172 .long 74 # DW_AT_type 173 # DW_AT_external 174 175 .byte 4 # Abbrev [4] 0x4a:0x4 DW_TAG_base_type 176 .byte 5 # DW_AT_name 177 .byte 5 # DW_AT_encoding 178 .byte 4 # DW_AT_byte_size 179 .byte 0 # End Of Children Mark 180 181.section .debug_rnglists,"",@progbits 182.long .Ldebug_rnglist_table_end0-.Ldebug_rnglist_table_start0 # Length 183.Ldebug_rnglist_table_start0: 184 .short 5 # Version 185 .byte 8 # Address size 186 .byte 0 # Segment selector size 187 .long 1 # Offset entry count 188.Lrnglists_table_base0: 189 .long .Ldebug_ranges0-.Lrnglists_table_base0 190.Ldebug_ranges0: 191 .byte 3 # DW_RLE_startx_length 192 .byte 0 # start index 193 .uleb128 .Lfunc_end0-.Lfunc_begin0 # length 194 .byte 3 # DW_RLE_startx_length 195 .byte 1 # start index 196 .uleb128 .Lfunc_end1-.Lfunc_begin1 # length 197 .byte 0 # DW_RLE_end_of_list 198.Ldebug_rnglist_table_end0: 199 200.section .debug_addr,"",@progbits 201 .long 20 202 .short 5 203 .byte 8 204 .byte 0 205.Laddr_table_base0: 206 .quad .Lfunc_begin0 207 .quad .Lfunc_begin1 208