1 # REQUIRES: system-linux
3 # RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %tmain.o --defsym MAIN=0
4 # RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %thelper.o
5 # RUN: %clang %cflags %tmain.o %thelper.o -o %tmain.exe
6 # RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
7 # RUN: llvm-dwarfdump --debug-info %tmain.exe.bolt > %tout.text
8 # RUN: llvm-dwarfdump --show-section-sizes %tmain.exe >> %tout.text
9 # RUN: llvm-dwarfdump --show-section-sizes %tmain.exe.bolt >> %tout.text
10 # RUN: cat %tout.text | FileCheck %s
12 # This test checks that with DWARF5 when two CUs share the same .debug_str_offsets
13 # entry BOLT does not create a duplicate.
15 # CHECK: DW_AT_str_offsets_base (0x[[#%.8x,ADDR:]]
16 # CHECK: DW_AT_str_offsets_base (0x[[#ADDR]]
18 # CHECK: .debug_str_offsets [[#ADDR2:]]
19 # CHECK: .debug_str_offsets [[#ADDR2]]
29 ## Create two CUs, with dwo_ids 0 and 1 respectively.
33 .globl main # -- Begin function main
38 .file 0 "." "main.cpp" md5 0x32c197b0a8b855eb3d7573c993ada862
39 .loc 0 1 0 # main.cpp:1:0
43 .cfi_def_cfa_offset 16
46 .cfi_def_cfa_register %rbp
49 .loc 0 2 1 prologue_end # main.cpp:2:1
56 .size main, .Lfunc_end0-main
59 .section .debug_abbrev,"",@progbits
60 .byte 1 # Abbreviation Code
61 .byte 17 # DW_TAG_compile_unit
62 .byte 1 # DW_CHILDREN_yes
63 .byte 37 # DW_AT_producer
64 .byte 37 # DW_FORM_strx1
65 .byte 19 # DW_AT_language
66 .byte 5 # DW_FORM_data2
68 .byte 37 # DW_FORM_strx1
69 .byte 114 # DW_AT_str_offsets_base
70 .byte 23 # DW_FORM_sec_offset
71 .byte 16 # DW_AT_stmt_list
72 .byte 23 # DW_FORM_sec_offset
73 .byte 27 # DW_AT_comp_dir
74 .byte 37 # DW_FORM_strx1
75 .byte 17 # DW_AT_low_pc
76 .byte 27 # DW_FORM_addrx
77 .byte 18 # DW_AT_high_pc
78 .byte 6 # DW_FORM_data4
79 .byte 115 # DW_AT_addr_base
80 .byte 23 # DW_FORM_sec_offset
83 .byte 2 # Abbreviation Code
84 .byte 46 # DW_TAG_subprogram
85 .byte 0 # DW_CHILDREN_no
86 .byte 17 # DW_AT_low_pc
87 .byte 27 # DW_FORM_addrx
88 .byte 18 # DW_AT_high_pc
89 .byte 6 # DW_FORM_data4
90 .byte 64 # DW_AT_frame_base
91 .byte 24 # DW_FORM_exprloc
93 .byte 37 # DW_FORM_strx1
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
99 .byte 19 # DW_FORM_ref4
100 .byte 63 # DW_AT_external
101 .byte 25 # DW_FORM_flag_present
104 .byte 3 # Abbreviation Code
105 .byte 36 # DW_TAG_base_type
106 .byte 0 # DW_CHILDREN_no
108 .byte 37 # DW_FORM_strx1
109 .byte 62 # DW_AT_encoding
110 .byte 11 # DW_FORM_data1
111 .byte 11 # DW_AT_byte_size
112 .byte 11 # DW_FORM_data1
116 .section .debug_info,"",@progbits
118 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
120 .short 5 # DWARF version number
121 .byte 1 # DWARF Unit Type
122 .byte 8 # Address Size (in bytes)
123 .long .debug_abbrev # Offset Into Abbrev. Section
124 .byte 1 # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit
125 .byte 0 # DW_AT_producer
126 .short 33 # DW_AT_language
128 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
129 .long .Lline_table_start0 # DW_AT_stmt_list
130 .byte 2 # DW_AT_comp_dir
131 .byte 0 # DW_AT_low_pc
132 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
133 .long .Laddr_table_base0 # DW_AT_addr_base
134 .byte 2 # Abbrev [2] 0x23:0xf DW_TAG_subprogram
135 .byte 0 # DW_AT_low_pc
136 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
137 .byte 1 # DW_AT_frame_base
140 .byte 0 # DW_AT_decl_file
141 .byte 1 # DW_AT_decl_line
142 .long 50 # DW_AT_type
144 .byte 3 # Abbrev [3] 0x32:0x4 DW_TAG_base_type
146 .byte 5 # DW_AT_encoding
147 .byte 4 # DW_AT_byte_size
148 .byte 0 # End Of Children Mark
150 .section .debug_str_offsets,"",@progbits
151 .long 24 # Length of String Offsets Set
155 .section .debug_str,"MS",@progbits,1
157 .asciz "clang version 15.0.0" # string offset=0
159 .asciz "main.cpp" # string offset=146
161 .asciz "." # string offset=155
163 .asciz "main" # string offset=198
165 .asciz "int" # string offset=203
166 .section .debug_str_offsets,"",@progbits
172 .section .debug_addr,"",@progbits
173 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
175 .short 5 # DWARF version number
176 .byte 8 # Address size
177 .byte 0 # Segment selector size
181 .ident "clang version 15.0.0"
182 .section ".note.GNU-stack","",@progbits
184 .section .debug_line,"",@progbits
189 .globl _Z3foov # -- Begin function _Z3foov
191 .type _Z3foov,@function
194 .file 0 "." "helper.cpp" md5 0x5f98e4807e4f8781c26a82faf819f8a7
195 .loc 0 1 0 # helper.cpp:1:0
199 .cfi_def_cfa_offset 16
200 .cfi_offset %rbp, -16
202 .cfi_def_cfa_register %rbp
204 .loc 0 1 12 prologue_end # helper.cpp:1:12
210 .size _Z3foov, .Lfunc_end0-_Z3foov
213 .section .debug_abbrev,"",@progbits
214 .byte 1 # Abbreviation Code
215 .byte 17 # DW_TAG_compile_unit
216 .byte 1 # DW_CHILDREN_yes
217 .byte 37 # DW_AT_producer
218 .byte 37 # DW_FORM_strx1
219 .byte 19 # DW_AT_language
220 .byte 5 # DW_FORM_data2
222 .byte 37 # DW_FORM_strx1
223 .byte 114 # DW_AT_str_offsets_base
224 .byte 23 # DW_FORM_sec_offset
225 .byte 16 # DW_AT_stmt_list
226 .byte 23 # DW_FORM_sec_offset
227 .byte 27 # DW_AT_comp_dir
228 .byte 37 # DW_FORM_strx1
229 .byte 17 # DW_AT_low_pc
230 .byte 27 # DW_FORM_addrx
231 .byte 18 # DW_AT_high_pc
232 .byte 6 # DW_FORM_data4
233 .byte 115 # DW_AT_addr_base
234 .byte 23 # DW_FORM_sec_offset
237 .byte 2 # Abbreviation Code
238 .byte 46 # DW_TAG_subprogram
239 .byte 0 # DW_CHILDREN_no
240 .byte 17 # DW_AT_low_pc
241 .byte 27 # DW_FORM_addrx
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 .byte 110 # DW_AT_linkage_name
247 .byte 37 # DW_FORM_strx1
249 .byte 37 # DW_FORM_strx1
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 63 # DW_AT_external
255 .byte 25 # DW_FORM_flag_present
259 .section .debug_info,"",@progbits
261 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
263 .short 5 # DWARF version number
264 .byte 1 # DWARF Unit Type
265 .byte 8 # Address Size (in bytes)
266 .long .debug_abbrev # Offset Into Abbrev. Section
267 .byte 1 # Abbrev [1] 0xc:0x24 DW_TAG_compile_unit
268 .byte 0 # DW_AT_producer
269 .short 33 # DW_AT_language
271 .long 0x8 # DW_AT_str_offsets_base Manually modified to be the same as first CU
272 .long .Lline_table_start0 # DW_AT_stmt_list
273 .byte 2 # DW_AT_comp_dir
274 .byte 0 # DW_AT_low_pc
275 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
276 .long .Laddr_table_base0 # DW_AT_addr_base
277 .byte 2 # Abbrev [2] 0x23:0xc DW_TAG_subprogram
278 .byte 0 # DW_AT_low_pc
279 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
280 .byte 1 # DW_AT_frame_base
282 .byte 3 # DW_AT_linkage_name
284 .byte 0 # DW_AT_decl_file
285 .byte 1 # DW_AT_decl_line
287 .byte 0 # End Of Children Mark
289 # Manually removed .debug_str_offsets and .debug_str
290 .section .debug_addr,"",@progbits
291 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
293 .short 5 # DWARF version number
294 .byte 8 # Address size
295 .byte 0 # Segment selector size
299 .ident "clang version 15.0.0"
300 .section ".note.GNU-stack","",@progbits
302 .section .debug_line,"",@progbits