1 //===-- RuntimeDyldELF.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 // ELF support for MC-JIT runtime dynamic linker.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_RUNTIME_DYLD_ELF_H
15 #define LLVM_RUNTIME_DYLD_ELF_H
17 #include "RuntimeDyldImpl.h"
23 class RuntimeDyldELF : public RuntimeDyldImpl {
24 // For each symbol, keep a list of relocations based on it. Anytime
25 // its address is reassigned (the JIT re-compiled the function, e.g.),
26 // the relocations get re-resolved.
27 struct RelocationEntry {
28 // Function or section this relocation is contained in.
30 // Offset into the target function or section for the relocation.
34 // Addend encoded in the instruction itself, if any.
36 // Has the relocation been recalcuated as an offset within a function?
37 bool IsFunctionRelative;
38 // Has this relocation been resolved previously?
41 RelocationEntry(StringRef t,
45 bool isFunctionRelative)
50 , IsFunctionRelative(isFunctionRelative)
51 , isResolved(false) { }
53 typedef SmallVector<RelocationEntry, 4> RelocationList;
54 StringMap<RelocationList> Relocations;
57 void resolveRelocations();
59 void resolveX86_64Relocation(StringRef Name,
61 const RelocationEntry &RE);
63 void resolveX86Relocation(StringRef Name,
65 const RelocationEntry &RE);
67 void resolveArmRelocation(StringRef Name,
69 const RelocationEntry &RE);
71 void resolveRelocation(StringRef Name,
73 const RelocationEntry &RE);
76 RuntimeDyldELF(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {}
78 bool loadObject(MemoryBuffer *InputBuffer);
80 void reassignSymbolAddress(StringRef Name, uint8_t *Addr);
81 void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
83 bool isCompatibleFormat(const MemoryBuffer *InputBuffer) const;
86 } // end namespace llvm
90 //===-- RuntimeDyldELF.h - Run-time dynamic linker for MC-JIT ---*- C++ -*-===//
92 // The LLVM Compiler Infrastructure
94 // This file is distributed under the University of Illinois Open Source
95 // License. See LICENSE.TXT for details.
97 //===----------------------------------------------------------------------===//
99 // ELF support for MC-JIT runtime dynamic linker.
101 //===----------------------------------------------------------------------===//
103 #ifndef LLVM_RUNTIME_DYLD_ELF_H
104 #define LLVM_RUNTIME_DYLD_ELF_H
106 #include "RuntimeDyldImpl.h"
108 using namespace llvm;
112 class RuntimeDyldELF : public RuntimeDyldImpl {
113 // For each symbol, keep a list of relocations based on it. Anytime
114 // its address is reassigned (the JIT re-compiled the function, e.g.),
115 // the relocations get re-resolved.
116 struct RelocationEntry {
117 // Function or section this relocation is contained in.
119 // Offset into the target function or section for the relocation.
123 // Addend encoded in the instruction itself, if any.
125 // Has the relocation been recalcuated as an offset within a function?
126 bool IsFunctionRelative;
127 // Has this relocation been resolved previously?
130 RelocationEntry(StringRef t,
134 bool isFunctionRelative)
139 , IsFunctionRelative(isFunctionRelative)
140 , isResolved(false) { }
142 typedef SmallVector<RelocationEntry, 4> RelocationList;
143 StringMap<RelocationList> Relocations;
146 void resolveRelocations();
148 void resolveX86_64Relocation(StringRef Name,
150 const RelocationEntry &RE);
152 void resolveX86Relocation(StringRef Name,
154 const RelocationEntry &RE);
156 void resolveArmRelocation(StringRef Name,
158 const RelocationEntry &RE);
160 void resolveRelocation(StringRef Name,
162 const RelocationEntry &RE);
165 RuntimeDyldELF(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {}
167 bool loadObject(MemoryBuffer *InputBuffer);
169 void reassignSymbolAddress(StringRef Name, uint8_t *Addr);
170 void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
172 bool isCompatibleFormat(const MemoryBuffer *InputBuffer) const;
175 } // end namespace llvm