1# REQUIRES: system-linux 2 3# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o 4# RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q 5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections 6# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s 7# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt 8# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt 9# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s 10 11# This tests checks that re-writing of .debug_loclists is handled correctly. 12 13# PRECHECK: version = 0x0005 14# PRECHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c) 15# PRECHECK-EMPTY: 16# PRECHECK: DW_TAG_variable 17# PRECHECK: DW_AT_location [DW_FORM_loclistx] 18# PRECHECK-SAME: indexed (0x0) 19# PRECHECK-SAME: loclist = 0x00000010 20 21# POSTCHECK: Addrs: [ 22# POSTCHECK-NEXT: 0x 23# POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]] 24# POSTCHECK-NEXT: 0x 25# POSTCHECK-NEXT: 0x[[#%.16x,ADDR2:]] 26# POSTCHECK: version = 0x0005 27# POSTCHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c) 28# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c) 29# POSTCHECK: DW_TAG_variable 30# POSTCHECK: DW_AT_location [DW_FORM_loclistx] 31# POSTCHECK-SAME: indexed (0x0) 32# POSTCHECK-SAME: loclist = 0x00000010 33# POSTCHECK-NEXT: [0x[[#ADDR]] 34# POSTCHECK-SAME: 0x[[#ADDR + 3]] 35# POSTCHECK-NEXT: [0x[[#ADDR2]] 36# POSTCHECK-SAME: 0x[[#ADDR2 + 1]] 37 38# clang++ main.cpp -g -O2 -S 39# void use(int * x) { 40# *x += 4; 41# } 42# 43# int main(int argc, char *argv[]) { 44# int x = argc; 45# use(&x); 46# return x; 47# } 48 49 .text 50 .file "main.cpp" 51 .globl _Z3usePi # -- Begin function _Z3usePi 52 .p2align 4, 0x90 53 .type _Z3usePi,@function 54_Z3usePi: # @_Z3usePi 55.Lfunc_begin0: 56 .file 0 "testLocList" "main.cpp" md5 0x95a77c95663d823a6228bf928825e8c7 57 .loc 0 1 0 # main.cpp:1:0 58 .cfi_startproc 59# %bb.0: # %entry 60 #DEBUG_VALUE: use:x <- $rdi 61 .loc 0 2 4 prologue_end # main.cpp:2:4 62 addl $4, (%rdi) 63 .loc 0 3 1 # main.cpp:3:1 64 retq 65.Ltmp0: 66.Lfunc_end0: 67 .size _Z3usePi, .Lfunc_end0-_Z3usePi 68 .cfi_endproc 69 # -- End function 70 .globl main # -- Begin function main 71 .p2align 4, 0x90 72 .type main,@function 73main: # @main 74.Lfunc_begin1: 75 .loc 0 5 0 # main.cpp:5:0 76 .cfi_startproc 77# %bb.0: # %entry 78 #DEBUG_VALUE: main:argc <- $edi 79 #DEBUG_VALUE: main:argv <- $rsi 80 #DEBUG_VALUE: main:x <- $edi 81 # kill: def $edi killed $edi def $rdi 82 #DEBUG_VALUE: use:x <- undef 83 .loc 0 2 4 prologue_end # main.cpp:2:4 84 leal 4(%rdi), %eax 85.Ltmp1: 86 #DEBUG_VALUE: main:x <- $eax 87 .loc 0 8 4 # main.cpp:8:4 88 retq 89.Ltmp2: 90.Lfunc_end1: 91 .size main, .Lfunc_end1-main 92 .cfi_endproc 93 # -- End function 94 .section .debug_loclists,"",@progbits 95 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length 96.Ldebug_list_header_start0: 97 .short 5 # Version 98 .byte 8 # Address size 99 .byte 0 # Segment selector size 100 .long 1 # Offset entry count 101.Lloclists_table_base0: 102 .long .Ldebug_loc0-.Lloclists_table_base0 103.Ldebug_loc0: 104 .byte 4 # DW_LLE_offset_pair 105 .uleb128 .Lfunc_begin1-.Lfunc_begin0 # starting offset 106 .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset 107 .byte 1 # Loc expr size 108 .byte 85 # super-register DW_OP_reg5 109 .byte 4 # DW_LLE_offset_pair 110 .uleb128 .Ltmp1-.Lfunc_begin0 # starting offset 111 .uleb128 .Lfunc_end1-.Lfunc_begin0 # ending offset 112 .byte 1 # Loc expr size 113 .byte 80 # super-register DW_OP_reg0 114 .byte 0 # DW_LLE_end_of_list 115.Ldebug_list_header_end0: 116 .section .debug_abbrev,"",@progbits 117 .byte 1 # Abbreviation Code 118 .byte 17 # DW_TAG_compile_unit 119 .byte 1 # DW_CHILDREN_yes 120 .byte 37 # DW_AT_producer 121 .byte 37 # DW_FORM_strx1 122 .byte 19 # DW_AT_language 123 .byte 5 # DW_FORM_data2 124 .byte 3 # DW_AT_name 125 .byte 37 # DW_FORM_strx1 126 .byte 114 # DW_AT_str_offsets_base 127 .byte 23 # DW_FORM_sec_offset 128 .byte 16 # DW_AT_stmt_list 129 .byte 23 # DW_FORM_sec_offset 130 .byte 27 # DW_AT_comp_dir 131 .byte 37 # DW_FORM_strx1 132 .byte 17 # DW_AT_low_pc 133 .byte 27 # DW_FORM_addrx 134 .byte 18 # DW_AT_high_pc 135 .byte 6 # DW_FORM_data4 136 .byte 115 # DW_AT_addr_base 137 .byte 23 # DW_FORM_sec_offset 138 .ascii "\214\001" # DW_AT_loclists_base 139 .byte 23 # DW_FORM_sec_offset 140 .byte 0 # EOM(1) 141 .byte 0 # EOM(2) 142 .byte 2 # Abbreviation Code 143 .byte 46 # DW_TAG_subprogram 144 .byte 1 # DW_CHILDREN_yes 145 .byte 17 # DW_AT_low_pc 146 .byte 27 # DW_FORM_addrx 147 .byte 18 # DW_AT_high_pc 148 .byte 6 # DW_FORM_data4 149 .byte 64 # DW_AT_frame_base 150 .byte 24 # DW_FORM_exprloc 151 .byte 122 # DW_AT_call_all_calls 152 .byte 25 # DW_FORM_flag_present 153 .byte 49 # DW_AT_abstract_origin 154 .byte 19 # DW_FORM_ref4 155 .byte 0 # EOM(1) 156 .byte 0 # EOM(2) 157 .byte 3 # Abbreviation Code 158 .byte 5 # DW_TAG_formal_parameter 159 .byte 0 # DW_CHILDREN_no 160 .byte 2 # DW_AT_location 161 .byte 24 # DW_FORM_exprloc 162 .byte 49 # DW_AT_abstract_origin 163 .byte 19 # DW_FORM_ref4 164 .byte 0 # EOM(1) 165 .byte 0 # EOM(2) 166 .byte 4 # Abbreviation Code 167 .byte 46 # DW_TAG_subprogram 168 .byte 1 # DW_CHILDREN_yes 169 .byte 110 # DW_AT_linkage_name 170 .byte 37 # DW_FORM_strx1 171 .byte 3 # DW_AT_name 172 .byte 37 # DW_FORM_strx1 173 .byte 58 # DW_AT_decl_file 174 .byte 11 # DW_FORM_data1 175 .byte 59 # DW_AT_decl_line 176 .byte 11 # DW_FORM_data1 177 .byte 63 # DW_AT_external 178 .byte 25 # DW_FORM_flag_present 179 .byte 32 # DW_AT_inline 180 .byte 33 # DW_FORM_implicit_const 181 .byte 1 182 .byte 0 # EOM(1) 183 .byte 0 # EOM(2) 184 .byte 5 # Abbreviation Code 185 .byte 5 # DW_TAG_formal_parameter 186 .byte 0 # DW_CHILDREN_no 187 .byte 3 # DW_AT_name 188 .byte 37 # DW_FORM_strx1 189 .byte 58 # DW_AT_decl_file 190 .byte 11 # DW_FORM_data1 191 .byte 59 # DW_AT_decl_line 192 .byte 11 # DW_FORM_data1 193 .byte 73 # DW_AT_type 194 .byte 19 # DW_FORM_ref4 195 .byte 0 # EOM(1) 196 .byte 0 # EOM(2) 197 .byte 6 # Abbreviation Code 198 .byte 15 # DW_TAG_pointer_type 199 .byte 0 # DW_CHILDREN_no 200 .byte 73 # DW_AT_type 201 .byte 19 # DW_FORM_ref4 202 .byte 0 # EOM(1) 203 .byte 0 # EOM(2) 204 .byte 7 # Abbreviation Code 205 .byte 36 # DW_TAG_base_type 206 .byte 0 # DW_CHILDREN_no 207 .byte 3 # DW_AT_name 208 .byte 37 # DW_FORM_strx1 209 .byte 62 # DW_AT_encoding 210 .byte 11 # DW_FORM_data1 211 .byte 11 # DW_AT_byte_size 212 .byte 11 # DW_FORM_data1 213 .byte 0 # EOM(1) 214 .byte 0 # EOM(2) 215 .byte 8 # Abbreviation Code 216 .byte 46 # DW_TAG_subprogram 217 .byte 1 # DW_CHILDREN_yes 218 .byte 17 # DW_AT_low_pc 219 .byte 27 # DW_FORM_addrx 220 .byte 18 # DW_AT_high_pc 221 .byte 6 # DW_FORM_data4 222 .byte 64 # DW_AT_frame_base 223 .byte 24 # DW_FORM_exprloc 224 .byte 122 # DW_AT_call_all_calls 225 .byte 25 # DW_FORM_flag_present 226 .byte 3 # DW_AT_name 227 .byte 37 # DW_FORM_strx1 228 .byte 58 # DW_AT_decl_file 229 .byte 11 # DW_FORM_data1 230 .byte 59 # DW_AT_decl_line 231 .byte 11 # DW_FORM_data1 232 .byte 73 # DW_AT_type 233 .byte 19 # DW_FORM_ref4 234 .byte 63 # DW_AT_external 235 .byte 25 # DW_FORM_flag_present 236 .byte 0 # EOM(1) 237 .byte 0 # EOM(2) 238 .byte 9 # Abbreviation Code 239 .byte 5 # DW_TAG_formal_parameter 240 .byte 0 # DW_CHILDREN_no 241 .byte 2 # DW_AT_location 242 .byte 24 # DW_FORM_exprloc 243 .byte 3 # DW_AT_name 244 .byte 37 # DW_FORM_strx1 245 .byte 58 # DW_AT_decl_file 246 .byte 11 # DW_FORM_data1 247 .byte 59 # DW_AT_decl_line 248 .byte 11 # DW_FORM_data1 249 .byte 73 # DW_AT_type 250 .byte 19 # DW_FORM_ref4 251 .byte 0 # EOM(1) 252 .byte 0 # EOM(2) 253 .byte 10 # Abbreviation Code 254 .byte 52 # DW_TAG_variable 255 .byte 0 # DW_CHILDREN_no 256 .byte 2 # DW_AT_location 257 .byte 34 # DW_FORM_loclistx 258 .byte 3 # DW_AT_name 259 .byte 37 # DW_FORM_strx1 260 .byte 58 # DW_AT_decl_file 261 .byte 11 # DW_FORM_data1 262 .byte 59 # DW_AT_decl_line 263 .byte 11 # DW_FORM_data1 264 .byte 73 # DW_AT_type 265 .byte 19 # DW_FORM_ref4 266 .byte 0 # EOM(1) 267 .byte 0 # EOM(2) 268 .byte 11 # Abbreviation Code 269 .byte 29 # DW_TAG_inlined_subroutine 270 .byte 0 # DW_CHILDREN_no 271 .byte 49 # DW_AT_abstract_origin 272 .byte 19 # DW_FORM_ref4 273 .byte 17 # DW_AT_low_pc 274 .byte 27 # DW_FORM_addrx 275 .byte 18 # DW_AT_high_pc 276 .byte 6 # DW_FORM_data4 277 .byte 88 # DW_AT_call_file 278 .byte 11 # DW_FORM_data1 279 .byte 89 # DW_AT_call_line 280 .byte 11 # DW_FORM_data1 281 .byte 87 # DW_AT_call_column 282 .byte 11 # DW_FORM_data1 283 .byte 0 # EOM(1) 284 .byte 0 # EOM(2) 285 .byte 0 # EOM(3) 286 .section .debug_info,"",@progbits 287.Lcu_begin0: 288 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 289.Ldebug_info_start0: 290 .short 5 # DWARF version number 291 .byte 1 # DWARF Unit Type 292 .byte 8 # Address Size (in bytes) 293 .long .debug_abbrev # Offset Into Abbrev. Section 294 .byte 1 # Abbrev [1] 0xc:0x8f DW_TAG_compile_unit 295 .byte 0 # DW_AT_producer 296 .short 33 # DW_AT_language 297 .byte 1 # DW_AT_name 298 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base 299 .long .Lline_table_start0 # DW_AT_stmt_list 300 .byte 2 # DW_AT_comp_dir 301 .byte 0 # DW_AT_low_pc 302 .long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc 303 .long .Laddr_table_base0 # DW_AT_addr_base 304 .long .Lloclists_table_base0 # DW_AT_loclists_base 305 .byte 2 # Abbrev [2] 0x27:0x14 DW_TAG_subprogram 306 .byte 0 # DW_AT_low_pc 307 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 308 .byte 1 # DW_AT_frame_base 309 .byte 87 310 # DW_AT_call_all_calls 311 .long 59 # DW_AT_abstract_origin 312 .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_formal_parameter 313 .byte 1 # DW_AT_location 314 .byte 85 315 .long 64 # DW_AT_abstract_origin 316 .byte 0 # End Of Children Mark 317 .byte 4 # Abbrev [4] 0x3b:0xe DW_TAG_subprogram 318 .byte 3 # DW_AT_linkage_name 319 .byte 4 # DW_AT_name 320 .byte 0 # DW_AT_decl_file 321 .byte 1 # DW_AT_decl_line 322 # DW_AT_external 323 # DW_AT_inline 324 .byte 5 # Abbrev [5] 0x40:0x8 DW_TAG_formal_parameter 325 .byte 5 # DW_AT_name 326 .byte 0 # DW_AT_decl_file 327 .byte 1 # DW_AT_decl_line 328 .long 73 # DW_AT_type 329 .byte 0 # End Of Children Mark 330 .byte 6 # Abbrev [6] 0x49:0x5 DW_TAG_pointer_type 331 .long 78 # DW_AT_type 332 .byte 7 # Abbrev [7] 0x4e:0x4 DW_TAG_base_type 333 .byte 6 # DW_AT_name 334 .byte 5 # DW_AT_encoding 335 .byte 4 # DW_AT_byte_size 336 .byte 8 # Abbrev [8] 0x52:0x3a DW_TAG_subprogram 337 .byte 1 # DW_AT_low_pc 338 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc 339 .byte 1 # DW_AT_frame_base 340 .byte 87 341 # DW_AT_call_all_calls 342 .byte 7 # DW_AT_name 343 .byte 0 # DW_AT_decl_file 344 .byte 5 # DW_AT_decl_line 345 .long 78 # DW_AT_type 346 # DW_AT_external 347 .byte 9 # Abbrev [9] 0x61:0xa DW_TAG_formal_parameter 348 .byte 1 # DW_AT_location 349 .byte 85 350 .byte 8 # DW_AT_name 351 .byte 0 # DW_AT_decl_file 352 .byte 5 # DW_AT_decl_line 353 .long 78 # DW_AT_type 354 .byte 9 # Abbrev [9] 0x6b:0xa DW_TAG_formal_parameter 355 .byte 1 # DW_AT_location 356 .byte 84 357 .byte 9 # DW_AT_name 358 .byte 0 # DW_AT_decl_file 359 .byte 5 # DW_AT_decl_line 360 .long 140 # DW_AT_type 361 .byte 10 # Abbrev [10] 0x75:0x9 DW_TAG_variable 362 .byte 0 # DW_AT_location 363 .byte 5 # DW_AT_name 364 .byte 0 # DW_AT_decl_file 365 .byte 6 # DW_AT_decl_line 366 .long 78 # DW_AT_type 367 .byte 11 # Abbrev [11] 0x7e:0xd DW_TAG_inlined_subroutine 368 .long 59 # DW_AT_abstract_origin 369 .byte 1 # DW_AT_low_pc 370 .long .Ltmp1-.Lfunc_begin1 # DW_AT_high_pc 371 .byte 0 # DW_AT_call_file 372 .byte 7 # DW_AT_call_line 373 .byte 4 # DW_AT_call_column 374 .byte 0 # End Of Children Mark 375 .byte 6 # Abbrev [6] 0x8c:0x5 DW_TAG_pointer_type 376 .long 145 # DW_AT_type 377 .byte 6 # Abbrev [6] 0x91:0x5 DW_TAG_pointer_type 378 .long 150 # DW_AT_type 379 .byte 7 # Abbrev [7] 0x96:0x4 DW_TAG_base_type 380 .byte 10 # DW_AT_name 381 .byte 6 # DW_AT_encoding 382 .byte 1 # DW_AT_byte_size 383 .byte 0 # End Of Children Mark 384.Ldebug_info_end0: 385 .section .debug_str_offsets,"",@progbits 386 .long 48 # Length of String Offsets Set 387 .short 5 388 .short 0 389.Lstr_offsets_base0: 390 .section .debug_str,"MS",@progbits,1 391.Linfo_string0: 392 .asciz "clang version 15.0.0)" # string offset=0 393.Linfo_string1: 394 .asciz "main.cpp" # string offset=134 395.Linfo_string2: 396 .asciz "/testLocList" # string offset=143 397.Linfo_string3: 398 .asciz "_Z3usePi" # string offset=192 399.Linfo_string4: 400 .asciz "use" # string offset=201 401.Linfo_string5: 402 .asciz "x" # string offset=205 403.Linfo_string6: 404 .asciz "int" # string offset=207 405.Linfo_string7: 406 .asciz "main" # string offset=211 407.Linfo_string8: 408 .asciz "argc" # string offset=216 409.Linfo_string9: 410 .asciz "argv" # string offset=221 411.Linfo_string10: 412 .asciz "char" # string offset=226 413 .section .debug_str_offsets,"",@progbits 414 .long .Linfo_string0 415 .long .Linfo_string1 416 .long .Linfo_string2 417 .long .Linfo_string3 418 .long .Linfo_string4 419 .long .Linfo_string5 420 .long .Linfo_string6 421 .long .Linfo_string7 422 .long .Linfo_string8 423 .long .Linfo_string9 424 .long .Linfo_string10 425 .section .debug_addr,"",@progbits 426 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution 427.Ldebug_addr_start0: 428 .short 5 # DWARF version number 429 .byte 8 # Address size 430 .byte 0 # Segment selector size 431.Laddr_table_base0: 432 .quad .Lfunc_begin0 433 .quad .Lfunc_begin1 434.Ldebug_addr_end0: 435 .ident "clang version 15.0.0" 436 .section ".note.GNU-stack","",@progbits 437 .addrsig 438 .section .debug_line,"",@progbits 439.Lline_table_start0: 440