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 .file "main.cpp" 31 .file 0 "gnu_tls_push" "main.cpp" md5 0x551db97d5e23dc6a81abdc5ade4d9d71 32 .globl main 33 .type main,@function 34main: 35.Lfunc_begin0: 36 .loc 0 2 0 37 .loc 0 3 3 prologue_end 38 .loc 0 3 5 is_stmt 0 39 .loc 0 4 10 is_stmt 1 40 .loc 0 4 3 epilogue_begin is_stmt 0 41 retq 42.Lfunc_end0: 43 .size main, .Lfunc_end0-main 44 45 .hidden _ZTW1x 46 .weak _ZTW1x 47 .type _ZTW1x,@function 48_ZTW1x: 49.Lfunc_begin1: 50 retq 51.Lfunc_end1: 52 .size _ZTW1x, .Lfunc_end1-_ZTW1x 53 54 .type x,@object 55 .section .tbss,"awT",@nobits 56 .globl x 57x: 58 .long 0 59 .size x, 4 60 61 .section .debug_abbrev,"",@progbits 62 .byte 1 # Abbreviation Code 63 .byte 17 # DW_TAG_compile_unit 64 .byte 1 # DW_CHILDREN_yes 65 .byte 37 # DW_AT_producer 66 .byte 37 # DW_FORM_strx1 67 .byte 19 # DW_AT_language 68 .byte 5 # DW_FORM_data2 69 .byte 3 # DW_AT_name 70 .byte 37 # DW_FORM_strx1 71 .byte 114 # DW_AT_str_offsets_base 72 .byte 23 # DW_FORM_sec_offset 73 .byte 16 # DW_AT_stmt_list 74 .byte 23 # DW_FORM_sec_offset 75 .byte 27 # DW_AT_comp_dir 76 .byte 37 # DW_FORM_strx1 77 .byte 17 # DW_AT_low_pc 78 .byte 27 # DW_FORM_addrx 79 .byte 18 # DW_AT_high_pc 80 .byte 6 # DW_FORM_data4 81 .byte 115 # DW_AT_addr_base 82 .byte 23 # DW_FORM_sec_offset 83 .byte 0 # EOM(1) 84 .byte 0 # EOM(2) 85 .byte 2 # Abbreviation Code 86 .byte 52 # DW_TAG_variable 87 .byte 0 # DW_CHILDREN_no 88 .byte 3 # DW_AT_name 89 .byte 37 # DW_FORM_strx1 90 .byte 73 # DW_AT_type 91 .byte 19 # DW_FORM_ref4 92 .byte 63 # DW_AT_external 93 .byte 25 # DW_FORM_flag_present 94 .byte 58 # DW_AT_decl_file 95 .byte 11 # DW_FORM_data1 96 .byte 59 # DW_AT_decl_line 97 .byte 11 # DW_FORM_data1 98 .byte 2 # DW_AT_location 99 .byte 24 # DW_FORM_exprloc 100 .byte 0 # EOM(1) 101 .byte 0 # EOM(2) 102 .byte 3 # Abbreviation Code 103 .byte 36 # DW_TAG_base_type 104 .byte 0 # DW_CHILDREN_no 105 .byte 3 # DW_AT_name 106 .byte 37 # DW_FORM_strx1 107 .byte 62 # DW_AT_encoding 108 .byte 11 # DW_FORM_data1 109 .byte 11 # DW_AT_byte_size 110 .byte 11 # DW_FORM_data1 111 .byte 0 # EOM(1) 112 .byte 0 # EOM(2) 113 .byte 4 # Abbreviation Code 114 .byte 46 # DW_TAG_subprogram 115 .byte 0 # DW_CHILDREN_no 116 .byte 17 # DW_AT_low_pc 117 .byte 27 # DW_FORM_addrx 118 .byte 18 # DW_AT_high_pc 119 .byte 6 # DW_FORM_data4 120 .byte 64 # DW_AT_frame_base 121 .byte 24 # DW_FORM_exprloc 122 .byte 3 # DW_AT_name 123 .byte 37 # DW_FORM_strx1 124 .byte 58 # DW_AT_decl_file 125 .byte 11 # DW_FORM_data1 126 .byte 59 # DW_AT_decl_line 127 .byte 11 # DW_FORM_data1 128 .byte 73 # DW_AT_type 129 .byte 19 # DW_FORM_ref4 130 .byte 63 # DW_AT_external 131 .byte 25 # DW_FORM_flag_present 132 .byte 0 # EOM(1) 133 .byte 0 # EOM(2) 134 .byte 0 # EOM(3) 135 .section .debug_info,"",@progbits 136.Lcu_begin0: 137 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 138.Ldebug_info_start0: 139 .short 5 # DWARF version number 140 .byte 1 # DWARF Unit Type 141 .byte 8 # Address Size (in bytes) 142 .long .debug_abbrev # Offset Into Abbrev. Section 143 .byte 1 # Abbrev [1] 0xc:0x3e DW_TAG_compile_unit 144 .byte 0 # DW_AT_producer 145 .short 33 # DW_AT_language 146 .byte 1 # DW_AT_name 147 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base 148 .long .Lline_table_start0 # DW_AT_stmt_list 149 .byte 2 # DW_AT_comp_dir 150 .byte 0 # DW_AT_low_pc 151 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 152 .long .Laddr_table_base0 # DW_AT_addr_base 153 .byte 2 # Abbrev [2] 0x23:0x13 DW_TAG_variable 154 .byte 3 # DW_AT_name 155 .long 54 # DW_AT_type 156 # DW_AT_external 157 .byte 0 # DW_AT_decl_file 158 .byte 1 # DW_AT_decl_line 159 .byte 10 # DW_AT_location 160 .byte 14 161 .quad x@DTPOFF 162 .byte 224 163 .byte 3 # Abbrev [3] 0x36:0x4 DW_TAG_base_type 164 .byte 4 # DW_AT_name 165 .byte 5 # DW_AT_encoding 166 .byte 4 # DW_AT_byte_size 167 .byte 4 # Abbrev [4] 0x3a:0xf DW_TAG_subprogram 168 .byte 0 # DW_AT_low_pc 169 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 170 .byte 1 # DW_AT_frame_base 171 .byte 86 172 .byte 5 # DW_AT_name 173 .byte 0 # DW_AT_decl_file 174 .byte 2 # DW_AT_decl_line 175 .long 54 # DW_AT_type 176 # DW_AT_external 177 .byte 0 # End Of Children Mark 178.Ldebug_info_end0: 179 .section .debug_str_offsets,"",@progbits 180 .long 28 # Length of String Offsets Set 181 .short 5 182 .short 0 183.Lstr_offsets_base0: 184 .section .debug_str,"MS",@progbits,1 185.Linfo_string0: 186 .asciz "clang version 17.0.4" # string offset=0 187.Linfo_string1: 188 .asciz "main.cpp" # string offset=137 189.Linfo_string2: 190 .asciz "gnu_tls_push" # string offset=146 191.Linfo_string3: 192 .asciz "x" # string offset=184 193.Linfo_string4: 194 .asciz "int" # string offset=186 195.Linfo_string5: 196 .asciz "main" # string offset=190 197 .section .debug_str_offsets,"",@progbits 198 .long .Linfo_string0 199 .long .Linfo_string1 200 .long .Linfo_string2 201 .long .Linfo_string3 202 .long .Linfo_string4 203 .long .Linfo_string5 204 .section .debug_addr,"",@progbits 205 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution 206.Ldebug_addr_start0: 207 .short 5 # DWARF version number 208 .byte 8 # Address size 209 .byte 0 # Segment selector size 210.Laddr_table_base0: 211 .quad .Lfunc_begin0 212.Ldebug_addr_end0: 213 .section .debug_names,"",@progbits 214 .long .Lnames_end0-.Lnames_start0 # Header: unit length 215.Lnames_start0: 216 .short 5 # Header: version 217 .short 0 # Header: padding 218 .long 1 # Header: compilation unit count 219 .long 0 # Header: local type unit count 220 .long 0 # Header: foreign type unit count 221 .long 3 # Header: bucket count 222 .long 3 # Header: name count 223 .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size 224 .long 8 # Header: augmentation string size 225 .ascii "LLVM0700" # Header: augmentation string 226 .long .Lcu_begin0 # Compilation unit 0 227 .long 1 # Bucket 0 228 .long 2 # Bucket 1 229 .long 3 # Bucket 2 230 .long 177693 # Hash in Bucket 0 231 .long 2090499946 # Hash in Bucket 1 232 .long 193495088 # Hash in Bucket 2 233 .long .Linfo_string3 # String in Bucket 0: x 234 .long .Linfo_string5 # String in Bucket 1: main 235 .long .Linfo_string4 # String in Bucket 2: int 236 .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0 237 .long .Lnames2-.Lnames_entries0 # Offset in Bucket 1 238 .long .Lnames0-.Lnames_entries0 # Offset in Bucket 2 239.Lnames_abbrev_start0: 240 .byte 1 # Abbrev code 241 .byte 52 # DW_TAG_variable 242 .byte 3 # DW_IDX_die_offset 243 .byte 19 # DW_FORM_ref4 244 .byte 4 # DW_IDX_parent 245 .byte 25 # DW_FORM_flag_present 246 .byte 0 # End of abbrev 247 .byte 0 # End of abbrev 248 .byte 2 # Abbrev code 249 .byte 46 # DW_TAG_subprogram 250 .byte 3 # DW_IDX_die_offset 251 .byte 19 # DW_FORM_ref4 252 .byte 4 # DW_IDX_parent 253 .byte 25 # DW_FORM_flag_present 254 .byte 0 # End of abbrev 255 .byte 0 # End of abbrev 256 .byte 3 # Abbrev code 257 .byte 36 # DW_TAG_base_type 258 .byte 3 # DW_IDX_die_offset 259 .byte 19 # DW_FORM_ref4 260 .byte 4 # DW_IDX_parent 261 .byte 25 # DW_FORM_flag_present 262 .byte 0 # End of abbrev 263 .byte 0 # End of abbrev 264 .byte 0 # End of abbrev list 265.Lnames_abbrev_end0: 266.Lnames_entries0: 267.Lnames1: 268.L2: 269 .byte 1 # Abbreviation code 270 .long 35 # DW_IDX_die_offset 271 .byte 0 # DW_IDX_parent 272 # End of list: x 273.Lnames2: 274.L0: 275 .byte 2 # Abbreviation code 276 .long 58 # DW_IDX_die_offset 277 .byte 0 # DW_IDX_parent 278 # End of list: main 279.Lnames0: 280.L1: 281 .byte 3 # Abbreviation code 282 .long 54 # DW_IDX_die_offset 283 .byte 0 # DW_IDX_parent 284 # End of list: int 285 .p2align 2, 0x0 286.Lnames_end0: 287 .ident "clang version 17.0.4 (https://git.internal.tfbnw.net/repos/git/rw/osmeta/external/llvm-project 8d1fd9f463cb31caf429b83cf7a5baea5f67e54a)" 288 .section ".note.GNU-stack","",@progbits 289 .addrsig 290 .section .debug_line,"",@progbits 291.Lline_table_start0: 292