xref: /llvm-project/bolt/test/X86/high_pc_udata.s (revision 11791ae7b0b05b8bd8d806331ff51da618912cf8)
1# REQUIRES: system-linux
2
3# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o
4# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q
5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
6# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
7# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
8
9# PRECHECK: DW_AT_high_pc [DW_FORM_udata]	(15)
10# PRECHECK-NEXT: DW_AT_name [DW_FORM_strp]
11# PRECHECK-SAME: "main.cpp"
12
13# POSTCHECK: DW_AT_ranges [DW_FORM_sec_offset]
14# POSTCHECK-NEXT: [
15# POSTCHECK-NEXT: DW_AT_name [DW_FORM_strp]
16# POSTCHECK-SAME: "main.cpp"
17
18## Testing that BOLT transforms DW_AT_high_pc of form DW_FORM_udata correctly into DW_AT_ranges.
19## Manually changed so that DW_AT_high_pc is DW_FORM_udata, and that DW_AT_name is after it.
20# int main() {
21#    return 0;
22# }
23.text
24	.file	"main.cpp"
25	.globl	main                            # -- Begin function main
26	.p2align	4, 0x90
27	.type	main,@function
28main:                                   # @main
29.Lfunc_begin0:
30	.file	1 "" "main.cpp"
31	.loc	1 1 0                           # main.cpp:1:0
32	.cfi_startproc
33# %bb.0:                                # %entry
34	pushq	%rbp
35	.cfi_def_cfa_offset 16
36	.cfi_offset %rbp, -16
37	movq	%rsp, %rbp
38	.cfi_def_cfa_register %rbp
39	movl	$0, -4(%rbp)
40.Ltmp0:
41	.loc	1 2 1 prologue_end              # main.cpp:2:1
42	xorl	%eax, %eax
43	popq	%rbp
44	.cfi_def_cfa %rsp, 8
45	retq
46.Ltmp1:
47.Lfunc_end0:
48	.size	main, .Lfunc_end0-main
49	.cfi_endproc
50                                        # -- End function
51	.section	.debug_abbrev,"",@progbits
52	.byte	1                               # Abbreviation Code
53	.byte	17                              # DW_TAG_compile_unit
54	.byte	1                               # DW_CHILDREN_yes
55	.byte	37                              # DW_AT_producer
56	.byte	14                              # DW_FORM_strp
57	.byte	19                              # DW_AT_language
58	.byte	5                               # DW_FORM_data2
59	.byte	16                              # DW_AT_stmt_list
60	.byte	23                              # DW_FORM_sec_offset
61	.byte	27                              # DW_AT_comp_dir
62	.byte	14                              # DW_FORM_strp
63	.byte	17                              # DW_AT_low_pc
64	.byte	1                               # DW_FORM_addr
65	.byte	18                              # DW_AT_high_pc
66	.byte	15                              # DW_FORM_udata
67	.byte	3                               # DW_AT_name
68	.byte	14                              # DW_FORM_strp
69	.byte	0                               # EOM(1)
70	.byte	0                               # EOM(2)
71	.byte	2                               # Abbreviation Code
72	.byte	46                              # DW_TAG_subprogram
73	.byte	0                               # DW_CHILDREN_no
74	.byte	17                              # DW_AT_low_pc
75	.byte	1                               # DW_FORM_addr
76	.byte	18                              # DW_AT_high_pc
77	.byte	6                               # DW_FORM_data4
78	.byte	64                              # DW_AT_frame_base
79	.byte	24                              # DW_FORM_exprloc
80	.byte	3                               # DW_AT_name
81	.byte	14                              # DW_FORM_strp
82	.byte	58                              # DW_AT_decl_file
83	.byte	11                              # DW_FORM_data1
84	.byte	59                              # DW_AT_decl_line
85	.byte	11                              # DW_FORM_data1
86	.byte	73                              # DW_AT_type
87	.byte	19                              # DW_FORM_ref4
88	.byte	63                              # DW_AT_external
89	.byte	25                              # DW_FORM_flag_present
90	.byte	0                               # EOM(1)
91	.byte	0                               # EOM(2)
92	.byte	3                               # Abbreviation Code
93	.byte	36                              # DW_TAG_base_type
94	.byte	0                               # DW_CHILDREN_no
95	.byte	3                               # DW_AT_name
96	.byte	14                              # DW_FORM_strp
97	.byte	62                              # DW_AT_encoding
98	.byte	11                              # DW_FORM_data1
99	.byte	11                              # DW_AT_byte_size
100	.byte	11                              # DW_FORM_data1
101	.byte	0                               # EOM(1)
102	.byte	0                               # EOM(2)
103	.byte	0                               # EOM(3)
104	.section	.debug_info,"",@progbits
105.Lcu_begin0:
106	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
107.Ldebug_info_start0:
108	.short	4                               # DWARF version number
109	.long	.debug_abbrev                   # Offset Into Abbrev. Section
110	.byte	8                               # Address Size (in bytes)
111	.byte	1                               # Abbrev [1] 0xb:0x40 DW_TAG_compile_unit
112	.long	.Linfo_string0                  # DW_AT_producer
113	.short	33                              # DW_AT_language
114	.long	.Lline_table_start0             # DW_AT_stmt_list
115	.long	.Linfo_string2                  # DW_AT_comp_dir
116	.quad	.Lfunc_begin0                   # DW_AT_low_pc
117	.byte	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
118	.long	.Linfo_string1                  # DW_AT_name
119	.byte	2                               # Abbrev [2] 0x2a:0x19 DW_TAG_subprogram
120	.quad	.Lfunc_begin0                   # DW_AT_low_pc
121	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
122	.byte	1                               # DW_AT_frame_base
123	.byte	86
124	.long	.Linfo_string3                  # DW_AT_name
125	.byte	1                               # DW_AT_decl_file
126	.byte	1                               # DW_AT_decl_line
127	.long	64                              # DW_AT_type
128                                        # DW_AT_external
129	.byte	3                               # Abbrev [3] 0x43:0x7 DW_TAG_base_type
130	.long	.Linfo_string4                  # DW_AT_name
131	.byte	5                               # DW_AT_encoding
132	.byte	4                               # DW_AT_byte_size
133	.byte	0                               # End Of Children Mark
134.Ldebug_info_end0:
135	.section	.debug_str,"MS",@progbits,1
136.Linfo_string0:
137	.asciz	"clang" # string offset=0
138.Linfo_string1:
139	.asciz	"main.cpp"                      # string offset=134
140.Linfo_string2:
141	.asciz	"test" # string offset=143
142.Linfo_string3:
143	.asciz	"main"                          # string offset=186
144.Linfo_string4:
145	.asciz	"int"                           # string offset=191
146	.ident	"clang"
147	.section	".note.GNU-stack","",@progbits
148	.addrsig
149	.section	.debug_line,"",@progbits
150.Lline_table_start0:
151