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"
18 #include "llvm/ADT/DenseMap.h"
25 // Helper for extensive error checking in debug builds.
26 error_code Check(error_code Err) {
28 report_fatal_error(Err.message());
32 } // end anonymous namespace
34 class RuntimeDyldELF : public RuntimeDyldImpl {
35 void resolveRelocation(const SectionEntry &Section,
40 uint64_t SymOffset=0);
42 void resolveX86_64Relocation(const SectionEntry &Section,
49 void resolveX86Relocation(const SectionEntry &Section,
55 void resolveAArch64Relocation(const SectionEntry &Section,
61 void resolveARMRelocation(const SectionEntry &Section,
67 void resolveMIPSRelocation(const SectionEntry &Section,
73 void resolvePPC64Relocation(const SectionEntry &Section,
79 void resolveSystemZRelocation(const SectionEntry &Section,
85 uint64_t findPPC64TOC() const;
86 void findOPDEntrySection(ObjectImage &Obj,
87 ObjSectionToIDMap &LocalSections,
88 RelocationValueRef &Rel);
90 uint64_t findGOTEntry(uint64_t LoadAddr, uint64_t Offset);
91 size_t getGOTEntrySize();
93 virtual void updateGOTEntries(StringRef Name, uint64_t Addr);
95 // Relocation entries for symbols whose position-independant offset is
96 // updated in a global offset table.
97 typedef unsigned SID; // Type for SectionIDs
98 typedef SmallVector<RelocationValueRef, 2> GOTRelocations;
99 GOTRelocations GOTEntries; // List of entries requiring finalization.
100 SmallVector<std::pair<SID, GOTRelocations>, 8> GOTs; // Allocated tables.
103 RuntimeDyldELF(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm)
106 virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value);
107 virtual void processRelocationRef(unsigned SectionID,
110 ObjSectionToIDMap &ObjSectionToID,
111 const SymbolTableMap &Symbols,
113 virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
114 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
115 virtual StringRef getEHFrameSection();
116 virtual void finalizeLoad();
117 virtual ~RuntimeDyldELF();
120 } // end namespace llvm