aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-06-28 12:32:57 -0700
committerEli Bendersky <eliben@chromium.org>2013-06-28 12:32:57 -0700
commit46f7d96a210d9524fcb050a3e8bf5e0f65081442 (patch)
tree7fb8e7a8dae3f0f421e97afaf0905259dcf4aa7e /tools
parent2915b551ddcb24d34da8eeaae66c21de9714a7b2 (diff)
Teach llvm-nm to read PNaCl bitcode.
BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/18153009
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-nm/CMakeLists.txt2
-rw-r--r--tools/llvm-nm/LLVMBuild.txt2
-rw-r--r--tools/llvm-nm/Makefile2
-rw-r--r--tools/llvm-nm/llvm-nm.cpp29
4 files changed, 31 insertions, 4 deletions
diff --git a/tools/llvm-nm/CMakeLists.txt b/tools/llvm-nm/CMakeLists.txt
index b6cd80b477..de06ca28d9 100644
--- a/tools/llvm-nm/CMakeLists.txt
+++ b/tools/llvm-nm/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS archive bitreader object)
+set(LLVM_LINK_COMPONENTS archive bitreader naclbitreader object)
add_llvm_tool(llvm-nm
llvm-nm.cpp
diff --git a/tools/llvm-nm/LLVMBuild.txt b/tools/llvm-nm/LLVMBuild.txt
index 38ecbfd2e6..baba9ca50b 100644
--- a/tools/llvm-nm/LLVMBuild.txt
+++ b/tools/llvm-nm/LLVMBuild.txt
@@ -19,4 +19,4 @@
type = Tool
name = llvm-nm
parent = Tools
-required_libraries = Archive BitReader Object
+required_libraries = Archive BitReader NaClBitReader Object
diff --git a/tools/llvm-nm/Makefile b/tools/llvm-nm/Makefile
index d9cee98995..fe208a8f24 100644
--- a/tools/llvm-nm/Makefile
+++ b/tools/llvm-nm/Makefile
@@ -9,7 +9,7 @@
LEVEL := ../..
TOOLNAME := llvm-nm
-LINK_COMPONENTS := archive bitreader object
+LINK_COMPONENTS := archive bitreader naclbitreader object
# This tool has no plugins, optimize startup time.
TOOL_NO_EXPORTS := 1
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index a24aae6061..a4f9ab0730 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -19,6 +19,8 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/Bitcode/Archive.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" // @LOCALMOD
+#include "llvm/IRReader/IRReader.h" // @LOCALMOD
#include "llvm/IR/Module.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
@@ -122,6 +124,18 @@ namespace {
bool MultipleFiles = 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));
+ // @LOCALMOD-END
}
@@ -345,7 +359,20 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
LLVMContext &Context = getGlobalContext();
std::string ErrorMessage;
- if (magic == sys::fs::file_magic::bitcode) {
+ // @LOCALMOD-BEGIN
+ // Support parsing PNaCl bitcode files
+ if (InputFileFormat == PNaClFormat) {
+ Module *Result = NaClParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
+ if (Result) {
+ DumpSymbolNamesFromModule(Result);
+ delete Result;
+ } else {
+ error(ErrorMessage, Filename);
+ return;
+ }
+ }
+ // @LOCALMOD-END
+ else if (magic == sys::fs::file_magic::bitcode) {
Module *Result = 0;
Result = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
if (Result) {