summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj/llvm-readobj.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-05-14 00:02:53 +0000
committerReid Kleckner <rnk@google.com>2016-05-14 00:02:53 +0000
commit0b269748a6592c263394123a0de15740ad19c152 (patch)
tree5cd58f5a187c9d10b89a60b354007f207313b65c /llvm/tools/llvm-readobj/llvm-readobj.cpp
parent32b2897af6101e843f8fa90750e0de2a8a84d1cd (diff)
downloadbcm5719-llvm-0b269748a6592c263394123a0de15740ad19c152.tar.gz
bcm5719-llvm-0b269748a6592c263394123a0de15740ad19c152.zip
[codeview] Add type stream merging prototype
Summary: This code is intended to be used as part of LLD's PDB writing. Until that exists, this is exposed via llvm-readobj for testing purposes. Type stream merging uses the following algorithm: - Begin with a new empty stream, and a new empty hash table that maps from type record contents to new type index. - For each new type stream, maintain a map from source type index to destination type index. - For each record, copy it and rewrite its type indices to be valid in the destination type stream. - If the new type record is not already present in the destination stream hash table, append it to the destination type stream, assign it the next type index, and update the two hash tables. - If the type record already exists in the destination stream, discard it and update the type index map to forward the source type index to the existing destination type index. Reviewers: zturner, ruiu Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20122 llvm-svn: 269521
Diffstat (limited to 'llvm/tools/llvm-readobj/llvm-readobj.cpp')
-rw-r--r--llvm/tools/llvm-readobj/llvm-readobj.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp
index c2964c5f5e1..0a48918cf38 100644
--- a/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -22,6 +22,7 @@
#include "llvm-readobj.h"
#include "Error.h"
#include "ObjDumper.h"
+#include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Object/ELFObjectFile.h"
@@ -144,6 +145,11 @@ namespace opts {
cl::opt<bool> CodeView("codeview",
cl::desc("Display CodeView debug information"));
+ // -codeview-merged-types
+ cl::opt<bool>
+ CodeViewMergedTypes("codeview-merged-types",
+ cl::desc("Display the merged CodeView type stream"));
+
// -codeview-subsection-bytes
cl::opt<bool> CodeViewSubsectionBytes(
"codeview-subsection-bytes",
@@ -296,6 +302,8 @@ static bool isMipsArch(unsigned Arch) {
}
}
+static llvm::codeview::MemoryTypeTableBuilder CVTypes;
+
/// @brief Creates an format-specific object file dumper.
static std::error_code createDumper(const ObjectFile *Obj,
ScopedPrinter &Writer,
@@ -386,6 +394,8 @@ static void dumpObject(const ObjectFile *Obj) {
Dumper->printCOFFBaseReloc();
if (opts::CodeView)
Dumper->printCodeViewDebugInfo();
+ if (opts::CodeViewMergedTypes)
+ Dumper->mergeCodeViewTypes(CVTypes);
}
if (Obj->isMachO()) {
if (opts::MachODataInCode)
@@ -478,5 +488,10 @@ int main(int argc, const char *argv[]) {
std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
dumpInput);
+ if (opts::CodeViewMergedTypes) {
+ ScopedPrinter W(outs());
+ dumpCodeViewMergedTypes(W, CVTypes);
+ }
+
return 0;
}
OpenPOWER on IntegriCloud