RemoteMemoryManager.h [plain text]
#ifndef REMOTEMEMORYMANAGER_H
#define REMOTEMEMORYMANAGER_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h"
#include <utility>
#include "RemoteTarget.h"
namespace llvm {
class RemoteMemoryManager : public JITMemoryManager {
public:
struct Allocation {
Allocation() {}
Allocation(sys::MemoryBlock mb, unsigned a, bool code)
: MB(mb), Alignment(a), IsCode(code) {}
sys::MemoryBlock MB;
unsigned Alignment;
bool IsCode;
};
private:
SmallVector<Allocation, 2> AllocatedSections;
SmallVector<Allocation, 2> UnmappedSections;
DenseMap<uint64_t, Allocation> MappedSections;
sys::MemoryBlock Near;
sys::MemoryBlock allocateSection(uintptr_t Size);
RemoteTarget *Target;
public:
RemoteMemoryManager() : Target(NULL) {}
virtual ~RemoteMemoryManager();
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID, StringRef SectionName);
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID, StringRef SectionName,
bool IsReadOnly);
uint64_t getSymbolAddress(const std::string &Name) { return 0; }
void notifyObjectLoaded(ExecutionEngine *EE, const ObjectImage *Obj);
bool finalizeMemory(std::string *ErrMsg);
void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {}
void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {}
void setRemoteTarget(RemoteTarget *T) { Target = T; }
void setMemoryWritable();
void setMemoryExecutable();
void setPoisonMemory(bool poison);
void AllocateGOT();
uint8_t *getGOTBase() const;
uint8_t *startFunctionBody(const Function *F, uintptr_t &ActualSize);
uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize,
unsigned Alignment);
void endFunctionBody(const Function *F, uint8_t *FunctionStart,
uint8_t *FunctionEnd);
uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment);
void deallocateFunctionBody(void *Body);
};
}
#endif