1 # REQUIRES: system-linux
3 # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o
4 # RUN: %clang %cflags -dwarf-4 %t1.o -o %t.exe -Wl,-q
5 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections -v 1 &> %tlog.txt
6 # RUN: cat %tlog.txt | FileCheck --check-prefix=CHECKBOLT %s
7 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=CHECK %s
9 # Tests BOLT does not assert when DIE reference is invalid.
11 # CHECKBOLT: Referenced DIE offsets not in .debug_info
13 # CHECK: DW_TAG_variable
14 # CHECK-NEXT: DW_AT_name
15 # CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0091 => {0x00000091})
17 # Assembly manually modified
18 # struct pair {int i; int j; };
23 # void store(int i, int j) {
33 .file 1 "/invalidWithin" "main.cpp"
34 .section .text._Z4loadv,"ax",@progbits
35 .globl _Z4loadv # -- Begin function _Z4loadv
37 .type _Z4loadv,@function
42 .loc 1 4 20 prologue_end # main.cpp:4:20
43 movl _ZL1p.1
(%rip
), %eax
44 .loc 1 4 16 is_stmt 0 # main.cpp:4:16
45 addl _ZL1p.0
(%rip
), %eax
46 .loc 1 4 5 # main.cpp:4:5
50 .size _Z4loadv, .Lfunc_end0-_Z4loadv
53 .section .text._Z5storeii,"ax",@progbits
54 .globl _Z5storeii # -- Begin function _Z5storeii
56 .type _Z5storeii,@function
57 _Z5storeii
: # @_Z5storeii
61 #DEBUG_VALUE: store:i <- $edi
62 #DEBUG_VALUE: store:j <- $esi
63 .loc 1 7 9 prologue_end is_stmt 1 # main.cpp:7:9
64 movl
%edi
, _ZL1p.0
(%rip
)
65 .loc 1 8 9 # main.cpp:8:9
66 movl
%esi
, _ZL1p.1
(%rip
)
67 .loc 1 9 1 # main.cpp:9:1
71 .size _Z5storeii, .Lfunc_end1-_Z5storeii
74 .section .text.main,"ax",@progbits
75 .globl main # -- Begin function main
82 .loc 1 11 1 prologue_end # main.cpp:11:1
87 .size main, .Lfunc_end2-main
90 .type _ZL1p.0,@object # @_ZL1p.0
93 .type _ZL1p.1,@object # @_ZL1p.1
96 .section .debug_abbrev,"",@progbits
97 .byte 1 # Abbreviation Code
98 .byte 17 # DW_TAG_compile_unit
99 .byte 1 # DW_CHILDREN_yes
100 .byte 37 # DW_AT_producer
101 .byte 14 # DW_FORM_strp
102 .byte 19 # DW_AT_language
103 .byte 5 # DW_FORM_data2
105 .byte 14 # DW_FORM_strp
106 .byte 16 # DW_AT_stmt_list
107 .byte 23 # DW_FORM_sec_offset
108 .byte 27 # DW_AT_comp_dir
109 .byte 14 # DW_FORM_strp
110 .byte 17 # DW_AT_low_pc
111 .byte 1 # DW_FORM_addr
112 .byte 85 # DW_AT_ranges
113 .byte 23 # DW_FORM_sec_offset
116 .byte 2 # Abbreviation Code
117 .byte 52 # DW_TAG_variable
118 .byte 0 # DW_CHILDREN_no
120 .byte 14 # DW_FORM_strp
121 .byte 73 # DW_AT_type
122 .byte 19 # DW_FORM_ref4
123 .byte 58 # DW_AT_decl_file
124 .byte 11 # DW_FORM_data1
125 .byte 59 # DW_AT_decl_line
126 .byte 11 # DW_FORM_data1
127 .byte 2 # DW_AT_location
128 .byte 24 # DW_FORM_exprloc
129 .byte 110 # DW_AT_linkage_name
130 .byte 14 # DW_FORM_strp
133 .byte 3 # Abbreviation Code
134 .byte 19 # DW_TAG_structure_type
135 .byte 1 # DW_CHILDREN_yes
136 .byte 54 # DW_AT_calling_convention
137 .byte 11 # DW_FORM_data1
139 .byte 14 # DW_FORM_strp
140 .byte 11 # DW_AT_byte_size
141 .byte 11 # DW_FORM_data1
142 .byte 58 # DW_AT_decl_file
143 .byte 11 # DW_FORM_data1
144 .byte 59 # DW_AT_decl_line
145 .byte 11 # DW_FORM_data1
148 .byte 4 # Abbreviation Code
149 .byte 13 # DW_TAG_member
150 .byte 0 # DW_CHILDREN_no
152 .byte 14 # DW_FORM_strp
153 .byte 73 # DW_AT_type
154 .byte 19 # DW_FORM_ref4
155 .byte 58 # DW_AT_decl_file
156 .byte 11 # DW_FORM_data1
157 .byte 59 # DW_AT_decl_line
158 .byte 11 # DW_FORM_data1
159 .byte 56 # DW_AT_data_member_location
160 .byte 11 # DW_FORM_data1
163 .byte 5 # Abbreviation Code
164 .byte 36 # DW_TAG_base_type
165 .byte 0 # DW_CHILDREN_no
167 .byte 14 # DW_FORM_strp
168 .byte 62 # DW_AT_encoding
169 .byte 11 # DW_FORM_data1
170 .byte 11 # DW_AT_byte_size
171 .byte 11 # DW_FORM_data1
174 .byte 6 # Abbreviation Code
175 .byte 46 # DW_TAG_subprogram
176 .byte 0 # DW_CHILDREN_no
177 .byte 17 # DW_AT_low_pc
178 .byte 1 # DW_FORM_addr
179 .byte 18 # DW_AT_high_pc
180 .byte 6 # DW_FORM_data4
181 .byte 64 # DW_AT_frame_base
182 .byte 24 # DW_FORM_exprloc
183 .ascii "\227B" # DW_AT_GNU_all_call_sites
184 .byte 25 # DW_FORM_flag_present
185 .byte 110 # DW_AT_linkage_name
186 .byte 14 # DW_FORM_strp
188 .byte 14 # DW_FORM_strp
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 63 # DW_AT_external
196 .byte 25 # DW_FORM_flag_present
199 .byte 7 # Abbreviation Code
200 .byte 46 # DW_TAG_subprogram
201 .byte 1 # DW_CHILDREN_yes
202 .byte 17 # DW_AT_low_pc
203 .byte 1 # DW_FORM_addr
204 .byte 18 # DW_AT_high_pc
205 .byte 6 # DW_FORM_data4
206 .byte 64 # DW_AT_frame_base
207 .byte 24 # DW_FORM_exprloc
208 .ascii "\227B" # DW_AT_GNU_all_call_sites
209 .byte 25 # DW_FORM_flag_present
210 .byte 110 # DW_AT_linkage_name
211 .byte 14 # DW_FORM_strp
213 .byte 14 # DW_FORM_strp
214 .byte 58 # DW_AT_decl_file
215 .byte 11 # DW_FORM_data1
216 .byte 59 # DW_AT_decl_line
217 .byte 11 # DW_FORM_data1
218 .byte 63 # DW_AT_external
219 .byte 25 # DW_FORM_flag_present
222 .byte 8 # Abbreviation Code
223 .byte 5 # DW_TAG_formal_parameter
224 .byte 0 # DW_CHILDREN_no
225 .byte 2 # DW_AT_location
226 .byte 24 # DW_FORM_exprloc
228 .byte 14 # DW_FORM_strp
229 .byte 58 # DW_AT_decl_file
230 .byte 11 # DW_FORM_data1
231 .byte 59 # DW_AT_decl_line
232 .byte 11 # DW_FORM_data1
233 .byte 73 # DW_AT_type
234 .byte 19 # DW_FORM_ref4
237 .byte 9 # Abbreviation Code
238 .byte 46 # DW_TAG_subprogram
239 .byte 0 # DW_CHILDREN_no
240 .byte 17 # DW_AT_low_pc
241 .byte 1 # DW_FORM_addr
242 .byte 18 # DW_AT_high_pc
243 .byte 6 # DW_FORM_data4
244 .byte 64 # DW_AT_frame_base
245 .byte 24 # DW_FORM_exprloc
246 .ascii "\227B" # DW_AT_GNU_all_call_sites
247 .byte 25 # DW_FORM_flag_present
249 .byte 14 # DW_FORM_strp
250 .byte 58 # DW_AT_decl_file
251 .byte 11 # DW_FORM_data1
252 .byte 59 # DW_AT_decl_line
253 .byte 11 # DW_FORM_data1
254 .byte 73 # DW_AT_type
255 .byte 19 # DW_FORM_ref4
256 .byte 63 # DW_AT_external
257 .byte 25 # DW_FORM_flag_present
261 .section .debug_info,"",@progbits
263 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
265 .short 4 # DWARF version number
266 .long .debug_abbrev # Offset Into Abbrev. Section
267 .byte 8 # Address Size (in bytes)
268 .byte 1 # Abbrev [1] 0xb:0xd9 DW_TAG_compile_unit
269 .long .Linfo_string0 # DW_AT_producer
270 .short 33 # DW_AT_language
271 .long .Linfo_string1 # DW_AT_name
272 .long .Lline_table_start0 # DW_AT_stmt_list
273 .long .Linfo_string2 # DW_AT_comp_dir
274 .quad 0 # DW_AT_low_pc
275 .long .Ldebug_ranges0 # DW_AT_ranges
276 .byte 2 # Abbrev [2] 0x2a:0x26 DW_TAG_variable
277 .long .Linfo_string3 # DW_AT_name
278 .long 145 # DW_AT_type --> Modified manually s/80/145
279 .byte 1 # DW_AT_decl_file
280 .byte 2 # DW_AT_decl_line
281 .byte 22 # DW_AT_location
290 .long .Linfo_string8 # DW_AT_linkage_name
291 .byte 3 # Abbrev [3] 0x50:0x22 DW_TAG_structure_type
292 .byte 5 # DW_AT_calling_convention
293 .long .Linfo_string7 # DW_AT_name
294 .byte 8 # DW_AT_byte_size
295 .byte 1 # DW_AT_decl_file
296 .byte 1 # DW_AT_decl_line
297 .byte 4 # Abbrev [4] 0x59:0xc DW_TAG_member
298 .long .Linfo_string4 # DW_AT_name
299 .long 114 # DW_AT_type
300 .byte 1 # DW_AT_decl_file
301 .byte 1 # DW_AT_decl_line
302 .byte 0 # DW_AT_data_member_location
303 .byte 4 # Abbrev [4] 0x65:0xc DW_TAG_member
304 .long .Linfo_string6 # DW_AT_name
305 .long 114 # DW_AT_type
306 .byte 1 # DW_AT_decl_file
307 .byte 1 # DW_AT_decl_line
308 .byte 4 # DW_AT_data_member_location
309 .byte 0 # End Of Children Mark
310 .byte 5 # Abbrev [5] 0x72:0x7 DW_TAG_base_type
311 .long .Linfo_string5 # DW_AT_name
312 .byte 5 # DW_AT_encoding
313 .byte 4 # DW_AT_byte_size
314 .byte 6 # Abbrev [6] 0x79:0x1d DW_TAG_subprogram
315 .quad .Lfunc_begin0 # DW_AT_low_pc
316 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
317 .byte 1 # DW_AT_frame_base
319 # DW_AT_GNU_all_call_sites
320 .long .Linfo_string9 # DW_AT_linkage_name
321 .long .Linfo_string10 # DW_AT_name
322 .byte 1 # DW_AT_decl_file
323 .byte 3 # DW_AT_decl_line
324 .long 114 # DW_AT_type
326 .byte 7 # Abbrev [7] 0x96:0x34 DW_TAG_subprogram
327 .quad .Lfunc_begin1 # DW_AT_low_pc
328 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
329 .byte 1 # DW_AT_frame_base
331 # DW_AT_GNU_all_call_sites
332 .long .Linfo_string11 # DW_AT_linkage_name
333 .long .Linfo_string12 # DW_AT_name
334 .byte 1 # DW_AT_decl_file
335 .byte 6 # DW_AT_decl_line
337 .byte 8 # Abbrev [8] 0xaf:0xd DW_TAG_formal_parameter
338 .byte 1 # DW_AT_location
340 .long .Linfo_string4 # DW_AT_name
341 .byte 1 # DW_AT_decl_file
342 .byte 6 # DW_AT_decl_line
343 .long 114 # DW_AT_type
344 .byte 8 # Abbrev [8] 0xbc:0xd DW_TAG_formal_parameter
345 .byte 1 # DW_AT_location
347 .long .Linfo_string6 # DW_AT_name
348 .byte 1 # DW_AT_decl_file
349 .byte 6 # DW_AT_decl_line
350 .long 114 # DW_AT_type
351 .byte 0 # End Of Children Mark
352 .byte 9 # Abbrev [9] 0xca:0x19 DW_TAG_subprogram
353 .quad .Lfunc_begin2 # DW_AT_low_pc
354 .long .Lfunc_end2-.Lfunc_begin2 # DW_AT_high_pc
355 .byte 1 # DW_AT_frame_base
357 # DW_AT_GNU_all_call_sites
358 .long .Linfo_string13 # DW_AT_name
359 .byte 1 # DW_AT_decl_file
360 .byte 10 # DW_AT_decl_line
361 .long 114 # DW_AT_type
363 .byte 0 # End Of Children Mark
365 .section .debug_ranges,"",@progbits
375 .section .debug_str,"MS",@progbits,1
377 .asciz "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)" # string offset=0
379 .asciz "main.cpp" # string offset=101
381 .asciz "/invalidWithin" # string offset=110
383 .asciz "p" # string offset=162
385 .asciz "i" # string offset=164
387 .asciz "int" # string offset=166
389 .asciz "j" # string offset=170
391 .asciz "pair" # string offset=172
393 .asciz "_ZL1p" # string offset=177
395 .asciz "_Z4loadv" # string offset=183
397 .asciz "load" # string offset=192
399 .asciz "_Z5storeii" # string offset=197
401 .asciz "store" # string offset=208
403 .asciz "main" # string offset=214
404 .ident "clang version 18.0.0 (git@github.com:llvm/llvm-project.git 37d6c1cc7d4dd3a8a47ba62254bc88521bd50d66)"
405 .section ".note.GNU-stack","",@progbits
407 .section .debug_line,"",@progbits