Propogate the error message, not just the error state.
[oota-llvm.git] / lib / ExecutionEngine / RuntimeDyld / RuntimeDyld.cpp
index 4fb017d75763811414bba1947a6e60913c982611..aa4f2f9ad0b394d638a5ecc24b30d3346ea56b97 100644 (file)
@@ -51,6 +51,8 @@ class RuntimeDyldImpl {
                      const InMemoryStruct<macho::SymtabLoadCommand> &SymtabLC);
 
 public:
+  RuntimeDyldImpl() : HasError(false) {}
+
   bool loadObject(MemoryBuffer *InputBuffer);
 
   void *getSymbolAddress(StringRef Name) {
@@ -143,6 +145,10 @@ loadSegment32(const MachOObject *Obj,
     SymbolTable[Name] = Address;
   }
 
+  // We've loaded the section; now mark the functions in it as executable.
+  // FIXME: We really should use the JITMemoryManager for this.
+  sys::Memory::setRangeExecutable(Data.base(), Data.size());
+
   delete SectionBases;
   return false;
 }
@@ -218,12 +224,14 @@ loadSegment64(const MachOObject *Obj,
     SymbolTable[Name] = Address;
   }
 
+  // We've loaded the section; now mark the functions in it as executable.
+  // FIXME: We really should use the JITMemoryManager for this.
+  sys::Memory::setRangeExecutable(Data.base(), Data.size());
+
   delete SectionBases;
   return false;
 }
 
-
-
 bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) {
   // If the linker is in an error state, don't do anything.
   if (hasError())
@@ -326,4 +334,9 @@ sys::MemoryBlock RuntimeDyld::getMemoryBlock() {
   return Dyld->getMemoryBlock();
 }
 
+StringRef RuntimeDyld::getErrorString()
+{
+  return Dyld->getErrorString();
+}
+
 } // end namespace llvm