xref: /llvm-project/lld/test/ELF/debug-names-missing-parent.s (revision 16711b431b843dd2143d38fdf6b0591dfb1783e0)
1# REQUIRES: x86
2## Test clang-17-generated DW_TAG_subprogram, which do not contain DW_IDX_parent
3## attributes.
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
6# RUN: ld.lld --debug-names %t.o -o %t
7# RUN: llvm-dwarfdump --debug-info --debug-names %t | FileCheck %s --check-prefix=DWARF
8
9# DWARF: 0x00000023:   DW_TAG_namespace
10# DWARF: 0x00000025:     DW_TAG_subprogram
11
12# DWARF:      String: {{.*}} "fa"
13# DWARF-NEXT: Entry @ 0x71 {
14# DWARF-NEXT:   Abbrev: 0x1
15# DWARF-NEXT:   Tag: DW_TAG_subprogram
16# DWARF-NEXT:   DW_IDX_die_offset: 0x00000025
17# DWARF-NEXT:   DW_IDX_compile_unit: 0x00
18# DWARF-NEXT: }
19# DWARF:      String: {{.*}} "ns"
20# DWARF-NEXT: Entry @ 0x78 {
21# DWARF-NEXT:   Abbrev: 0x2
22# DWARF-NEXT:   Tag: DW_TAG_namespace
23# DWARF-NEXT:   DW_IDX_die_offset: 0x00000023
24# DWARF-NEXT:   DW_IDX_compile_unit: 0x00
25# DWARF-NEXT: }
26
27.ifdef GEN
28//--- a.cc
29namespace ns {
30void fa() {}
31}
32//--- gen
33clang-17 --target=x86_64-linux -S -O1 -g -gpubnames a.cc -o -
34.endif
35	.text
36	.file	"a.cc"
37	.globl	_ZN2ns2faEv                     # -- Begin function _ZN2ns2faEv
38	.p2align	4, 0x90
39	.type	_ZN2ns2faEv,@function
40_ZN2ns2faEv:                            # @_ZN2ns2faEv
41.Lfunc_begin0:
42	.file	0 "/proc/self/cwd" "a.cc" md5 0xb3281d5b5a0b2997d7d59d49bc912274
43	.cfi_startproc
44# %bb.0:
45	.loc	0 2 12 prologue_end             # a.cc:2:12
46	retq
47.Ltmp0:
48.Lfunc_end0:
49	.size	_ZN2ns2faEv, .Lfunc_end0-_ZN2ns2faEv
50	.cfi_endproc
51                                        # -- End function
52	.section	.debug_abbrev,"",@progbits
53	.byte	1                               # Abbreviation Code
54	.byte	17                              # DW_TAG_compile_unit
55	.byte	1                               # DW_CHILDREN_yes
56	.byte	37                              # DW_AT_producer
57	.byte	37                              # DW_FORM_strx1
58	.byte	19                              # DW_AT_language
59	.byte	5                               # DW_FORM_data2
60	.byte	3                               # DW_AT_name
61	.byte	37                              # DW_FORM_strx1
62	.byte	114                             # DW_AT_str_offsets_base
63	.byte	23                              # DW_FORM_sec_offset
64	.byte	16                              # DW_AT_stmt_list
65	.byte	23                              # DW_FORM_sec_offset
66	.byte	27                              # DW_AT_comp_dir
67	.byte	37                              # DW_FORM_strx1
68	.byte	17                              # DW_AT_low_pc
69	.byte	27                              # DW_FORM_addrx
70	.byte	18                              # DW_AT_high_pc
71	.byte	6                               # DW_FORM_data4
72	.byte	115                             # DW_AT_addr_base
73	.byte	23                              # DW_FORM_sec_offset
74	.byte	0                               # EOM(1)
75	.byte	0                               # EOM(2)
76	.byte	2                               # Abbreviation Code
77	.byte	57                              # DW_TAG_namespace
78	.byte	1                               # DW_CHILDREN_yes
79	.byte	3                               # DW_AT_name
80	.byte	37                              # DW_FORM_strx1
81	.byte	0                               # EOM(1)
82	.byte	0                               # EOM(2)
83	.byte	3                               # 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
92	.byte	122                             # DW_AT_call_all_calls
93	.byte	25                              # DW_FORM_flag_present
94	.byte	110                             # DW_AT_linkage_name
95	.byte	37                              # DW_FORM_strx1
96	.byte	3                               # DW_AT_name
97	.byte	37                              # DW_FORM_strx1
98	.byte	58                              # DW_AT_decl_file
99	.byte	11                              # DW_FORM_data1
100	.byte	59                              # DW_AT_decl_line
101	.byte	11                              # DW_FORM_data1
102	.byte	63                              # DW_AT_external
103	.byte	25                              # DW_FORM_flag_present
104	.byte	0                               # EOM(1)
105	.byte	0                               # EOM(2)
106	.byte	0                               # EOM(3)
107	.section	.debug_info,"",@progbits
108.Lcu_begin0:
109	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
110.Ldebug_info_start0:
111	.short	5                               # DWARF version number
112	.byte	1                               # DWARF Unit Type
113	.byte	8                               # Address Size (in bytes)
114	.long	.debug_abbrev                   # Offset Into Abbrev. Section
115	.byte	1                               # Abbrev [1] 0xc:0x27 DW_TAG_compile_unit
116	.byte	0                               # DW_AT_producer
117	.short	33                              # DW_AT_language
118	.byte	1                               # DW_AT_name
119	.long	.Lstr_offsets_base0             # DW_AT_str_offsets_base
120	.long	.Lline_table_start0             # DW_AT_stmt_list
121	.byte	2                               # DW_AT_comp_dir
122	.byte	0                               # DW_AT_low_pc
123	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
124	.long	.Laddr_table_base0              # DW_AT_addr_base
125	.byte	2                               # Abbrev [2] 0x23:0xf DW_TAG_namespace
126	.byte	3                               # DW_AT_name
127	.byte	3                               # Abbrev [3] 0x25:0xc DW_TAG_subprogram
128	.byte	0                               # DW_AT_low_pc
129	.long	.Lfunc_end0-.Lfunc_begin0       # DW_AT_high_pc
130	.byte	1                               # DW_AT_frame_base
131	.byte	87
132                                        # DW_AT_call_all_calls
133	.byte	4                               # DW_AT_linkage_name
134	.byte	5                               # DW_AT_name
135	.byte	0                               # DW_AT_decl_file
136	.byte	2                               # DW_AT_decl_line
137                                        # DW_AT_external
138	.byte	0                               # End Of Children Mark
139	.byte	0                               # End Of Children Mark
140.Ldebug_info_end0:
141	.section	.debug_str_offsets,"",@progbits
142	.long	28                              # Length of String Offsets Set
143	.short	5
144	.short	0
145.Lstr_offsets_base0:
146	.section	.debug_str,"MS",@progbits,1
147.Linfo_string0:
148	.byte	0                               # string offset=0
149.Linfo_string1:
150	.asciz	"a.cc"                          # string offset=1
151.Linfo_string2:
152	.asciz	"/proc/self/cwd"                # string offset=6
153.Linfo_string3:
154	.asciz	"ns"                            # string offset=21
155.Linfo_string4:
156	.asciz	"fa"                            # string offset=24
157.Linfo_string5:
158	.asciz	"_ZN2ns2faEv"                   # string offset=27
159	.section	.debug_str_offsets,"",@progbits
160	.long	.Linfo_string0
161	.long	.Linfo_string1
162	.long	.Linfo_string2
163	.long	.Linfo_string3
164	.long	.Linfo_string5
165	.long	.Linfo_string4
166	.section	.debug_addr,"",@progbits
167	.long	.Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
168.Ldebug_addr_start0:
169	.short	5                               # DWARF version number
170	.byte	8                               # Address size
171	.byte	0                               # Segment selector size
172.Laddr_table_base0:
173	.quad	.Lfunc_begin0
174.Ldebug_addr_end0:
175	.section	.debug_names,"",@progbits
176	.long	.Lnames_end0-.Lnames_start0     # Header: unit length
177.Lnames_start0:
178	.short	5                               # Header: version
179	.short	0                               # Header: padding
180	.long	1                               # Header: compilation unit count
181	.long	0                               # Header: local type unit count
182	.long	0                               # Header: foreign type unit count
183	.long	3                               # Header: bucket count
184	.long	3                               # Header: name count
185	.long	.Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size
186	.long	8                               # Header: augmentation string size
187	.ascii	"LLVM0700"                      # Header: augmentation string
188	.long	.Lcu_begin0                     # Compilation unit 0
189	.long	0                               # Bucket 0
190	.long	1                               # Bucket 1
191	.long	3                               # Bucket 2
192	.long	5863372                         # Hash in Bucket 1
193	.long	5863654                         # Hash in Bucket 1
194	.long	-1413999533                     # Hash in Bucket 2
195	.long	.Linfo_string4                  # String in Bucket 1: fa
196	.long	.Linfo_string3                  # String in Bucket 1: ns
197	.long	.Linfo_string5                  # String in Bucket 2: _ZN2ns2faEv
198	.long	.Lnames1-.Lnames_entries0       # Offset in Bucket 1
199	.long	.Lnames0-.Lnames_entries0       # Offset in Bucket 1
200	.long	.Lnames2-.Lnames_entries0       # Offset in Bucket 2
201.Lnames_abbrev_start0:
202	.byte	46                              # Abbrev code
203	.byte	46                              # DW_TAG_subprogram
204	.byte	3                               # DW_IDX_die_offset
205	.byte	19                              # DW_FORM_ref4
206	.byte	0                               # End of abbrev
207	.byte	0                               # End of abbrev
208	.byte	57                              # Abbrev code
209	.byte	57                              # DW_TAG_namespace
210	.byte	3                               # DW_IDX_die_offset
211	.byte	19                              # DW_FORM_ref4
212	.byte	0                               # End of abbrev
213	.byte	0                               # End of abbrev
214	.byte	0                               # End of abbrev list
215.Lnames_abbrev_end0:
216.Lnames_entries0:
217.Lnames1:
218	.byte	46                              # Abbreviation code
219	.long	37                              # DW_IDX_die_offset
220	.byte	0                               # End of list: fa
221.Lnames0:
222	.byte	57                              # Abbreviation code
223	.long	35                              # DW_IDX_die_offset
224	.byte	0                               # End of list: ns
225.Lnames2:
226	.byte	46                              # Abbreviation code
227	.long	37                              # DW_IDX_die_offset
228	.byte	0                               # End of list: _ZN2ns2faEv
229	.p2align	2, 0x0
230.Lnames_end0:
231	.section	".note.GNU-stack","",@progbits
232	.addrsig
233	.section	.debug_line,"",@progbits
234.Lline_table_start0:
235