1//===-- RuntimeDyldELF.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// ELF support for MC-JIT runtime dynamic linker. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_RUNTIME_DYLD_ELF_H 15#define LLVM_RUNTIME_DYLD_ELF_H 16 17#include "RuntimeDyldImpl.h" 18 19using namespace llvm; 20 21namespace llvm { 22 23namespace { 24 // Helper for extensive error checking in debug builds. 25 error_code Check(error_code Err) { 26 if (Err) { 27 report_fatal_error(Err.message()); 28 } 29 return Err; 30 } 31} // end anonymous namespace 32 33class RuntimeDyldELF : public RuntimeDyldImpl { 34 void resolveRelocation(const SectionEntry &Section, 35 uint64_t Offset, 36 uint64_t Value, 37 uint32_t Type, 38 int64_t Addend); 39 40 void resolveX86_64Relocation(const SectionEntry &Section, 41 uint64_t Offset, 42 uint64_t Value, 43 uint32_t Type, 44 int64_t Addend); 45 46 void resolveX86Relocation(const SectionEntry &Section, 47 uint64_t Offset, 48 uint32_t Value, 49 uint32_t Type, 50 int32_t Addend); 51 52 void resolveAArch64Relocation(const SectionEntry &Section, 53 uint64_t Offset, 54 uint64_t Value, 55 uint32_t Type, 56 int64_t Addend); 57 58 void resolveARMRelocation(const SectionEntry &Section, 59 uint64_t Offset, 60 uint32_t Value, 61 uint32_t Type, 62 int32_t Addend); 63 64 void resolveMIPSRelocation(const SectionEntry &Section, 65 uint64_t Offset, 66 uint32_t Value, 67 uint32_t Type, 68 int32_t Addend); 69 70 void resolvePPC64Relocation(const SectionEntry &Section, 71 uint64_t Offset, 72 uint64_t Value, 73 uint32_t Type, 74 int64_t Addend); 75 76 void resolveSystemZRelocation(const SectionEntry &Section, 77 uint64_t Offset, 78 uint64_t Value, 79 uint32_t Type, 80 int64_t Addend); 81 82 uint64_t findPPC64TOC() const; 83 void findOPDEntrySection(ObjectImage &Obj, 84 ObjSectionToIDMap &LocalSections, 85 RelocationValueRef &Rel); 86 87public: 88 RuntimeDyldELF(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {} 89 90 virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value); 91 virtual void processRelocationRef(unsigned SectionID, 92 RelocationRef RelI, 93 ObjectImage &Obj, 94 ObjSectionToIDMap &ObjSectionToID, 95 const SymbolTableMap &Symbols, 96 StubMap &Stubs); 97 virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const; 98 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer); 99 virtual StringRef getEHFrameSection(); 100 virtual ~RuntimeDyldELF(); 101}; 102 103} // end namespace llvm 104 105#endif 106