llvm-6502/lib/ExecutionEngine/MCJIT/MCJITMemoryManager.h
Danil Malyshev 0e4fa5ff36 Re-factored RuntimeDyLd:
1. The main works will made in the RuntimeDyLdImpl with uses the ObjectFile class. RuntimeDyLdMachO and RuntimeDyLdELF now only parses relocations and resolve it. This is allows to make improvements of the RuntimeDyLd more easily. In addition the support for COFF can be easily added.

2. Added ARM relocations to RuntimeDyLdELF.

3. Added support for stub functions for the ARM, allowing to do a long branch.

4. Added support for external functions that are not loaded from the object files, but can be loaded from external libraries. Now MCJIT can correctly execute the code containing the printf, putc, and etc.

5. The sections emitted instead functions, thanks Jim Grosbach. MemoryManager.startFunctionBody() and MemoryManager.endFunctionBody() have been removed.
6. MCJITMemoryManager.allocateDataSection() and MCJITMemoryManager. allocateCodeSection() used JMM->allocateSpace() instead of JMM->allocateCodeSection() and JMM->allocateDataSection(), because I got an error: "Cannot allocate an allocated block!" with object file contains more than one code or data sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153754 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 16:45:19 +00:00

55 lines
1.8 KiB
C++

//===-- MCJITMemoryManager.h - Definition for the Memory Manager ---C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
#define LLVM_LIB_EXECUTIONENGINE_MCJITMEMORYMANAGER_H
#include "llvm/Module.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include <assert.h>
namespace llvm {
// The MCJIT memory manager is a layer between the standard JITMemoryManager
// and the RuntimeDyld interface that maps objects, by name, onto their
// matching LLVM IR counterparts in the module(s) being compiled.
class MCJITMemoryManager : public RTDyldMemoryManager {
virtual void anchor();
JITMemoryManager *JMM;
// FIXME: Multiple modules.
Module *M;
public:
MCJITMemoryManager(JITMemoryManager *jmm, Module *m) :
JMM(jmm?jmm:JITMemoryManager::CreateDefaultMemManager()), M(m) {}
// We own the JMM, so make sure to delete it.
~MCJITMemoryManager() { delete JMM; }
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID) {
return JMM->allocateSpace(Size, Alignment);
}
uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID) {
return JMM->allocateSpace(Size, Alignment);
}
virtual void *getPointerToNamedFunction(const std::string &Name,
bool AbortOnFailure = true) {
return JMM->getPointerToNamedFunction(Name, AbortOnFailure);
}
};
} // End llvm namespace
#endif