• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-windows-msvc < %s > %t.obj
3# RUN: lld-link /DEBUG:FULL /nodefaultlib /entry:main %t.obj /PDB:%t.pdb /OUT:%t.exe
4# RUN: llvm-pdbutil dump -types -globals -symbols -modi=0 %t.pdb | FileCheck %s
5# RUN: lld-link /DEBUG:FULL /debug:ghash /nodefaultlib /entry:main %t.obj /PDB:%t.pdb /OUT:%t.exe
6# RUN: llvm-pdbutil dump -types -globals -symbols -modi=0 %t.pdb | FileCheck %s
7
8# CHECK:                               Types (TPI Stream)
9# CHECK-NEXT: ============================================================
10# CHECK:      0x1003 | LF_STRUCTURE [size = 44] `Struct`
11# CHECK-NEXT:          unique name: `.?AUStruct@@`
12# CHECK-NEXT:          vtable: <no type>, base list: <no type>, field list: <no type>
13# CHECK-NEXT:          options: forward ref (-> 0x1006) | has unique name, sizeof 0
14# CHECK-NEXT: 0x1004 | LF_POINTER [size = 12]
15# CHECK-NEXT:          referent = 0x1003, mode = pointer, opts = None, kind = ptr64
16# CHECK:      0x1006 | LF_STRUCTURE [size = 44] `Struct`
17# CHECK-NEXT:          unique name: `.?AUStruct@@`
18# CHECK-NEXT:          vtable: <no type>, base list: <no type>, field list: 0x1005
19# CHECK-NEXT:          options: has unique name, sizeof 4
20# CHECK:                               Global Symbols
21# CHECK-NEXT: ============================================================
22# CHECK:      {{.*}} | S_UDT [size = 24] `StructTypedef`
23# CHECK:               original type = 0x1003
24# CHECK:      {{.*}} | S_UDT [size = 16] `Struct`
25# CHECK:               original type = 0x1006
26# CHECK:      {{.*}} | S_UDT [size = 20] `IntTypedef`
27# CHECK:               original type = 0x0074 (int)
28# CHECK:                               Symbols
29# CHECK-NEXT: ============================================================
30# CHECK:      {{.*}} | S_GPROC32 [size = 44] `main`
31# CHECK-NEXT:          parent = 0, end = 252, addr = 0001:0000, code size = 52
32# CHECK-NEXT:          type = `0x1002 (int (int, char**))`, debug start = 0, debug end = 0, flags = none
33# CHECK-NOT:  {{.*}} | S_END
34# CHECK:      {{.*}} | S_UDT [size = 28] `main::LocalTypedef`
35# CHECK-NEXT:          original type = 0x1004
36# CHECK:      {{.*}} | S_END [size = 4]
37
38# source code to re-generate:
39# clang-cl /Z7 /GS- /GR- /c foo.cpp
40#
41# struct Struct {
42#   int x;
43# };
44#
45# using IntTypedef = int;
46# using StructTypedef = Struct;
47# Struct S;
48# StructTypedef SS;
49# IntTypedef I;
50#
51# int main(int argc, char **argv) {
52#   using LocalTypedef = Struct*;
53#   LocalTypedef SPtr;
54#   return I + S.x + SS.x + SPtr->x;
55# }
56
57	.text
58	.def	 @feat.00;
59	.scl	3;
60	.type	0;
61	.endef
62	.globl	@feat.00
63.set @feat.00, 0
64	.intel_syntax noprefix
65	.def	 main;
66	.scl	2;
67	.type	32;
68	.endef
69	.globl	main                    # -- Begin function main
70	.p2align	4, 0x90
71main:                                   # @main
72.Lfunc_begin0:
73	.cv_func_id 0
74	.cv_file	1 "D:\\src\\llvmbuild\\cl\\Debug\\x64\\foo.cpp" "2B62298EE3EEF94E1D81FDFE18BD46A6" 1
75	.cv_loc	0 1 12 0                # foo.cpp:12:0
76.seh_proc main
77# %bb.0:                                # %entry
78	sub	rsp, 32
79	.seh_stackalloc 32
80	.seh_endprologue
81	mov	dword ptr [rsp + 28], 0
82	mov	qword ptr [rsp + 16], rdx
83	mov	dword ptr [rsp + 12], ecx
84.Ltmp0:
85	.cv_loc	0 1 15 0                # foo.cpp:15:0
86	mov	ecx, dword ptr [rip + "?I@@3HA"]
87	add	ecx, dword ptr [rip + "?S@@3UStruct@@A"]
88	add	ecx, dword ptr [rip + "?SS@@3UStruct@@A"]
89	mov	rdx, qword ptr [rsp]
90	add	ecx, dword ptr [rdx]
91	mov	eax, ecx
92	add	rsp, 32
93	ret
94.Ltmp1:
95.Lfunc_end0:
96	.seh_handlerdata
97	.text
98	.seh_endproc
99                                        # -- End function
100	.bss
101	.globl	"?S@@3UStruct@@A"       # @"?S@@3UStruct@@A"
102	.p2align	2
103"?S@@3UStruct@@A":
104	.zero	4
105
106	.globl	"?SS@@3UStruct@@A"      # @"?SS@@3UStruct@@A"
107	.p2align	2
108"?SS@@3UStruct@@A":
109	.zero	4
110
111	.globl	"?I@@3HA"               # @"?I@@3HA"
112	.p2align	2
113"?I@@3HA":
114	.long	0                       # 0x0
115
116	.section	.drectve,"yn"
117	.ascii	" /DEFAULTLIB:libcmt.lib"
118	.ascii	" /DEFAULTLIB:oldnames.lib"
119	.section	.debug$S,"dr"
120	.p2align	2
121	.long	4                       # Debug section magic
122	.long	241
123	.long	.Ltmp3-.Ltmp2           # Subsection size
124.Ltmp2:
125	.short	.Ltmp5-.Ltmp4           # Record length
126.Ltmp4:
127	.short	4412                    # Record kind: S_COMPILE3
128	.long	1                       # Flags and language
129	.short	208                     # CPUType
130	.short	8                       # Frontend version
131	.short	0
132	.short	0
133	.short	0
134	.short	8000                    # Backend version
135	.short	0
136	.short	0
137	.short	0
138	.asciz	"clang version 8.0.0 "  # Null-terminated compiler version string
139.Ltmp5:
140.Ltmp3:
141	.p2align	2
142	.long	241                     # Symbol subsection for main
143	.long	.Ltmp7-.Ltmp6           # Subsection size
144.Ltmp6:
145	.short	.Ltmp9-.Ltmp8           # Record length
146.Ltmp8:
147	.short	4423                    # Record kind: S_GPROC32_ID
148	.long	0                       # PtrParent
149	.long	0                       # PtrEnd
150	.long	0                       # PtrNext
151	.long	.Lfunc_end0-main        # Code size
152	.long	0                       # Offset after prologue
153	.long	0                       # Offset before epilogue
154	.long	4099                    # Function type index
155	.secrel32	main            # Function section relative address
156	.secidx	main                    # Function section index
157	.byte	0                       # Flags
158	.asciz	"main"                  # Function name
159.Ltmp9:
160	.short	.Ltmp11-.Ltmp10         # Record length
161.Ltmp10:
162	.short	4114                    # Record kind: S_FRAMEPROC
163	.long	32                      # FrameSize
164	.long	0                       # Padding
165	.long	0                       # Offset of padding
166	.long	0                       # Bytes of callee saved registers
167	.long	0                       # Exception handler offset
168	.short	0                       # Exception handler section
169	.long	81920                   # Flags (defines frame register)
170.Ltmp11:
171	.short	.Ltmp13-.Ltmp12         # Record length
172.Ltmp12:
173	.short	4414                    # Record kind: S_LOCAL
174	.long	116                     # TypeIndex
175	.short	1                       # Flags
176	.asciz	"argc"
177.Ltmp13:
178	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 12
179	.short	.Ltmp15-.Ltmp14         # Record length
180.Ltmp14:
181	.short	4414                    # Record kind: S_LOCAL
182	.long	4096                    # TypeIndex
183	.short	1                       # Flags
184	.asciz	"argv"
185.Ltmp15:
186	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 16
187	.short	.Ltmp17-.Ltmp16         # Record length
188.Ltmp16:
189	.short	4414                    # Record kind: S_LOCAL
190	.long	4101                    # TypeIndex
191	.short	0                       # Flags
192	.asciz	"SPtr"
193.Ltmp17:
194	.cv_def_range	 .Ltmp0 .Ltmp1, frame_ptr_rel, 0
195	.short	.Ltmp19-.Ltmp18         # Record length
196.Ltmp18:
197	.short	4360                    # Record kind: S_UDT
198	.long	4101                    # Type
199	.asciz	"main::LocalTypedef"
200.Ltmp19:
201	.short	2                       # Record length
202	.short	4431                    # Record kind: S_PROC_ID_END
203.Ltmp7:
204	.p2align	2
205	.cv_linetable	0, main, .Lfunc_end0
206	.long	241                     # Symbol subsection for globals
207	.long	.Ltmp21-.Ltmp20         # Subsection size
208.Ltmp20:
209	.short	.Ltmp23-.Ltmp22         # Record length
210.Ltmp22:
211	.short	4365                    # Record kind: S_GDATA32
212	.long	4103                    # Type
213	.secrel32	"?S@@3UStruct@@A" # DataOffset
214	.secidx	"?S@@3UStruct@@A"       # Segment
215	.asciz	"S"                     # Name
216.Ltmp23:
217	.short	.Ltmp25-.Ltmp24         # Record length
218.Ltmp24:
219	.short	4365                    # Record kind: S_GDATA32
220	.long	4100                    # Type
221	.secrel32	"?SS@@3UStruct@@A" # DataOffset
222	.secidx	"?SS@@3UStruct@@A"      # Segment
223	.asciz	"SS"                    # Name
224.Ltmp25:
225	.short	.Ltmp27-.Ltmp26         # Record length
226.Ltmp26:
227	.short	4365                    # Record kind: S_GDATA32
228	.long	116                     # Type
229	.secrel32	"?I@@3HA"       # DataOffset
230	.secidx	"?I@@3HA"               # Segment
231	.asciz	"I"                     # Name
232.Ltmp27:
233.Ltmp21:
234	.p2align	2
235	.long	241
236	.long	.Ltmp29-.Ltmp28         # Subsection size
237.Ltmp28:
238	.short	.Ltmp31-.Ltmp30         # Record length
239.Ltmp30:
240	.short	4360                    # Record kind: S_UDT
241	.long	4103                    # Type
242	.asciz	"Struct"
243.Ltmp31:
244	.short	.Ltmp33-.Ltmp32         # Record length
245.Ltmp32:
246	.short	4360                    # Record kind: S_UDT
247	.long	4100                    # Type
248	.asciz	"StructTypedef"
249.Ltmp33:
250	.short	.Ltmp35-.Ltmp34         # Record length
251.Ltmp34:
252	.short	4360                    # Record kind: S_UDT
253	.long	116                     # Type
254	.asciz	"IntTypedef"
255.Ltmp35:
256.Ltmp29:
257	.p2align	2
258	.cv_filechecksums               # File index to string table offset subsection
259	.cv_stringtable                 # String table
260	.long	241
261	.long	.Ltmp37-.Ltmp36         # Subsection size
262.Ltmp36:
263	.short	6                       # Record length
264	.short	4428                    # Record kind: S_BUILDINFO
265	.long	4108                    # LF_BUILDINFO index
266.Ltmp37:
267	.p2align	2
268	.section	.debug$T,"dr"
269	.p2align	2
270	.long	4                       # Debug section magic
271	# Pointer (0x1000) {
272	#   TypeLeafKind: LF_POINTER (0x1002)
273	#   PointeeType: char* (0x670)
274	#   PtrType: Near64 (0xC)
275	#   PtrMode: Pointer (0x0)
276	#   IsFlat: 0
277	#   IsConst: 0
278	#   IsVolatile: 0
279	#   IsUnaligned: 0
280	#   IsRestrict: 0
281	#   IsThisPtr&: 0
282	#   IsThisPtr&&: 0
283	#   SizeOf: 8
284	# }
285	.byte	0x0a, 0x00, 0x02, 0x10
286	.byte	0x70, 0x06, 0x00, 0x00
287	.byte	0x0c, 0x00, 0x01, 0x00
288	# ArgList (0x1001) {
289	#   TypeLeafKind: LF_ARGLIST (0x1201)
290	#   NumArgs: 2
291	#   Arguments [
292	#     ArgType: int (0x74)
293	#     ArgType: char** (0x1000)
294	#   ]
295	# }
296	.byte	0x0e, 0x00, 0x01, 0x12
297	.byte	0x02, 0x00, 0x00, 0x00
298	.byte	0x74, 0x00, 0x00, 0x00
299	.byte	0x00, 0x10, 0x00, 0x00
300	# Procedure (0x1002) {
301	#   TypeLeafKind: LF_PROCEDURE (0x1008)
302	#   ReturnType: int (0x74)
303	#   CallingConvention: NearC (0x0)
304	#   FunctionOptions [ (0x0)
305	#   ]
306	#   NumParameters: 2
307	#   ArgListType: (int, char**) (0x1001)
308	# }
309	.byte	0x0e, 0x00, 0x08, 0x10
310	.byte	0x74, 0x00, 0x00, 0x00
311	.byte	0x00, 0x00, 0x02, 0x00
312	.byte	0x01, 0x10, 0x00, 0x00
313	# FuncId (0x1003) {
314	#   TypeLeafKind: LF_FUNC_ID (0x1601)
315	#   ParentScope: 0x0
316	#   FunctionType: int (int, char**) (0x1002)
317	#   Name: main
318	# }
319	.byte	0x12, 0x00, 0x01, 0x16
320	.byte	0x00, 0x00, 0x00, 0x00
321	.byte	0x02, 0x10, 0x00, 0x00
322	.byte	0x6d, 0x61, 0x69, 0x6e
323	.byte	0x00, 0xf3, 0xf2, 0xf1
324	# Struct (0x1004) {
325	#   TypeLeafKind: LF_STRUCTURE (0x1505)
326	#   MemberCount: 0
327	#   Properties [ (0x280)
328	#     ForwardReference (0x80)
329	#     HasUniqueName (0x200)
330	#   ]
331	#   FieldList: 0x0
332	#   DerivedFrom: 0x0
333	#   VShape: 0x0
334	#   SizeOf: 0
335	#   Name: Struct
336	#   LinkageName: .?AUStruct@@
337	# }
338	.byte	0x2a, 0x00, 0x05, 0x15
339	.byte	0x00, 0x00, 0x80, 0x02
340	.byte	0x00, 0x00, 0x00, 0x00
341	.byte	0x00, 0x00, 0x00, 0x00
342	.byte	0x00, 0x00, 0x00, 0x00
343	.byte	0x00, 0x00, 0x53, 0x74
344	.byte	0x72, 0x75, 0x63, 0x74
345	.byte	0x00, 0x2e, 0x3f, 0x41
346	.byte	0x55, 0x53, 0x74, 0x72
347	.byte	0x75, 0x63, 0x74, 0x40
348	.byte	0x40, 0x00, 0xf2, 0xf1
349	# Pointer (0x1005) {
350	#   TypeLeafKind: LF_POINTER (0x1002)
351	#   PointeeType: Struct (0x1004)
352	#   PtrType: Near64 (0xC)
353	#   PtrMode: Pointer (0x0)
354	#   IsFlat: 0
355	#   IsConst: 0
356	#   IsVolatile: 0
357	#   IsUnaligned: 0
358	#   IsRestrict: 0
359	#   IsThisPtr&: 0
360	#   IsThisPtr&&: 0
361	#   SizeOf: 8
362	# }
363	.byte	0x0a, 0x00, 0x02, 0x10
364	.byte	0x04, 0x10, 0x00, 0x00
365	.byte	0x0c, 0x00, 0x01, 0x00
366	# FieldList (0x1006) {
367	#   TypeLeafKind: LF_FIELDLIST (0x1203)
368	#   DataMember {
369	#     TypeLeafKind: LF_MEMBER (0x150D)
370	#     AccessSpecifier: Public (0x3)
371	#     Type: int (0x74)
372	#     FieldOffset: 0x0
373	#     Name: x
374	#   }
375	# }
376	.byte	0x0e, 0x00, 0x03, 0x12
377	.byte	0x0d, 0x15, 0x03, 0x00
378	.byte	0x74, 0x00, 0x00, 0x00
379	.byte	0x00, 0x00, 0x78, 0x00
380	# Struct (0x1007) {
381	#   TypeLeafKind: LF_STRUCTURE (0x1505)
382	#   MemberCount: 1
383	#   Properties [ (0x200)
384	#     HasUniqueName (0x200)
385	#   ]
386	#   FieldList: <field list> (0x1006)
387	#   DerivedFrom: 0x0
388	#   VShape: 0x0
389	#   SizeOf: 4
390	#   Name: Struct
391	#   LinkageName: .?AUStruct@@
392	# }
393	.byte	0x2a, 0x00, 0x05, 0x15
394	.byte	0x01, 0x00, 0x00, 0x02
395	.byte	0x06, 0x10, 0x00, 0x00
396	.byte	0x00, 0x00, 0x00, 0x00
397	.byte	0x00, 0x00, 0x00, 0x00
398	.byte	0x04, 0x00, 0x53, 0x74
399	.byte	0x72, 0x75, 0x63, 0x74
400	.byte	0x00, 0x2e, 0x3f, 0x41
401	.byte	0x55, 0x53, 0x74, 0x72
402	.byte	0x75, 0x63, 0x74, 0x40
403	.byte	0x40, 0x00, 0xf2, 0xf1
404	# StringId (0x1008) {
405	#   TypeLeafKind: LF_STRING_ID (0x1605)
406	#   Id: 0x0
407	#   StringData: D:\src\llvmbuild\cl\Debug\x64\foo.cpp
408	# }
409	.byte	0x2e, 0x00, 0x05, 0x16
410	.byte	0x00, 0x00, 0x00, 0x00
411	.byte	0x44, 0x3a, 0x5c, 0x73
412	.byte	0x72, 0x63, 0x5c, 0x6c
413	.byte	0x6c, 0x76, 0x6d, 0x62
414	.byte	0x75, 0x69, 0x6c, 0x64
415	.byte	0x5c, 0x63, 0x6c, 0x5c
416	.byte	0x44, 0x65, 0x62, 0x75
417	.byte	0x67, 0x5c, 0x78, 0x36
418	.byte	0x34, 0x5c, 0x66, 0x6f
419	.byte	0x6f, 0x2e, 0x63, 0x70
420	.byte	0x70, 0x00, 0xf2, 0xf1
421	# UdtSourceLine (0x1009) {
422	#   TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
423	#   UDT: Struct (0x1007)
424	#   SourceFile: D:\src\llvmbuild\cl\Debug\x64\foo.cpp (0x1008)
425	#   LineNumber: 1
426	# }
427	.byte	0x0e, 0x00, 0x06, 0x16
428	.byte	0x07, 0x10, 0x00, 0x00
429	.byte	0x08, 0x10, 0x00, 0x00
430	.byte	0x01, 0x00, 0x00, 0x00
431	# StringId (0x100A) {
432	#   TypeLeafKind: LF_STRING_ID (0x1605)
433	#   Id: 0x0
434	#   StringData: D:\\src\\llvmbuild\\cl\\Debug\\x64
435	# }
436	.byte	0x2a, 0x00, 0x05, 0x16
437	.byte	0x00, 0x00, 0x00, 0x00
438	.byte	0x44, 0x3a, 0x5c, 0x5c
439	.byte	0x73, 0x72, 0x63, 0x5c
440	.byte	0x5c, 0x6c, 0x6c, 0x76
441	.byte	0x6d, 0x62, 0x75, 0x69
442	.byte	0x6c, 0x64, 0x5c, 0x5c
443	.byte	0x63, 0x6c, 0x5c, 0x5c
444	.byte	0x44, 0x65, 0x62, 0x75
445	.byte	0x67, 0x5c, 0x5c, 0x78
446	.byte	0x36, 0x34, 0x00, 0xf1
447	# StringId (0x100B) {
448	#   TypeLeafKind: LF_STRING_ID (0x1605)
449	#   Id: 0x0
450	#   StringData: foo.cpp
451	# }
452	.byte	0x0e, 0x00, 0x05, 0x16
453	.byte	0x00, 0x00, 0x00, 0x00
454	.byte	0x66, 0x6f, 0x6f, 0x2e
455	.byte	0x63, 0x70, 0x70, 0x00
456	# BuildInfo (0x100C) {
457	#   TypeLeafKind: LF_BUILDINFO (0x1603)
458	#   NumArgs: 5
459	#   Arguments [
460	#     ArgType: D:\\src\\llvmbuild\\cl\\Debug\\x64 (0x100A)
461	#     ArgType: 0x0
462	#     ArgType: foo.cpp (0x100B)
463	#     ArgType: 0x0
464	#     ArgType: 0x0
465	#   ]
466	# }
467	.byte	0x1a, 0x00, 0x03, 0x16
468	.byte	0x05, 0x00, 0x0a, 0x10
469	.byte	0x00, 0x00, 0x00, 0x00
470	.byte	0x00, 0x00, 0x0b, 0x10
471	.byte	0x00, 0x00, 0x00, 0x00
472	.byte	0x00, 0x00, 0x00, 0x00
473	.byte	0x00, 0x00, 0xf2, 0xf1
474
475	.addrsig
476	.addrsig_sym "?S@@3UStruct@@A"
477	.addrsig_sym "?SS@@3UStruct@@A"
478	.addrsig_sym "?I@@3HA"
479