Move DIContext.h to common DebugInfo location.
[oota-llvm.git] / tools / llvm-rtdyld / llvm-rtdyld.cpp
index 244ed27256957b7656819bacadbded57c3296a9b..7f254da5de0fcf84d92695d42ba0c26e898e9a53 100644 (file)
@@ -12,7 +12,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/StringMap.h"
-#include "llvm/DebugInfo/DWARF/DIContext.h"
+#include "llvm/DebugInfo/DIContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
 #include "llvm/ExecutionEngine/RuntimeDyld.h"
 #include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
@@ -227,7 +228,7 @@ static int printLineInfoForInput() {
     OwningBinary<ObjectFile> DebugObj = LoadedObjInfo->getObjectForDebug(Obj);
 
     std::unique_ptr<DIContext> Context(
-      DIContext::getDWARFContext(*DebugObj.getBinary()));
+      new DWARFContextInMemory(*DebugObj.getBinary()));
 
     // Use symbol info to iterate functions in the object.
     for (object::symbol_iterator I = DebugObj.getBinary()->symbol_begin(),
@@ -267,6 +268,11 @@ static int executeInput() {
   TrivialMemoryManager MemMgr;
   RuntimeDyld Dyld(MemMgr, MemMgr);
 
+  // FIXME: Preserve buffers until resolveRelocations time to work around a bug
+  //        in RuntimeDyldELF.
+  // This fixme should be fixed ASAP. This is a very brittle workaround.
+  std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
+
   // If we don't have any input files, read from stdin.
   if (!InputFileList.size())
     InputFileList.push_back("-");
@@ -283,6 +289,7 @@ static int executeInput() {
       return Error("unable to create object file: '" + EC.message() + "'");
 
     ObjectFile &Obj = **MaybeObj;
+    InputBuffers.push_back(std::move(*InputBuffer));
 
     // Load the object file
     Dyld.loadObject(Obj);
@@ -519,6 +526,11 @@ static int linkAndVerify() {
   RuntimeDyldChecker Checker(Dyld, Disassembler.get(), InstPrinter.get(),
                              llvm::dbgs());
 
+  // FIXME: Preserve buffers until resolveRelocations time to work around a bug
+  //        in RuntimeDyldELF.
+  // This fixme should be fixed ASAP. This is a very brittle workaround.
+  std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
+
   // If we don't have any input files, read from stdin.
   if (!InputFileList.size())
     InputFileList.push_back("-");
@@ -537,6 +549,7 @@ static int linkAndVerify() {
       return Error("unable to create object file: '" + EC.message() + "'");
 
     ObjectFile &Obj = **MaybeObj;
+    InputBuffers.push_back(std::move(*InputBuffer));
 
     // Load the object file
     Dyld.loadObject(Obj);