1 # REQUIRES: system-linux
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 --always-convert-to-ranges
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
11 # This tests checks that DW_AT_low_pc/DW_AT_high_pc is converted to DW_AT_low_pc/DW_AT_ranges.
12 # Checks that DW_AT_rnglists_base is inserted, and that correct address is used.
14 # PRECHECK: version = 0x0005
15 # PRECHECK: DW_AT_low_pc
16 # PRECHECK-SAME: DW_FORM_addrx
17 # PRECHECK-SAME: (00000000)
18 # PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x0000000f)
19 # PRECHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
22 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]
23 # POSTCHECK: version = 0x0005
24 # POSTCHECK: DW_AT_low_pc
25 # POSTCHECK-SAME: DW_FORM_addrx
26 # POSTCHECK-SAME: (00000001)
27 # POSTCHECK-SAME: address = 0x0000000000000000
28 # POSTCHECK-NEXT: DW_AT_ranges
29 # POSTCHECK-SAME: DW_FORM_rnglistx
30 # POSTCHECK-SAME: (0x0)
31 # POSTCHECK-SAME: rangelist = 0x00000014
33 # POSTCHECK-SAME: 0x[[#ADDR]]
34 # POSTCHECK-SAME: 0x[[#ADDR + 15]]
35 # POSTCHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
36 # POSTCHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
44 .globl main # -- Begin function main
49 .file 0 "." "main.cpp" md5 0xbb12fec8d002b1f0e06f7dee4604c6cc
50 .loc 0 1 0 # main.cpp:1:0
54 .cfi_def_cfa_offset 16
57 .cfi_def_cfa_register %rbp
60 .loc 0 2 3 prologue_end # main.cpp:2:3
67 .size main, .Lfunc_end0-main
70 .section .debug_abbrev,"",@progbits
71 .byte 1 # Abbreviation Code
72 .byte 17 # DW_TAG_compile_unit
73 .byte 1 # DW_CHILDREN_yes
74 .byte 37 # DW_AT_producer
75 .byte 37 # DW_FORM_strx1
76 .byte 19 # DW_AT_language
77 .byte 5 # DW_FORM_data2
79 .byte 37 # DW_FORM_strx1
80 .byte 114 # DW_AT_str_offsets_base
81 .byte 23 # DW_FORM_sec_offset
82 .byte 16 # DW_AT_stmt_list
83 .byte 23 # DW_FORM_sec_offset
84 .byte 27 # DW_AT_comp_dir
85 .byte 37 # DW_FORM_strx1
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 115 # DW_AT_addr_base
91 .byte 23 # DW_FORM_sec_offset
94 .byte 2 # Abbreviation Code
95 .byte 46 # DW_TAG_subprogram
96 .byte 0 # DW_CHILDREN_no
97 .byte 17 # DW_AT_low_pc
98 .byte 27 # DW_FORM_addrx
99 .byte 18 # DW_AT_high_pc
100 .byte 6 # DW_FORM_data4
101 .byte 64 # DW_AT_frame_base
102 .byte 24 # DW_FORM_exprloc
104 .byte 37 # DW_FORM_strx1
105 .byte 58 # DW_AT_decl_file
106 .byte 11 # DW_FORM_data1
107 .byte 59 # DW_AT_decl_line
108 .byte 11 # DW_FORM_data1
109 .byte 73 # DW_AT_type
110 .byte 19 # DW_FORM_ref4
111 .byte 63 # DW_AT_external
112 .byte 25 # DW_FORM_flag_present
115 .byte 3 # Abbreviation Code
116 .byte 36 # DW_TAG_base_type
117 .byte 0 # DW_CHILDREN_no
119 .byte 37 # DW_FORM_strx1
120 .byte 62 # DW_AT_encoding
121 .byte 11 # DW_FORM_data1
122 .byte 11 # DW_AT_byte_size
123 .byte 11 # DW_FORM_data1
127 .section .debug_info,"",@progbits
129 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
131 .short 5 # DWARF version number
132 .byte 1 # DWARF Unit Type
133 .byte 8 # Address Size (in bytes)
134 .long .debug_abbrev # Offset Into Abbrev. Section
135 .byte 1 # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit
136 .byte 0 # DW_AT_producer
137 .short 33 # DW_AT_language
139 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
140 .long .Lline_table_start0 # DW_AT_stmt_list
141 .byte 2 # DW_AT_comp_dir
142 .byte 0 # DW_AT_low_pc
143 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
144 .long .Laddr_table_base0 # DW_AT_addr_base
145 .byte 2 # Abbrev [2] 0x23:0xf DW_TAG_subprogram
146 .byte 0 # DW_AT_low_pc
147 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
148 .byte 1 # DW_AT_frame_base
151 .byte 0 # DW_AT_decl_file
152 .byte 1 # DW_AT_decl_line
153 .long 50 # DW_AT_type
155 .byte 3 # Abbrev [3] 0x32:0x4 DW_TAG_base_type
157 .byte 5 # DW_AT_encoding
158 .byte 4 # DW_AT_byte_size
159 .byte 0 # End Of Children Mark
161 .section .debug_str_offsets,"",@progbits
162 .long 24 # Length of String Offsets Set
166 .section .debug_str,"MS",@progbits,1
168 .asciz "clang version 15.0.0" # string offset=0
170 .asciz "main.cpp" # string offset=134
172 .asciz "." # string offset=143
174 .asciz "main" # string offset=180
176 .asciz "int" # string offset=185
177 .section .debug_str_offsets,"",@progbits
183 .section .debug_addr,"",@progbits
184 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
186 .short 5 # DWARF version number
187 .byte 8 # Address size
188 .byte 0 # Segment selector size
192 .ident "clang version 15.0.0"
193 .section ".note.GNU-stack","",@progbits
195 .section .debug_line,"",@progbits