1 //===-- RuntimeDyldMachO.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 // MachO support for MC-JIT runtime dynamic linker.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_RUNTIME_DYLD_MACHO_H
15 #define LLVM_RUNTIME_DYLD_MACHO_H
17 #include "RuntimeDyldImpl.h"
18 #include "llvm/ADT/IndexedMap.h"
19 #include "llvm/Object/MachO.h"
20 #include "llvm/Support/Format.h"
23 using namespace llvm::object;
27 class RuntimeDyldMachO : public RuntimeDyldImpl {
28 bool resolveI386Relocation(uint8_t *LocalAddress,
29 uint64_t FinalAddress,
35 bool resolveX86_64Relocation(uint8_t *LocalAddress,
36 uint64_t FinalAddress,
42 bool resolveARMRelocation(uint8_t *LocalAddress,
43 uint64_t FinalAddress,
50 void resolveRelocation(const SectionEntry &Section,
58 unsigned getMaxStubSize() {
59 if (Arch == Triple::arm || Arch == Triple::thumb)
60 return 8; // 32-bit instruction and 32-bit address
61 else if (Arch == Triple::x86_64)
62 return 8; // GOT entry
67 unsigned getStubAlignment() {
71 struct EHFrameRelatedSections {
72 EHFrameRelatedSections() : EHFrameSID(RTDYLD_INVALID_SECTION_ID),
73 TextSID(RTDYLD_INVALID_SECTION_ID),
74 ExceptTabSID(RTDYLD_INVALID_SECTION_ID) {}
75 EHFrameRelatedSections(SID EH, SID T, SID Ex)
76 : EHFrameSID(EH), TextSID(T), ExceptTabSID(Ex) {}
82 // When a module is loaded we save the SectionID of the EH frame section
83 // in a table until we receive a request to register all unregistered
84 // EH frame sections with the memory manager.
85 SmallVector<EHFrameRelatedSections, 2> UnregisteredEHFrameSections;
87 RuntimeDyldMachO(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {}
89 virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value);
90 virtual void processRelocationRef(unsigned SectionID,
93 ObjSectionToIDMap &ObjSectionToID,
94 const SymbolTableMap &Symbols,
96 virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
97 virtual bool isCompatibleFile(const object::ObjectFile *Obj) const;
98 virtual void registerEHFrames();
99 virtual void finalizeLoad(ObjSectionToIDMap &SectionMap);
102 } // end namespace llvm