diff options
author | Jim Grosbach <grosbach@apple.com> | 2011-04-04 23:04:39 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2011-04-04 23:04:39 +0000 |
commit | 2dcef0505f286b20adb5a4c08bca86e322717993 (patch) | |
tree | 1190d55740b59641874d00e39891c1bbf39426b9 /llvm/tools/llvm-rtdyld | |
parent | f87b3739cc6d58823d06c1c48a8ea312159f53ce (diff) | |
download | bcm5719-llvm-2dcef0505f286b20adb5a4c08bca86e322717993.tar.gz bcm5719-llvm-2dcef0505f286b20adb5a4c08bca86e322717993.zip |
Layer the memory manager between the JIT and the runtime Dyld.
The JITMemory manager references LLVM IR constructs directly, while the
runtime Dyld works at a lower level and can handle objects which may not
originate from LLVM IR. Introduce a new layer for the memory manager to
handle the interface between them. For the MCJIT, this layer will be almost
entirely simply a call-through w/ translation between the IR objects and
symbol names.
llvm-svn: 128851
Diffstat (limited to 'llvm/tools/llvm-rtdyld')
-rw-r--r-- | llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index a6709442356..e09f14ad784 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -13,7 +13,6 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/OwningPtr.h" -#include "llvm/ExecutionEngine/JITMemoryManager.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/Object/MachOObject.h" #include "llvm/Support/CommandLine.h" @@ -41,6 +40,20 @@ Action(cl::desc("Action to perform:"), /* *** */ +// A trivial memory manager that doesn't do anything fancy, just uses the +// support library allocation routines directly. +class TrivialMemoryManager : public RTDyldMemoryManager { +public: + uint64_t startFunctionBody(const char *Name, uintptr_t &Size); + void endFunctionBody(const char *Name, uint64_t FunctionStart, + uint64_t FunctionEnd) {} +}; + +uint64_t TrivialMemoryManager::startFunctionBody(const char *Name, + uintptr_t &Size) { + return (uint64_t)sys::Memory::AllocateRWX(Size, 0, 0).base(); +} + static const char *ProgramName; static void Message(const char *Type, const Twine &Msg) { @@ -61,7 +74,7 @@ static int executeInput() { return Error("unable to read input: '" + ec.message() + "'"); // Instantiate a dynamic linker. - RuntimeDyld Dyld(JITMemoryManager::CreateDefaultMemManager()); + RuntimeDyld Dyld(new TrivialMemoryManager); // Load the object file into it. if (Dyld.loadObject(InputBuffer.take())) { @@ -69,7 +82,7 @@ static int executeInput() { } // Get the address of "_main". - void *MainAddress = Dyld.getSymbolAddress("_main"); + uint64_t MainAddress = Dyld.getSymbolAddress("_main"); if (MainAddress == 0) return Error("no definition for '_main'"); @@ -83,7 +96,7 @@ static int executeInput() { return Error("unable to mark function executable: '" + ErrorStr + "'"); // Dispatch to _main(). - errs() << "loaded '_main' at: " << MainAddress << "\n"; + errs() << "loaded '_main' at: " << (void*)MainAddress << "\n"; int (*Main)(int, const char**) = (int(*)(int,const char**)) uintptr_t(MainAddress); |