1 //===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Interface for the runtime dynamic linker facilities of the MC-JIT.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
15 #define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ExecutionEngine/ObjectBuffer.h"
19 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
20 #include "llvm/Support/Memory.h"
28 class RuntimeDyldImpl;
32 RuntimeDyld(const RuntimeDyld &) LLVM_DELETED_FUNCTION;
33 void operator=(const RuntimeDyld &) LLVM_DELETED_FUNCTION;
35 // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public
37 RuntimeDyldImpl *Dyld;
38 RTDyldMemoryManager *MM;
40 // Change the address associated with a section when resolving relocations.
41 // Any relocations already associated with the symbol will be re-resolved.
42 void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
44 RuntimeDyld(RTDyldMemoryManager *);
47 /// Prepare the object contained in the input buffer for execution.
48 /// Ownership of the input buffer is transferred to the ObjectImage
49 /// instance returned from this function if successful. In the case of load
50 /// failure, the input buffer will be deleted.
51 ObjectImage *loadObject(ObjectBuffer *InputBuffer);
53 /// Prepare the referenced object file for execution.
54 /// Ownership of the input object is transferred to the ObjectImage
55 /// instance returned from this function if successful. In the case of load
56 /// failure, the input object will be deleted.
57 ObjectImage *loadObject(object::ObjectFile *InputObject);
59 /// Get the address of our local copy of the symbol. This may or may not
60 /// be the address used for relocation (clients can copy the data around
61 /// and resolve relocatons based on where they put it).
62 void *getSymbolAddress(StringRef Name);
64 /// Get the address of the target copy of the symbol. This is the address
65 /// used for relocation.
66 uint64_t getSymbolLoadAddress(StringRef Name);
68 /// Resolve the relocations for all symbols we currently know about.
69 void resolveRelocations();
71 /// Map a section to its target address space value.
72 /// Map the address of a JIT section as returned from the memory manager
73 /// to the address in the target process as the running code will see it.
74 /// This is the address which will be used for relocation resolution.
75 void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress);
77 /// Register any EH frame sections that have been loaded but not previously
78 /// registered with the memory manager. Note, RuntimeDyld is responsible
79 /// for identifying the EH frame and calling the memory manager with the
80 /// EH frame section data. However, the memory manager itself will handle
81 /// the actual target-specific EH frame registration.
82 void registerEHFrames();
84 void deregisterEHFrames();
86 StringRef getErrorString();
89 } // end namespace llvm