[PDB] Fix linking of function symbols and local variables.
authorZachary Turner <zturner@google.com>
Tue, 8 Aug 2017 18:34:44 +0000 (18:34 +0000)
committerZachary Turner <zturner@google.com>
Tue, 8 Aug 2017 18:34:44 +0000 (18:34 +0000)
commit59e3ae827dae9d96096c0fb0b8f2e6d636e14b6c
tree5aa76c2408ab3ef006e9c8a1f11d8b495f343ba0
parente502f005383568e3e3d22e1e0a9005c29572e720
[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
14 files changed:
lld/COFF/PDB.cpp
lld/test/COFF/pdb-comdat.test
lld/test/COFF/pdb-invalid-func-type.yaml
lld/test/COFF/pdb-procid-remapping.test [new file with mode: 0644]
lld/test/COFF/pdb-scopes.test
lld/test/COFF/pdb-symbol-types.yaml
lld/test/COFF/pdb-type-server-simple.test
llvm/include/llvm/DebugInfo/CodeView/TypeDeserializer.h
llvm/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h
llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp
llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
llvm/tools/llvm-pdbutil/MinimalSymbolDumper.h
llvm/unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp