|
| 1 | +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o |
| 2 | +# RUN: %clang %cflags -gdwarf-5 %tmain.o -o %tmain.exe |
| 3 | +# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections |
| 4 | +# RUN: llvm-dwarfdump --debug-names --debug-info %tmain.exe.bolt > %tlog.txt |
| 5 | +# RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s |
| 6 | + |
| 7 | +## This test checks that BOLT correctly generates .debug_names section when there is DW_TAG_variable |
| 8 | +## with DW_OP_GNU_push_tls_address in DW_AT_location. |
| 9 | + |
| 10 | +# BOLT: [[DIEOFFSET:0x[0-9a-f]*]]: DW_TAG_variable |
| 11 | +# BOLT-NEXT: DW_AT_name ("x") |
| 12 | +# BOLT-NEXT: DW_AT_type ({{.+}} "int") |
| 13 | +# BOLT-NEXT: DW_AT_external (true) |
| 14 | +# BOLT-NEXT: DW_AT_decl_file ("gnu_tls_push/main.cpp") |
| 15 | +# BOLT-NEXT: DW_AT_decl_line (1) |
| 16 | +# BOLT-NEXT: DW_AT_location (DW_OP_const8u 0x0, DW_OP_GNU_push_tls_address) |
| 17 | +# BOLT: Hash: 0x2B61D |
| 18 | +# BOLT-NEXT: String: {{.+}} "x" |
| 19 | +# BOLT-NEXT: Entry @ {{.+}} { |
| 20 | +# BOLT-NEXT: Abbrev: {{.+}} |
| 21 | +# BOLT-NEXT: Tag: DW_TAG_variable |
| 22 | +# BOLT-NEXT: DW_IDX_die_offset: [[DIEOFFSET]] |
| 23 | +# BOLT-NEXT: DW_IDX_parent: <parent not indexed> |
| 24 | + |
| 25 | +## thread_local int x = 0; |
| 26 | +## int main() { |
| 27 | +## x = 10; |
| 28 | +## return x; |
| 29 | +## } |
| 30 | + .text |
| 31 | + .file "main.cpp" |
| 32 | + .file 0 "gnu_tls_push" "main.cpp" md5 0x551db97d5e23dc6a81abdc5ade4d9d71 |
| 33 | + .globl main # -- Begin function main |
| 34 | + .p2align 4, 0x90 |
| 35 | + .type main,@function |
| 36 | +main: # @main |
| 37 | +.Lfunc_begin0: |
| 38 | + .loc 0 2 0 # main.cpp:2:0 |
| 39 | + .cfi_startproc |
| 40 | +# %bb.0: # %entry |
| 41 | + pushq %rbp |
| 42 | + .cfi_def_cfa_offset 16 |
| 43 | + .cfi_offset %rbp, -16 |
| 44 | + movq %rsp, %rbp |
| 45 | + .cfi_def_cfa_register %rbp |
| 46 | + movl $0, -4(%rbp) |
| 47 | +.Ltmp0: |
| 48 | + .loc 0 3 3 prologue_end # main.cpp:3:3 |
| 49 | + movq %fs:0, %rax |
| 50 | + leaq x@TPOFF(%rax), %rax |
| 51 | + .loc 0 3 5 is_stmt 0 # main.cpp:3:5 |
| 52 | + movl $10, (%rax) |
| 53 | + .loc 0 4 10 is_stmt 1 # main.cpp:4:10 |
| 54 | + movq %fs:0, %rax |
| 55 | + leaq x@TPOFF(%rax), %rax |
| 56 | + movl (%rax), %eax |
| 57 | + .loc 0 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 |
| 58 | + popq %rbp |
| 59 | + .cfi_def_cfa %rsp, 8 |
| 60 | + retq |
| 61 | +.Ltmp1: |
| 62 | +.Lfunc_end0: |
| 63 | + .size main, .Lfunc_end0-main |
| 64 | + .cfi_endproc |
| 65 | + # -- End function |
| 66 | + .section .text._ZTW1x,"axG",@progbits,_ZTW1x,comdat |
| 67 | + .hidden _ZTW1x # -- Begin function _ZTW1x |
| 68 | + .weak _ZTW1x |
| 69 | + .p2align 4, 0x90 |
| 70 | + .type _ZTW1x,@function |
| 71 | +_ZTW1x: # @_ZTW1x |
| 72 | +.Lfunc_begin1: |
| 73 | + .cfi_startproc |
| 74 | +# %bb.0: |
| 75 | + pushq %rbp |
| 76 | + .cfi_def_cfa_offset 16 |
| 77 | + .cfi_offset %rbp, -16 |
| 78 | + movq %rsp, %rbp |
| 79 | + .cfi_def_cfa_register %rbp |
| 80 | + movq %fs:0, %rax |
| 81 | + leaq x@TPOFF(%rax), %rax |
| 82 | + popq %rbp |
| 83 | + .cfi_def_cfa %rsp, 8 |
| 84 | + retq |
| 85 | +.Lfunc_end1: |
| 86 | + .size _ZTW1x, .Lfunc_end1-_ZTW1x |
| 87 | + .cfi_endproc |
| 88 | + # -- End function |
| 89 | + .type x,@object # @x |
| 90 | + .section .tbss,"awT",@nobits |
| 91 | + .globl x |
| 92 | + .p2align 2, 0x0 |
| 93 | +x: |
| 94 | + .long 0 # 0x0 |
| 95 | + .size x, 4 |
| 96 | + |
| 97 | + .section .debug_abbrev,"",@progbits |
| 98 | + .byte 1 # Abbreviation Code |
| 99 | + .byte 17 # DW_TAG_compile_unit |
| 100 | + .byte 1 # DW_CHILDREN_yes |
| 101 | + .byte 37 # DW_AT_producer |
| 102 | + .byte 37 # DW_FORM_strx1 |
| 103 | + .byte 19 # DW_AT_language |
| 104 | + .byte 5 # DW_FORM_data2 |
| 105 | + .byte 3 # DW_AT_name |
| 106 | + .byte 37 # DW_FORM_strx1 |
| 107 | + .byte 114 # DW_AT_str_offsets_base |
| 108 | + .byte 23 # DW_FORM_sec_offset |
| 109 | + .byte 16 # DW_AT_stmt_list |
| 110 | + .byte 23 # DW_FORM_sec_offset |
| 111 | + .byte 27 # DW_AT_comp_dir |
| 112 | + .byte 37 # DW_FORM_strx1 |
| 113 | + .byte 17 # DW_AT_low_pc |
| 114 | + .byte 27 # DW_FORM_addrx |
| 115 | + .byte 18 # DW_AT_high_pc |
| 116 | + .byte 6 # DW_FORM_data4 |
| 117 | + .byte 115 # DW_AT_addr_base |
| 118 | + .byte 23 # DW_FORM_sec_offset |
| 119 | + .byte 0 # EOM(1) |
| 120 | + .byte 0 # EOM(2) |
| 121 | + .byte 2 # Abbreviation Code |
| 122 | + .byte 52 # DW_TAG_variable |
| 123 | + .byte 0 # DW_CHILDREN_no |
| 124 | + .byte 3 # DW_AT_name |
| 125 | + .byte 37 # DW_FORM_strx1 |
| 126 | + .byte 73 # DW_AT_type |
| 127 | + .byte 19 # DW_FORM_ref4 |
| 128 | + .byte 63 # DW_AT_external |
| 129 | + .byte 25 # DW_FORM_flag_present |
| 130 | + .byte 58 # DW_AT_decl_file |
| 131 | + .byte 11 # DW_FORM_data1 |
| 132 | + .byte 59 # DW_AT_decl_line |
| 133 | + .byte 11 # DW_FORM_data1 |
| 134 | + .byte 2 # DW_AT_location |
| 135 | + .byte 24 # DW_FORM_exprloc |
| 136 | + .byte 0 # EOM(1) |
| 137 | + .byte 0 # EOM(2) |
| 138 | + .byte 3 # Abbreviation Code |
| 139 | + .byte 36 # DW_TAG_base_type |
| 140 | + .byte 0 # DW_CHILDREN_no |
| 141 | + .byte 3 # DW_AT_name |
| 142 | + .byte 37 # DW_FORM_strx1 |
| 143 | + .byte 62 # DW_AT_encoding |
| 144 | + .byte 11 # DW_FORM_data1 |
| 145 | + .byte 11 # DW_AT_byte_size |
| 146 | + .byte 11 # DW_FORM_data1 |
| 147 | + .byte 0 # EOM(1) |
| 148 | + .byte 0 # EOM(2) |
| 149 | + .byte 4 # Abbreviation Code |
| 150 | + .byte 46 # DW_TAG_subprogram |
| 151 | + .byte 0 # DW_CHILDREN_no |
| 152 | + .byte 17 # DW_AT_low_pc |
| 153 | + .byte 27 # DW_FORM_addrx |
| 154 | + .byte 18 # DW_AT_high_pc |
| 155 | + .byte 6 # DW_FORM_data4 |
| 156 | + .byte 64 # DW_AT_frame_base |
| 157 | + .byte 24 # DW_FORM_exprloc |
| 158 | + .byte 3 # DW_AT_name |
| 159 | + .byte 37 # DW_FORM_strx1 |
| 160 | + .byte 58 # DW_AT_decl_file |
| 161 | + .byte 11 # DW_FORM_data1 |
| 162 | + .byte 59 # DW_AT_decl_line |
| 163 | + .byte 11 # DW_FORM_data1 |
| 164 | + .byte 73 # DW_AT_type |
| 165 | + .byte 19 # DW_FORM_ref4 |
| 166 | + .byte 63 # DW_AT_external |
| 167 | + .byte 25 # DW_FORM_flag_present |
| 168 | + .byte 0 # EOM(1) |
| 169 | + .byte 0 # EOM(2) |
| 170 | + .byte 0 # EOM(3) |
| 171 | + .section .debug_info,"",@progbits |
| 172 | +.Lcu_begin0: |
| 173 | + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit |
| 174 | +.Ldebug_info_start0: |
| 175 | + .short 5 # DWARF version number |
| 176 | + .byte 1 # DWARF Unit Type |
| 177 | + .byte 8 # Address Size (in bytes) |
| 178 | + .long .debug_abbrev # Offset Into Abbrev. Section |
| 179 | + .byte 1 # Abbrev [1] 0xc:0x3e DW_TAG_compile_unit |
| 180 | + .byte 0 # DW_AT_producer |
| 181 | + .short 33 # DW_AT_language |
| 182 | + .byte 1 # DW_AT_name |
| 183 | + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base |
| 184 | + .long .Lline_table_start0 # DW_AT_stmt_list |
| 185 | + .byte 2 # DW_AT_comp_dir |
| 186 | + .byte 0 # DW_AT_low_pc |
| 187 | + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 188 | + .long .Laddr_table_base0 # DW_AT_addr_base |
| 189 | + .byte 2 # Abbrev [2] 0x23:0x13 DW_TAG_variable |
| 190 | + .byte 3 # DW_AT_name |
| 191 | + .long 54 # DW_AT_type |
| 192 | + # DW_AT_external |
| 193 | + .byte 0 # DW_AT_decl_file |
| 194 | + .byte 1 # DW_AT_decl_line |
| 195 | + .byte 10 # DW_AT_location |
| 196 | + .byte 14 |
| 197 | + .quad x@DTPOFF |
| 198 | + .byte 224 |
| 199 | + .byte 3 # Abbrev [3] 0x36:0x4 DW_TAG_base_type |
| 200 | + .byte 4 # DW_AT_name |
| 201 | + .byte 5 # DW_AT_encoding |
| 202 | + .byte 4 # DW_AT_byte_size |
| 203 | + .byte 4 # Abbrev [4] 0x3a:0xf DW_TAG_subprogram |
| 204 | + .byte 0 # DW_AT_low_pc |
| 205 | + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc |
| 206 | + .byte 1 # DW_AT_frame_base |
| 207 | + .byte 86 |
| 208 | + .byte 5 # DW_AT_name |
| 209 | + .byte 0 # DW_AT_decl_file |
| 210 | + .byte 2 # DW_AT_decl_line |
| 211 | + .long 54 # DW_AT_type |
| 212 | + # DW_AT_external |
| 213 | + .byte 0 # End Of Children Mark |
| 214 | +.Ldebug_info_end0: |
| 215 | + .section .debug_str_offsets,"",@progbits |
| 216 | + .long 28 # Length of String Offsets Set |
| 217 | + .short 5 |
| 218 | + .short 0 |
| 219 | +.Lstr_offsets_base0: |
| 220 | + .section .debug_str,"MS",@progbits,1 |
| 221 | +.Linfo_string0: |
| 222 | + .asciz "clang version 17.0.4" # string offset=0 |
| 223 | +.Linfo_string1: |
| 224 | + .asciz "main.cpp" # string offset=137 |
| 225 | +.Linfo_string2: |
| 226 | + .asciz "gnu_tls_push" # string offset=146 |
| 227 | +.Linfo_string3: |
| 228 | + .asciz "x" # string offset=184 |
| 229 | +.Linfo_string4: |
| 230 | + .asciz "int" # string offset=186 |
| 231 | +.Linfo_string5: |
| 232 | + .asciz "main" # string offset=190 |
| 233 | + .section .debug_str_offsets,"",@progbits |
| 234 | + .long .Linfo_string0 |
| 235 | + .long .Linfo_string1 |
| 236 | + .long .Linfo_string2 |
| 237 | + .long .Linfo_string3 |
| 238 | + .long .Linfo_string4 |
| 239 | + .long .Linfo_string5 |
| 240 | + .section .debug_addr,"",@progbits |
| 241 | + .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution |
| 242 | +.Ldebug_addr_start0: |
| 243 | + .short 5 # DWARF version number |
| 244 | + .byte 8 # Address size |
| 245 | + .byte 0 # Segment selector size |
| 246 | +.Laddr_table_base0: |
| 247 | + .quad .Lfunc_begin0 |
| 248 | +.Ldebug_addr_end0: |
| 249 | + .section .debug_names,"",@progbits |
| 250 | + .long .Lnames_end0-.Lnames_start0 # Header: unit length |
| 251 | +.Lnames_start0: |
| 252 | + .short 5 # Header: version |
| 253 | + .short 0 # Header: padding |
| 254 | + .long 1 # Header: compilation unit count |
| 255 | + .long 0 # Header: local type unit count |
| 256 | + .long 0 # Header: foreign type unit count |
| 257 | + .long 3 # Header: bucket count |
| 258 | + .long 3 # Header: name count |
| 259 | + .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size |
| 260 | + .long 8 # Header: augmentation string size |
| 261 | + .ascii "LLVM0700" # Header: augmentation string |
| 262 | + .long .Lcu_begin0 # Compilation unit 0 |
| 263 | + .long 1 # Bucket 0 |
| 264 | + .long 2 # Bucket 1 |
| 265 | + .long 3 # Bucket 2 |
| 266 | + .long 177693 # Hash in Bucket 0 |
| 267 | + .long 2090499946 # Hash in Bucket 1 |
| 268 | + .long 193495088 # Hash in Bucket 2 |
| 269 | + .long .Linfo_string3 # String in Bucket 0: x |
| 270 | + .long .Linfo_string5 # String in Bucket 1: main |
| 271 | + .long .Linfo_string4 # String in Bucket 2: int |
| 272 | + .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0 |
| 273 | + .long .Lnames2-.Lnames_entries0 # Offset in Bucket 1 |
| 274 | + .long .Lnames0-.Lnames_entries0 # Offset in Bucket 2 |
| 275 | +.Lnames_abbrev_start0: |
| 276 | + .byte 1 # Abbrev code |
| 277 | + .byte 52 # DW_TAG_variable |
| 278 | + .byte 3 # DW_IDX_die_offset |
| 279 | + .byte 19 # DW_FORM_ref4 |
| 280 | + .byte 4 # DW_IDX_parent |
| 281 | + .byte 25 # DW_FORM_flag_present |
| 282 | + .byte 0 # End of abbrev |
| 283 | + .byte 0 # End of abbrev |
| 284 | + .byte 2 # Abbrev code |
| 285 | + .byte 46 # DW_TAG_subprogram |
| 286 | + .byte 3 # DW_IDX_die_offset |
| 287 | + .byte 19 # DW_FORM_ref4 |
| 288 | + .byte 4 # DW_IDX_parent |
| 289 | + .byte 25 # DW_FORM_flag_present |
| 290 | + .byte 0 # End of abbrev |
| 291 | + .byte 0 # End of abbrev |
| 292 | + .byte 3 # Abbrev code |
| 293 | + .byte 36 # DW_TAG_base_type |
| 294 | + .byte 3 # DW_IDX_die_offset |
| 295 | + .byte 19 # DW_FORM_ref4 |
| 296 | + .byte 4 # DW_IDX_parent |
| 297 | + .byte 25 # DW_FORM_flag_present |
| 298 | + .byte 0 # End of abbrev |
| 299 | + .byte 0 # End of abbrev |
| 300 | + .byte 0 # End of abbrev list |
| 301 | +.Lnames_abbrev_end0: |
| 302 | +.Lnames_entries0: |
| 303 | +.Lnames1: |
| 304 | +.L2: |
| 305 | + .byte 1 # Abbreviation code |
| 306 | + .long 35 # DW_IDX_die_offset |
| 307 | + .byte 0 # DW_IDX_parent |
| 308 | + # End of list: x |
| 309 | +.Lnames2: |
| 310 | +.L0: |
| 311 | + .byte 2 # Abbreviation code |
| 312 | + .long 58 # DW_IDX_die_offset |
| 313 | + .byte 0 # DW_IDX_parent |
| 314 | + # End of list: main |
| 315 | +.Lnames0: |
| 316 | +.L1: |
| 317 | + .byte 3 # Abbreviation code |
| 318 | + .long 54 # DW_IDX_die_offset |
| 319 | + .byte 0 # DW_IDX_parent |
| 320 | + # End of list: int |
| 321 | + .p2align 2, 0x0 |
| 322 | +.Lnames_end0: |
| 323 | + .ident "clang version 17.0.4 (https://git.internal.tfbnw.net/repos/git/rw/osmeta/external/llvm-project 8d1fd9f463cb31caf429b83cf7a5baea5f67e54a)" |
| 324 | + .section ".note.GNU-stack","",@progbits |
| 325 | + .addrsig |
| 326 | + .section .debug_line,"",@progbits |
| 327 | +.Lline_table_start0: |
0 commit comments