2017-06-21 01:14:09 +08:00
|
|
|
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
|
2017-09-02 04:06:56 +08:00
|
|
|
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
|
2017-06-21 01:14:09 +08:00
|
|
|
|
|
|
|
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 *`:
|
|
|
|
|
2017-08-12 03:00:03 +08:00
|
|
|
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: 128 | S_PROCREF [size = 20] `foo`
|
|
|
|
CHECK-NEXT: module = 1, sum name = 0, offset = 208
|
|
|
|
CHECK-NEXT: 148 | S_PROCREF [size = 20] `bar`
|
|
|
|
CHECK-NEXT: module = 2, sum name = 0, offset = 120
|
|
|
|
CHECK-NEXT: 104 | S_GDATA32 [size = 24] `global`
|
|
|
|
CHECK-NEXT: type = 0x0074 (int), addr = 0000:0000
|
|
|
|
CHECK-NEXT: 168 | S_GDATA32 [size = 24] `global`
|
|
|
|
CHECK-NEXT: type = 0x0074 (int), addr = 0000:0000
|
|
|
|
|
2017-06-22 01:25:56 +08:00
|
|
|
CHECK: Symbols
|
|
|
|
CHECK: ============================================================
|
|
|
|
CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`:
|
2017-07-01 05:35:00 +08:00
|
|
|
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
|
2017-08-09 02:34:44 +08:00
|
|
|
CHECK: 120 | S_GPROC32 [size = 44] `main`
|
2018-04-05 03:15:55 +08:00
|
|
|
CHECK: parent = 0, end = 196, addr = 0001:0000, code size = 24
|
2017-07-01 05:35:00 +08:00
|
|
|
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]
|
2017-08-12 03:00:03 +08:00
|
|
|
CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100A`
|
|
|
|
CHECK: 208 | S_GPROC32 [size = 44] `foo`
|
2018-04-05 03:15:55 +08:00
|
|
|
CHECK: parent = 0, end = 284, addr = 0001:0032, code size = 15
|
2017-07-01 05:35:00 +08:00
|
|
|
CHECK: debug start = 0, debug end = 14, flags = none
|
2017-08-12 03:00:03 +08:00
|
|
|
CHECK: 252 | S_FRAMEPROC [size = 32]
|
2017-07-01 05:35:00 +08:00
|
|
|
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
|
2017-08-12 03:00:03 +08:00
|
|
|
CHECK: 284 | S_END [size = 4]
|
2017-06-22 01:25:56 +08:00
|
|
|
CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`:
|
2017-07-01 05:35:00 +08:00
|
|
|
CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj`
|
|
|
|
CHECK: 60 | S_COMPILE3 [size = 60]
|
2017-06-22 01:25:56 +08:00
|
|
|
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
|
2017-08-09 02:34:44 +08:00
|
|
|
CHECK: 120 | S_GPROC32 [size = 44] `bar`
|
2018-04-05 03:15:55 +08:00
|
|
|
CHECK: parent = 0, end = 196, addr = 0001:0048, code size = 14
|
2017-06-22 01:25:56 +08:00
|
|
|
CHECK: debug start = 4, debug end = 9, flags = none
|
2017-07-01 05:35:00 +08:00
|
|
|
CHECK: 164 | S_FRAMEPROC [size = 32]
|
2017-06-22 01:25:56 +08:00
|
|
|
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
|
2017-07-01 05:35:00 +08:00
|
|
|
CHECK: 196 | S_END [size = 4]
|
2017-08-12 03:00:03 +08:00
|
|
|
CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100D`
|
2017-08-09 02:34:44 +08:00
|
|
|
CHECK-NOT: S_GPROC32 {{.*}} `foo`
|
2017-06-22 01:25:56 +08:00
|
|
|
CHECK-LABEL: Mod 0002 | `* Linker *`:
|
|
|
|
|
2017-06-21 01:14:09 +08:00
|
|
|
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
|
2017-06-23 04:57:39 +08:00
|
|
|
RUN: llvm-pdbutil dump -l t.pdb | FileCheck %s --check-prefix=REORDER
|
2017-06-21 01:14:09 +08:00
|
|
|
|
|
|
|
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 *`:
|
2017-11-28 09:30:07 +08:00
|
|
|
|
|
|
|
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
|