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