Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PDB] Fix linking of function symbols and local variables.
The compiler outputs PROC32_ID symbols into the object files for functions, and these symbols have an embedded type index which, when copied to the PDB, refer to the IPI stream. However, the symbols themselves are also converted into regular symbols (e.g. S_GPROC32_ID -> S_GPROC32), and type indices in the regular symbol records refer to the TPI stream. So this patch applies two fixes to function records. 1. It converts ID symbols to the proper non-ID record type. 2. After remapping the type index from the object file's index space to the PDB file/IPI stream's index space, it then remaps that index to the TPI stream's index space by. Besides functions, during the remapping process we were also discarding symbol record types which we did not recognize. In particular, we were discarding S_BPREL32 records, which is what MSVC uses to describe local variables on the stack. So this patch fixes that as well by copying them to the PDB. Differential Revision: https://reviews.llvm.org/D36426 llvm-svn: 310394
- Loading branch information
Zachary Turner
committed
Aug 8, 2017
1 parent
e502f00
commit 59e3ae8
Showing
14 changed files
with
207 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj | ||
# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj | ||
# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ | ||
# RUN: %t1.obj %t2.obj | ||
|
||
# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s | ||
|
||
CHECK: Symbols | ||
CHECK-NEXT: ============================================================ | ||
CHECK-LABEL: Mod 0000 | | ||
CHECK: 92 | S_GPROC32 [size = 44] `main` | ||
CHECK-NEXT: parent = 0, end = 168, addr = 0002:0000, code size = 14 | ||
CHECK-NEXT: type = `0x1004 (int (<no type>))`, debug start = 4, debug end = 9, flags = none | ||
CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] | ||
CHECK-NEXT: size = 40, padding size = 0, offset to padding = 0 | ||
CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 | ||
CHECK-NEXT: flags = has async eh | opt speed | ||
CHECK-NEXT: 168 | S_END [size = 4] | ||
CHECK-LABEL: Mod 0001 | | ||
CHECK: 92 | S_GPROC32 [size = 44] `foo` | ||
CHECK-NEXT: parent = 0, end = 168, addr = 0002:0016, code size = 6 | ||
CHECK-NEXT: type = `0x1001 (int ())`, debug start = 0, debug end = 5, flags = none | ||
CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] | ||
CHECK-NEXT: size = 0, padding size = 0, offset to padding = 0 | ||
CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 | ||
CHECK-NEXT: flags = has async eh | opt speed | ||
CHECK-NEXT: 168 | S_END [size = 4] | ||
CHECK-LABEL: Mod 0002 | | ||
CHECK: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.