diff options
author | Zachary Turner <zturner@google.com> | 2017-06-05 21:40:33 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-05 21:40:33 +0000 |
commit | 349c18f8377aa46af024e0ba7d312304ad2ac28a (patch) | |
tree | 1bbd719c419cb69fa87cd037de57ab206216741e /llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp | |
parent | 5b0bf2ff0d80998804871ab151ec2f00ff2dee8b (diff) | |
download | llvm-349c18f8377aa46af024e0ba7d312304ad2ac28a.zip llvm-349c18f8377aa46af024e0ba7d312304ad2ac28a.tar.gz llvm-349c18f8377aa46af024e0ba7d312304ad2ac28a.tar.bz2 |
[CodeView] Handle Cross Module Imports and Exports.
While it's not entirely clear why a compiler or linker might
put this information into an object or PDB file, one has been
spotted in the wild which was causing llvm-pdbdump to crash.
This patch adds support for reading-writing these sections.
Since I don't know how to get one of the native tools to
generate this kind of debug info, the only test here is one
in which we feed YAML into the tool to produce a PDB and
then spit out YAML from the resulting PDB and make sure that
it matches.
llvm-svn: 304738
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp new file mode 100644 index 0000000..d8dca5d --- /dev/null +++ b/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp @@ -0,0 +1,49 @@ +//===- DebugCrossExSubsection.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h" + +#include "llvm/DebugInfo/CodeView/CodeViewError.h" + +using namespace llvm; +using namespace llvm::codeview; + +Error DebugCrossModuleExportsSubsectionRef::initialize( + BinaryStreamReader Reader) { + if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0) + return make_error<CodeViewError>( + cv_error_code::corrupt_record, + "Cross Scope Exports section is an invalid size!"); + + uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport); + return Reader.readArray(References, Size); +} + +Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) { + BinaryStreamReader Reader(Stream); + return initialize(Reader); +} + +void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local, + uint32_t Global) { + Mappings[Local] = Global; +} + +uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const { + return Mappings.size() * sizeof(CrossModuleExport); +} + +Error DebugCrossModuleExportsSubsection::commit( + BinaryStreamWriter &Writer) const { + for (const auto &M : Mappings) { + if (auto EC = Writer.writeObject(M)) + return EC; + } + return Error::success(); +} |