| Consider this example program with an inline function "foo": |
| |
| ==> foo.h <== |
| extern int global; |
| __inline void foo() { |
| ++global; |
| } |
| void bar(); |
| ==> pdb_comdat_main.c <== |
| #include "foo.h" |
| int main(void) { |
| foo(); |
| bar(); |
| return 42; |
| } |
| ==> pdb_comdat_bar.c <== |
| #include "foo.h" |
| void bar(void) { |
| foo(); |
| } |
| |
| Both object files will contain debug info for foo, but only the debug info from |
| pdb_comdat_main.obj should be included in the PDB. |
| |
| RUN: rm -rf %t && mkdir -p %t && cd %t |
| RUN: yaml2obj %S/Inputs/pdb_comdat_main.yaml -o pdb_comdat_main.obj |
| RUN: yaml2obj %S/Inputs/pdb_comdat_bar.yaml -o pdb_comdat_bar.obj |
| RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main |
| RUN: llvm-pdbutil dump -l -symbols -globals %t.pdb | FileCheck %s |
| |
| CHECK: Lines |
| CHECK: ============================================================ |
| CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`: |
| CHECK: c:\src\llvm-project\build\pdb_comdat_main.c (MD5: F969E51BBE373436D81492EB61387F36) |
| CHECK: c:\src\llvm-project\build\foo.h (MD5: D74D834EFAC3AE2B45E606A8320B1D5C) |
| CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`: |
| CHECK: c:\src\llvm-project\build\pdb_comdat_bar.c (MD5: 365279DB4FCBEDD721BBFC3B14A953C2) |
| CHECK-NOT: c:\src\llvm-project\build\foo.h |
| CHECK-LABEL: Mod 0002 | `* Linker *`: |
| |
| CHECK-LABEL: Global Symbols |
| CHECK-NEXT: ============================================================ |
| CHECK-NEXT: Records |
| CHECK-NEXT: 84 | S_PROCREF [size = 20] `main` |
| CHECK-NEXT: module = 1, sum name = 0, offset = 120 |
| CHECK-NEXT: 148 | S_PROCREF [size = 20] `bar` |
| CHECK-NEXT: module = 2, sum name = 0, offset = 120 |
| CHECK-NEXT: 128 | S_PROCREF [size = 20] `foo` |
| CHECK-NEXT: module = 1, sum name = 0, offset = 208 |
| CHECK-NEXT: 104 | S_GDATA32 [size = 24] `global` |
| CHECK-NEXT: type = 0x0074 (int), addr = 0003:0000 |
| CHECK-NEXT: 168 | S_GDATA32 [size = 24] `global` |
| CHECK-NEXT: type = 0x0074 (int), addr = 0003:0000 |
| |
| CHECK: Symbols |
| CHECK: ============================================================ |
| CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`: |
| CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_main.obj` |
| CHECK: 60 | S_COMPILE3 [size = 60] |
| CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c |
| CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 |
| CHECK: flags = security checks | hot patchable |
| CHECK: 120 | S_GPROC32 [size = 44] `main` |
| CHECK: parent = 0, end = 196, addr = 0001:0000, code size = 24 |
| CHECK: debug start = 4, debug end = 19, flags = none |
| CHECK: 164 | S_FRAMEPROC [size = 32] |
| CHECK: size = 40, padding size = 0, offset to padding = 0 |
| CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 |
| CHECK: flags = has async eh | opt speed |
| CHECK: 196 | S_END [size = 4] |
| CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100A` |
| CHECK: 208 | S_GPROC32 [size = 44] `foo` |
| CHECK: parent = 0, end = 284, addr = 0001:0032, code size = 15 |
| CHECK: debug start = 0, debug end = 14, flags = none |
| CHECK: 252 | S_FRAMEPROC [size = 32] |
| CHECK: size = 0, padding size = 0, offset to padding = 0 |
| CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 |
| CHECK: flags = marked inline | has async eh | opt speed |
| CHECK: 284 | S_END [size = 4] |
| CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`: |
| CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj` |
| CHECK: 60 | S_COMPILE3 [size = 60] |
| CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c |
| CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 |
| CHECK: flags = security checks | hot patchable |
| CHECK: 120 | S_GPROC32 [size = 44] `bar` |
| CHECK: parent = 0, end = 196, addr = 0001:0048, code size = 14 |
| CHECK: debug start = 4, debug end = 9, flags = none |
| CHECK: 164 | S_FRAMEPROC [size = 32] |
| CHECK: size = 40, padding size = 0, offset to padding = 0 |
| CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 |
| CHECK: flags = has async eh | opt speed |
| CHECK: 196 | S_END [size = 4] |
| CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100D` |
| CHECK-NOT: S_GPROC32 {{.*}} `foo` |
| CHECK-LABEL: Mod 0002 | `* Linker *`: |
| |
| Reorder the object files and verify that the other table is selected. |
| |
| RUN: lld-link pdb_comdat_bar.obj pdb_comdat_main.obj -out:t.exe -debug -pdb:t.pdb -nodefaultlib -entry:main |
| RUN: llvm-pdbutil dump -l t.pdb | FileCheck %s --check-prefix=REORDER |
| |
| REORDER-LABEL: Mod 0000 | `{{.*}}pdb_comdat_bar.obj`: |
| REORDER: c:\src\llvm-project\build\pdb_comdat_bar.c (MD5: 365279DB4FCBEDD721BBFC3B14A953C2) |
| REORDER: c:\src\llvm-project\build\foo.h (MD5: D74D834EFAC3AE2B45E606A8320B1D5C) |
| REORDER-LABEL: Mod 0001 | `{{.*}}pdb_comdat_main.obj`: |
| REORDER: c:\src\llvm-project\build\pdb_comdat_main.c |
| REORDER-NOT: c:\src\llvm-project\build\foo.h |
| REORDER-LABEL: Mod 0002 | `* Linker *`: |
| |
| Make sure that we don't crash on non-prevailing debug sections if -debug is not enabled. |
| RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -nodefaultlib -entry:main |