| Index: tools/pnacl-thaw/pnacl-thaw.cpp
|
| diff --git a/tools/pnacl-freeze/pnacl-freeze.cpp b/tools/pnacl-thaw/pnacl-thaw.cpp
|
| similarity index 72%
|
| copy from tools/pnacl-freeze/pnacl-freeze.cpp
|
| copy to tools/pnacl-thaw/pnacl-thaw.cpp
|
| index 963000a714a5063d224e00bc328348bcd343eba1..b28c357165779af6ec11dd6e5e19cb225e8b7f31 100644
|
| --- a/tools/pnacl-freeze/pnacl-freeze.cpp
|
| +++ b/tools/pnacl-thaw/pnacl-thaw.cpp
|
| @@ -3,20 +3,20 @@
|
| * be found in the LICENSE file.
|
| */
|
|
|
| -//===-- pnacl-freeze.cpp - The low-level NaCl bitcode freezer --------===//
|
| +//===-- pnacl-thaw.cpp - The low-level NaCl bitcode thawer ----------------===//
|
| //
|
| //===----------------------------------------------------------------------===//
|
| //
|
| -// Generates NaCl pexe wire format.
|
| +// Converts NaCl wire format back to LLVM bitcode.
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| #include "llvm/IR/LLVMContext.h"
|
| // Note: We need the following to provide the API for calling the NaCl
|
| -// Bitcode Writer to generate the frozen file.
|
| +// Bitcode Reader to read the frozen file.
|
| #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
|
| // Note: We need the following to provide the API for calling the (LLVM)
|
| -// Bitcode Reader to read in the corresonding pexe file to freeze.
|
| +// Bitcode Writer to generate the corresponding LLVM bitcode file.
|
| #include "llvm/Bitcode/ReaderWriter.h"
|
| #include "llvm/IR/Module.h"
|
| #include "llvm/Support/CommandLine.h"
|
| @@ -28,29 +28,28 @@
|
|
|
| using namespace llvm;
|
|
|
| -
|
| static cl::opt<std::string>
|
| -OutputFilename("o", cl::desc("Specify output filename"),
|
| +OutputFilename("o", cl::desc("Specify thawed pexe filename"),
|
| cl::value_desc("filename"));
|
|
|
| static cl::opt<std::string>
|
| -InputFilename(cl::Positional, cl::desc("<pexe file>"), cl::Required);
|
| +InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::Required);
|
|
|
| static void WriteOutputFile(const Module *M) {
|
|
|
| - std::string FrozenFilename =
|
| - (OutputFilename.size() == 0 ? (InputFilename + ".frozen") : OutputFilename);
|
| + std::string ThawedFilename =
|
| + (OutputFilename.size() == 0 ? (InputFilename + ".thawed") : OutputFilename);
|
|
|
| std::string ErrorInfo;
|
| OwningPtr<tool_output_file> Out
|
| - (new tool_output_file(FrozenFilename.c_str(), ErrorInfo,
|
| + (new tool_output_file(ThawedFilename.c_str(), ErrorInfo,
|
| raw_fd_ostream::F_Binary));
|
| if (!ErrorInfo.empty()) {
|
| errs() << ErrorInfo << '\n';
|
| exit(1);
|
| }
|
|
|
| - NaClWriteBitcodeToFile(M, Out->os());
|
| + WriteBitcodeToFile(M, Out->os());
|
|
|
| // Declare success.
|
| Out->keep();
|
| @@ -64,7 +63,8 @@ int main(int argc, char **argv) {
|
| LLVMContext &Context = getGlobalContext();
|
| llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
|
|
| - cl::ParseCommandLineOptions(argc, argv, "Generates NaCl pexe wire format\n");
|
| + cl::ParseCommandLineOptions(
|
| + argc, argv, "Converts NaCl pexe wire format into LLVM bitcode format\n");
|
|
|
| std::string ErrorMessage;
|
| std::auto_ptr<Module> M;
|
| @@ -73,8 +73,8 @@ int main(int argc, char **argv) {
|
| DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
|
| if (streamer) {
|
| std::string DisplayFilename = InputFilename;
|
| - M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
|
| - &ErrorMessage));
|
| + M.reset(getNaClStreamedBitcodeModule(DisplayFilename, streamer, Context,
|
| + &ErrorMessage));
|
| if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) {
|
| M.reset();
|
| }
|
|
|