Skip to content

Commit

Permalink
Revert r196639 while I investigate a bot failure.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196641 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lhames committed Dec 7, 2013
1 parent d4ef813 commit a49701d
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 342 deletions.
32 changes: 0 additions & 32 deletions include/llvm/ExecutionEngine/ExecutionEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class RTDyldMemoryManager;
class Triple;
class Type;

namespace object {
class Archive;
class ObjectFile;
}

/// \brief Helper class for helping synchronize access to the global address map
/// table.
class ExecutionEngineState {
Expand Down Expand Up @@ -209,33 +204,6 @@ class ExecutionEngine {
Modules.push_back(M);
}

/// addObjectFile - Add an ObjectFile to the execution engine.
///
/// This method is only supported by MCJIT. MCJIT will immediately load the
/// object into memory and adds its symbols to the list used to resolve
/// external symbols while preparing other objects for execution.
///
/// Objects added using this function will not be made executable until
/// needed by another object.
///
/// MCJIT will take ownership of the ObjectFile.
virtual void addObjectFile(object::ObjectFile *O) {
llvm_unreachable(
"ExecutionEngine subclass doesn't implement addObjectFile.");
}

/// addArchive - Add an Archive to the execution engine.
///
/// This method is only supported by MCJIT. MCJIT will use the archive to
/// resolve external symbols in objects it is loading. If a symbol is found
/// in the Archive the contained object file will be extracted (in memory)
/// and loaded for possible execution.
///
/// MCJIT will take ownership of the Archive.
virtual void addArchive(object::Archive *A) {
llvm_unreachable("ExecutionEngine subclass doesn't implement addArchive.");
}

//===--------------------------------------------------------------------===//

const DataLayout *getDataLayout() const { return TD; }
Expand Down
10 changes: 0 additions & 10 deletions include/llvm/ExecutionEngine/RuntimeDyld.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

namespace llvm {

namespace object {
class ObjectFile;
}

class RuntimeDyldImpl;
class ObjectImage;

Expand All @@ -50,12 +46,6 @@ class RuntimeDyld {
/// failure, the input buffer will be deleted.
ObjectImage *loadObject(ObjectBuffer *InputBuffer);

/// Prepare the referenced object file for execution.
/// Ownership of the input object is transferred to the ObjectImage
/// instance returned from this function if successful. In the case of load
/// failure, the input object will be deleted.
ObjectImage *loadObject(object::ObjectFile *InputObject);

/// Get the address of our local copy of the symbol. This may or may not
/// be the address used for relocation (clients can copy the data around
/// and resolve relocatons based on where they put it).
Expand Down
56 changes: 5 additions & 51 deletions lib/ExecutionEngine/MCJIT/MCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Object/Archive.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
Expand Down Expand Up @@ -79,24 +78,15 @@ MCJIT::~MCJIT() {
Modules.clear();
Dyld.deregisterEHFrames();

LoadedObjectList::iterator it, end;
for (it = LoadedObjects.begin(), end = LoadedObjects.end(); it != end; ++it) {
ObjectImage *Obj = *it;
LoadedObjectMap::iterator it, end = LoadedObjects.end();
for (it = LoadedObjects.begin(); it != end; ++it) {
ObjectImage *Obj = it->second;
if (Obj) {
NotifyFreeingObject(*Obj);
delete Obj;
}
}
LoadedObjects.clear();


SmallVector<object::Archive *, 2>::iterator ArIt, ArEnd;
for (ArIt = Archives.begin(), ArEnd = Archives.end(); ArIt != ArEnd; ++ArIt) {
object::Archive *A = *ArIt;
delete A;
}
Archives.clear();

delete TM;
}

Expand All @@ -112,21 +102,6 @@ bool MCJIT::removeModule(Module *M) {



void MCJIT::addObjectFile(object::ObjectFile *Obj) {
ObjectImage *LoadedObject = Dyld.loadObject(Obj);
if (!LoadedObject)
report_fatal_error(Dyld.getErrorString());

LoadedObjects.push_back(LoadedObject);

NotifyObjectEmitted(*LoadedObject);
}

void MCJIT::addArchive(object::Archive *A) {
Archives.push_back(A);
}


void MCJIT::setObjectCache(ObjectCache* NewCache) {
MutexGuard locked(lock);
ObjCache = NewCache;
Expand Down Expand Up @@ -196,9 +171,9 @@ void MCJIT::generateCodeForModule(Module *M) {
}

// Load the object into the dynamic linker.
// MCJIT now owns the ObjectImage pointer (via its LoadedObjects list).
// MCJIT now owns the ObjectImage pointer (via its LoadedObjects map).
ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.take());
LoadedObjects.push_back(LoadedObject);
LoadedObjects[M] = LoadedObject;
if (!LoadedObject)
report_fatal_error(Dyld.getErrorString());

Expand Down Expand Up @@ -296,27 +271,6 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name,
if (Addr)
return Addr;

SmallVector<object::Archive*, 2>::iterator I, E;
for (I = Archives.begin(), E = Archives.end(); I != E; ++I) {
object::Archive *A = *I;
// Look for our symbols in each Archive
object::Archive::child_iterator ChildIt = A->findSym(Name);
if (ChildIt != A->end_children()) {
OwningPtr<object::Binary> ChildBin;
// FIXME: Support nested archives?
if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) {
object::ObjectFile *OF = reinterpret_cast<object::ObjectFile *>(
ChildBin.take());
// This causes the object file to be loaded.
addObjectFile(OF);
// The address should be here now.
Addr = getExistingSymbolAddress(Name);
if (Addr)
return Addr;
}
}
}

// If it hasn't already been generated, see if it's in one of our modules.
Module *M = findModuleForSymbol(Name, CheckFunctionsOnly);
if (!M)
Expand Down
8 changes: 2 additions & 6 deletions lib/ExecutionEngine/MCJIT/MCJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ class MCJIT : public ExecutionEngine {

OwningModuleContainer OwnedModules;

SmallVector<object::Archive*, 2> Archives;

typedef SmallVector<ObjectImage *, 2> LoadedObjectList;
LoadedObjectList LoadedObjects;
typedef DenseMap<Module *, ObjectImage *> LoadedObjectMap;
LoadedObjectMap LoadedObjects;

// An optional ObjectCache to be notified of compiled objects and used to
// perform lookup of pre-compiled code to avoid re-compilation.
Expand All @@ -229,8 +227,6 @@ class MCJIT : public ExecutionEngine {
/// @name ExecutionEngine interface implementation
/// @{
virtual void addModule(Module *M);
virtual void addObjectFile(object::ObjectFile *O);
virtual void addArchive(object::Archive *O);
virtual bool removeModule(Module *M);

/// FindFunctionNamed - Search all of the active modules to find the one that
Expand Down
6 changes: 0 additions & 6 deletions lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@

namespace llvm {

namespace object {
class ObjectFile;
}

class ObjectImageCommon : public ObjectImage {
ObjectImageCommon(); // = delete
ObjectImageCommon(const ObjectImageCommon &other); // = delete
Expand All @@ -46,8 +42,6 @@ class ObjectImageCommon : public ObjectImage {
{
ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
}
ObjectImageCommon(object::ObjectFile* Input)
: ObjectImage(NULL), ObjFile(Input) {}
virtual ~ObjectImageCommon() { delete ObjFile; }

virtual object::symbol_iterator begin_symbols() const
Expand Down
34 changes: 3 additions & 31 deletions lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,12 @@ ObjectImage *RuntimeDyldImpl::createObjectImage(ObjectBuffer *InputBuffer) {
return new ObjectImageCommon(InputBuffer);
}

ObjectImage *RuntimeDyldImpl::createObjectImageFromFile(ObjectFile *InputObject) {
return new ObjectImageCommon(InputObject);
}

ObjectImage *RuntimeDyldImpl::loadObject(ObjectFile *InputObject) {
return loadObject(createObjectImageFromFile(InputObject));
}

ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) {
return loadObject(createObjectImage(InputBuffer));
}

ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
MutexGuard locked(lock);

OwningPtr<ObjectImage> obj(InputObject);
OwningPtr<ObjectImage> obj(createObjectImage(InputBuffer));
if (!obj)
return NULL;
report_fatal_error("Unable to create object image from memory buffer!");

// Save information about our target
Arch = (Triple::ArchType)obj->getArch();
Expand Down Expand Up @@ -151,7 +139,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
if (si == obj->end_sections()) continue;
Check(si->getContents(SectionData));
Check(si->isText(IsCode));
const uint8_t* SymPtr = (const uint8_t*)InputObject->getData().data() +
const uint8_t* SymPtr = (const uint8_t*)InputBuffer->getBufferStart() +
(uintptr_t)FileOffset;
uintptr_t SectOffset = (uintptr_t)(SymPtr -
(const uint8_t*)SectionData.begin());
Expand Down Expand Up @@ -575,22 +563,6 @@ RuntimeDyld::~RuntimeDyld() {
delete Dyld;
}

ObjectImage *RuntimeDyld::loadObject(ObjectFile *InputObject) {
if (!Dyld) {
if (InputObject->isELF())
Dyld = new RuntimeDyldELF(MM);
else if (InputObject->isMachO())
Dyld = new RuntimeDyldMachO(MM);
else
report_fatal_error("Incompatible object format!");
} else {
if (!Dyld->isCompatibleFile(InputObject))
report_fatal_error("Incompatible object format!");
}

return Dyld->loadObject(InputObject);
}

ObjectImage *RuntimeDyld::loadObject(ObjectBuffer *InputBuffer) {
if (!Dyld) {
sys::fs::file_magic Type =
Expand Down
40 changes: 0 additions & 40 deletions lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/MemoryBuffer.h"

using namespace llvm;
using namespace llvm::object;

Expand Down Expand Up @@ -180,39 +178,6 @@ void RuntimeDyldELF::deregisterEHFrames() {
RegisteredEHFrameSections.clear();
}

ObjectImage *RuntimeDyldELF::createObjectImageFromFile(object::ObjectFile *ObjFile) {
if (!ObjFile)
return NULL;

error_code ec;
MemoryBuffer* Buffer = MemoryBuffer::getMemBuffer(ObjFile->getData(),
"",
false);

if (ObjFile->getBytesInAddress() == 4 && ObjFile->isLittleEndian()) {
DyldELFObject<ELFType<support::little, 4, false> > *Obj =
new DyldELFObject<ELFType<support::little, 4, false> >(Buffer, ec);
return new ELFObjectImage<ELFType<support::little, 4, false> >(NULL, Obj);
}
else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) {
DyldELFObject<ELFType<support::big, 4, false> > *Obj =
new DyldELFObject<ELFType<support::big, 4, false> >(Buffer, ec);
return new ELFObjectImage<ELFType<support::big, 4, false> >(NULL, Obj);
}
else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) {
DyldELFObject<ELFType<support::big, 8, true> > *Obj =
new DyldELFObject<ELFType<support::big, 8, true> >(Buffer, ec);
return new ELFObjectImage<ELFType<support::big, 8, true> >(NULL, Obj);
}
else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) {
DyldELFObject<ELFType<support::little, 8, true> > *Obj =
new DyldELFObject<ELFType<support::little, 8, true> >(Buffer, ec);
return new ELFObjectImage<ELFType<support::little, 8, true> >(NULL, Obj);
}
else
llvm_unreachable("Unexpected ELF format");
}

ObjectImage *RuntimeDyldELF::createObjectImage(ObjectBuffer *Buffer) {
if (Buffer->getBufferSize() < ELF::EI_NIDENT)
llvm_unreachable("Unexpected ELF object size");
Expand Down Expand Up @@ -1438,9 +1403,4 @@ bool RuntimeDyldELF::isCompatibleFormat(const ObjectBuffer *Buffer) const {
return false;
return (memcmp(Buffer->getBufferStart(), ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0;
}

bool RuntimeDyldELF::isCompatibleFile(const object::ObjectFile *Obj) const {
return Obj->isELF();
}

} // namespace llvm
2 changes: 0 additions & 2 deletions lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ class RuntimeDyldELF : public RuntimeDyldImpl {
const SymbolTableMap &Symbols,
StubMap &Stubs);
virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
virtual bool isCompatibleFile(const object::ObjectFile *Buffer) const;
virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
virtual ObjectImage *createObjectImageFromFile(object::ObjectFile *Obj);
virtual void registerEHFrames();
virtual void deregisterEHFrames();
virtual void finalizeLoad(ObjSectionToIDMap &SectionMap);
Expand Down
7 changes: 0 additions & 7 deletions lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,12 @@ class RuntimeDyldImpl {
virtual void updateGOTEntries(StringRef Name, uint64_t Addr) {}

virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
virtual ObjectImage *createObjectImageFromFile(object::ObjectFile *InputObject);

// This is the implementation for the two public overloads
ObjectImage *loadObject(ObjectImage *InputObject);

public:
RuntimeDyldImpl(RTDyldMemoryManager *mm) : MemMgr(mm), HasError(false) {}

virtual ~RuntimeDyldImpl();

ObjectImage *loadObject(ObjectBuffer *InputBuffer);
ObjectImage *loadObject(object::ObjectFile *InputObject);

void *getSymbolAddress(StringRef Name) {
// FIXME: Just look up as a function for now. Overly simple of course.
Expand Down Expand Up @@ -360,7 +354,6 @@ class RuntimeDyldImpl {
StringRef getErrorString() { return ErrorStr; }

virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const = 0;
virtual bool isCompatibleFile(const ObjectFile *Obj) const = 0;

virtual void registerEHFrames();

Expand Down
5 changes: 0 additions & 5 deletions lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,4 @@ bool RuntimeDyldMachO::isCompatibleFormat(
return false;
}

bool RuntimeDyldMachO::isCompatibleFile(
const object::ObjectFile *Obj) const {
return Obj->isMachO();
}

} // end namespace llvm
1 change: 0 additions & 1 deletion lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class RuntimeDyldMachO : public RuntimeDyldImpl {
const SymbolTableMap &Symbols,
StubMap &Stubs);
virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
virtual bool isCompatibleFile(const object::ObjectFile *Obj) const;
virtual void registerEHFrames();
virtual void finalizeLoad(ObjSectionToIDMap &SectionMap);
};
Expand Down
Loading

0 comments on commit a49701d

Please sign in to comment.