1 Consider this example program with an inline function "foo":
9 ==> pdb_comdat_main.c <==
16 ==> pdb_comdat_bar.c <==
22 Both object files will contain debug info for foo, but only the debug info from
23 pdb_comdat_main.obj should be included in the PDB.
25 RUN: rm -rf %t && mkdir -p %t && cd %t
26 RUN: yaml2obj %S/Inputs/pdb_comdat_main.yaml -o pdb_comdat_main.obj
27 RUN: yaml2obj %S/Inputs/pdb_comdat_bar.yaml -o pdb_comdat_bar.obj
28 RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main
29 RUN: llvm-pdbutil dump -l -symbols -globals %t.pdb | FileCheck %s
32 CHECK: ============================================================
33 CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`:
34 CHECK: c:\src\llvm-project\build\pdb_comdat_main.c (MD5: F969E51BBE373436D81492EB61387F36)
35 CHECK: c:\src\llvm-project\build\foo.h (MD5: D74D834EFAC3AE2B45E606A8320B1D5C)
36 CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`:
37 CHECK: c:\src\llvm-project\build\pdb_comdat_bar.c (MD5: 365279DB4FCBEDD721BBFC3B14A953C2)
38 CHECK-NOT: c:\src\llvm-project\build\foo.h
39 CHECK-LABEL: Mod 0002 | `* Linker *`:
41 CHECK-LABEL: Global Symbols
42 CHECK-NEXT: ============================================================
44 CHECK-NEXT: 84 | S_PROCREF [size = 20] `main`
45 CHECK-NEXT: module = 1, sum name = 0, offset = 120
46 CHECK-NEXT: 148 | S_PROCREF [size = 20] `bar`
47 CHECK-NEXT: module = 2, sum name = 0, offset = 120
48 CHECK-NEXT: 128 | S_PROCREF [size = 20] `foo`
49 CHECK-NEXT: module = 1, sum name = 0, offset = 208
50 CHECK-NEXT: 104 | S_GDATA32 [size = 24] `global`
51 CHECK-NEXT: type = 0x0074 (int), addr = 0003:0000
52 CHECK-NEXT: 168 | S_GDATA32 [size = 24] `global`
53 CHECK-NEXT: type = 0x0074 (int), addr = 0003:0000
56 CHECK: ============================================================
57 CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`:
58 CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_main.obj`
59 CHECK: 60 | S_COMPILE3 [size = 60]
60 CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
61 CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
62 CHECK: flags = security checks | hot patchable
63 CHECK: 120 | S_GPROC32 [size = 44] `main`
64 CHECK: parent = 0, end = 196, addr = 0001:0000, code size = 24
65 CHECK: debug start = 4, debug end = 19, flags = none
66 CHECK: 164 | S_FRAMEPROC [size = 32]
67 CHECK: size = 40, padding size = 0, offset to padding = 0
68 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
69 CHECK: flags = has async eh | opt speed
70 CHECK: 196 | S_END [size = 4]
71 CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100A`
72 CHECK: 208 | S_GPROC32 [size = 44] `foo`
73 CHECK: parent = 0, end = 284, addr = 0001:0032, code size = 15
74 CHECK: debug start = 0, debug end = 14, flags = none
75 CHECK: 252 | S_FRAMEPROC [size = 32]
76 CHECK: size = 0, padding size = 0, offset to padding = 0
77 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
78 CHECK: flags = marked inline | has async eh | opt speed
79 CHECK: 284 | S_END [size = 4]
80 CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`:
81 CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj`
82 CHECK: 60 | S_COMPILE3 [size = 60]
83 CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c
84 CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1
85 CHECK: flags = security checks | hot patchable
86 CHECK: 120 | S_GPROC32 [size = 44] `bar`
87 CHECK: parent = 0, end = 196, addr = 0001:0048, code size = 14
88 CHECK: debug start = 4, debug end = 9, flags = none
89 CHECK: 164 | S_FRAMEPROC [size = 32]
90 CHECK: size = 40, padding size = 0, offset to padding = 0
91 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000
92 CHECK: flags = has async eh | opt speed
93 CHECK: 196 | S_END [size = 4]
94 CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100D`
95 CHECK-NOT: S_GPROC32 {{.*}} `foo`
96 CHECK-LABEL: Mod 0002 | `* Linker *`:
98 Reorder the object files and verify that the other table is selected.
100 RUN: lld-link pdb_comdat_bar.obj pdb_comdat_main.obj -out:t.exe -debug -pdb:t.pdb -nodefaultlib -entry:main
101 RUN: llvm-pdbutil dump -l t.pdb | FileCheck %s --check-prefix=REORDER
103 REORDER-LABEL: Mod 0000 | `{{.*}}pdb_comdat_bar.obj`:
104 REORDER: c:\src\llvm-project\build\pdb_comdat_bar.c (MD5: 365279DB4FCBEDD721BBFC3B14A953C2)
105 REORDER: c:\src\llvm-project\build\foo.h (MD5: D74D834EFAC3AE2B45E606A8320B1D5C)
106 REORDER-LABEL: Mod 0001 | `{{.*}}pdb_comdat_main.obj`:
107 REORDER: c:\src\llvm-project\build\pdb_comdat_main.c
108 REORDER-NOT: c:\src\llvm-project\build\foo.h
109 REORDER-LABEL: Mod 0002 | `* Linker *`:
111 Make sure that we don't crash on non-prevailing debug sections if -debug is not enabled.
112 RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -nodefaultlib -entry:main