Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: tools/llvm-nm/llvm-nm.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/llvm-nm/Makefile ('k') | tools/lto/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/llvm-nm/llvm-nm.cpp
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index be2c4fad948f68631b2b6d8ac8d5786876564d5f..f164e6924b440443cd062ed333c4c9424716f494 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -20,6 +20,8 @@
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" // @LOCALMOD
+#include "llvm/IRReader/IRReader.h" // @LOCALMOD
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/ELFObjectFile.h"
@@ -159,6 +161,21 @@ bool MultipleFiles = false;
bool HadError = false;
std::string ToolName;
+
+// @LOCALMOD-BEGIN
+cl::opt<NaClFileFormat> InputFileFormat(
+ "bitcode-format", cl::desc("Define format of input file:"),
+ cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
+ clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
+ clEnumValEnd),
+ cl::init(LLVMFormat));
+
+static cl::opt<bool>
+VerboseErrors(
+ "verbose-parse-errors",
+ cl::desc("Print out more descriptive PNaCl bitcode parse errors"),
+ cl::init(false));
+// @LOCALMOD-END
}
static void error(Twine Message, Twine Path = Twine()) {
@@ -1008,6 +1025,35 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
return;
LLVMContext &Context = getGlobalContext();
+
+ // @LOCALMOD-BEGIN
+ // Support parsing PNaCl bitcode files
+ switch (InputFileFormat) {
+ case LLVMFormat:
+ break;
+ case PNaClFormat:
+ case AutodetectFileFormat:
+ report_fatal_error("command only supports LLVM file format!");
+ }
+ /* TODO(jfb) This is currently broken: the code base now requires an Object.
+ if (InputFileFormat == PNaClFormat) {
+ std::string VerboseBuffer;
+ raw_string_ostream VerboseStrm(VerboseBuffer);
+ raw_ostream *Verbose = VerboseErrors ? &VerboseStrm : nullptr;
+ ErrorOr<Module *> Result =
+ NaClParseBitcodeFile(BufferOrErr.get().release(), Verbose,
+ Context);
+ if (Result) {
+ DumpSymbolNamesFromModule(Result.get());
+ delete Result;
+ } else {
+ error(VerboseStrm.str() + Result.message()), Filename);
+ return;
+ }
+ }
+ */
+ // @LOCALMOD-END
+
ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(
BufferOrErr.get()->getMemBufferRef(), NoLLVMBitcode ? nullptr : &Context);
if (error(BinaryOrErr.getError(), Filename))
« no previous file with comments | « tools/llvm-nm/Makefile ('k') | tools/lto/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698