1221337Sdim//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// 2221337Sdim// 3221337Sdim// The LLVM Compiler Infrastructure 4221337Sdim// 5221337Sdim// This file is distributed under the University of Illinois Open Source 6221337Sdim// License. See LICENSE.TXT for details. 7221337Sdim// 8221337Sdim//===----------------------------------------------------------------------===// 9221337Sdim// 10221337Sdim// Interface for the runtime dynamic linker facilities of the MC-JIT. 11221337Sdim// 12221337Sdim//===----------------------------------------------------------------------===// 13221337Sdim 14249423Sdim#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H 15249423Sdim#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H 16221337Sdim 17221337Sdim#include "llvm/ADT/StringRef.h" 18243830Sdim#include "llvm/ExecutionEngine/ObjectBuffer.h" 19263508Sdim#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" 20221337Sdim#include "llvm/Support/Memory.h" 21221337Sdim 22221337Sdimnamespace llvm { 23221337Sdim 24221337Sdimclass RuntimeDyldImpl; 25243830Sdimclass ObjectImage; 26221337Sdim 27221337Sdimclass RuntimeDyld { 28243830Sdim RuntimeDyld(const RuntimeDyld &) LLVM_DELETED_FUNCTION; 29243830Sdim void operator=(const RuntimeDyld &) LLVM_DELETED_FUNCTION; 30221337Sdim 31221337Sdim // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public 32221337Sdim // interface. 33221337Sdim RuntimeDyldImpl *Dyld; 34224145Sdim RTDyldMemoryManager *MM; 35234353Sdimprotected: 36234353Sdim // Change the address associated with a section when resolving relocations. 37234353Sdim // Any relocations already associated with the symbol will be re-resolved. 38234353Sdim void reassignSectionAddress(unsigned SectionID, uint64_t Addr); 39221337Sdimpublic: 40243830Sdim RuntimeDyld(RTDyldMemoryManager *); 41221337Sdim ~RuntimeDyld(); 42221337Sdim 43249423Sdim /// Prepare the object contained in the input buffer for execution. 44249423Sdim /// Ownership of the input buffer is transferred to the ObjectImage 45249423Sdim /// instance returned from this function if successful. In the case of load 46249423Sdim /// failure, the input buffer will be deleted. 47243830Sdim ObjectImage *loadObject(ObjectBuffer *InputBuffer); 48239462Sdim 49239462Sdim /// Get the address of our local copy of the symbol. This may or may not 50239462Sdim /// be the address used for relocation (clients can copy the data around 51239462Sdim /// and resolve relocatons based on where they put it). 52221337Sdim void *getSymbolAddress(StringRef Name); 53239462Sdim 54243830Sdim /// Get the address of the target copy of the symbol. This is the address 55243830Sdim /// used for relocation. 56243830Sdim uint64_t getSymbolLoadAddress(StringRef Name); 57243830Sdim 58239462Sdim /// Resolve the relocations for all symbols we currently know about. 59221337Sdim void resolveRelocations(); 60234353Sdim 61249423Sdim /// Map a section to its target address space value. 62234353Sdim /// Map the address of a JIT section as returned from the memory manager 63234353Sdim /// to the address in the target process as the running code will see it. 64234353Sdim /// This is the address which will be used for relocation resolution. 65243830Sdim void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress); 66234353Sdim 67263508Sdim /// Register any EH frame sections that have been loaded but not previously 68263508Sdim /// registered with the memory manager. Note, RuntimeDyld is responsible 69263508Sdim /// for identifying the EH frame and calling the memory manager with the 70263508Sdim /// EH frame section data. However, the memory manager itself will handle 71263508Sdim /// the actual target-specific EH frame registration. 72263508Sdim void registerEHFrames(); 73263508Sdim 74263508Sdim void deregisterEHFrames(); 75263508Sdim 76221337Sdim StringRef getErrorString(); 77221337Sdim}; 78221337Sdim 79221337Sdim} // end namespace llvm 80221337Sdim 81221337Sdim#endif 82