Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 1 | //===-- RuntimeDyldMachO.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 | // MachO support for MC-JIT runtime dynamic linker. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_RUNTIME_DYLD_MACHO_H |
| 15 | #define LLVM_RUNTIME_DYLD_MACHO_H |
| 16 | |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 17 | #include "RuntimeDyldImpl.h" |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/IndexedMap.h" |
Rafael Espindola | 6e040c0 | 2013-04-26 20:07:33 +0000 | [diff] [blame] | 19 | #include "llvm/Object/MachO.h" |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Format.h" |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace llvm; |
| 23 | using namespace llvm::object; |
| 24 | |
| 25 | |
| 26 | namespace llvm { |
| 27 | class RuntimeDyldMachO : public RuntimeDyldImpl { |
Sean Callanan | a375943 | 2012-03-26 20:45:52 +0000 | [diff] [blame] | 28 | bool resolveI386Relocation(uint8_t *LocalAddress, |
| 29 | uint64_t FinalAddress, |
| 30 | uint64_t Value, |
| 31 | bool isPCRel, |
| 32 | unsigned Type, |
| 33 | unsigned Size, |
| 34 | int64_t Addend); |
Sean Callanan | ca92a3d | 2012-03-07 23:05:25 +0000 | [diff] [blame] | 35 | bool resolveX86_64Relocation(uint8_t *LocalAddress, |
| 36 | uint64_t FinalAddress, |
| 37 | uint64_t Value, |
| 38 | bool isPCRel, |
| 39 | unsigned Type, |
| 40 | unsigned Size, |
| 41 | int64_t Addend); |
| 42 | bool resolveARMRelocation(uint8_t *LocalAddress, |
| 43 | uint64_t FinalAddress, |
| 44 | uint64_t Value, |
| 45 | bool isPCRel, |
| 46 | unsigned Type, |
| 47 | unsigned Size, |
| 48 | int64_t Addend); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 49 | |
Rafael Espindola | f1f1c62 | 2013-04-29 17:24:34 +0000 | [diff] [blame] | 50 | void resolveRelocation(const SectionEntry &Section, |
| 51 | uint64_t Offset, |
| 52 | uint64_t Value, |
| 53 | uint32_t Type, |
| 54 | int64_t Addend, |
| 55 | bool isPCRel, |
| 56 | unsigned Size); |
Andrew Kaylor | 7bb1344 | 2013-10-11 21:25:48 +0000 | [diff] [blame^] | 57 | |
| 58 | struct EHFrameRelatedSections { |
| 59 | EHFrameRelatedSections() : EHFrameSID(RTDYLD_INVALID_SECTION_ID), |
| 60 | TextSID(RTDYLD_INVALID_SECTION_ID), |
| 61 | ExceptTabSID(RTDYLD_INVALID_SECTION_ID) {} |
| 62 | EHFrameRelatedSections(SID EH, SID T, SID Ex) |
| 63 | : EHFrameSID(EH), TextSID(T), ExceptTabSID(Ex) {} |
| 64 | SID EHFrameSID; |
| 65 | SID TextSID; |
| 66 | SID ExceptTabSID; |
| 67 | }; |
| 68 | |
| 69 | // When a module is loaded we save the SectionID of the EH frame section |
| 70 | // in a table until we receive a request to register all unregistered |
| 71 | // EH frame sections with the memory manager. |
| 72 | SmallVector<EHFrameRelatedSections, 2> UnregisteredEHFrameSections; |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 73 | public: |
| 74 | RuntimeDyldMachO(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {} |
| 75 | |
Rafael Espindola | 2b06530 | 2013-04-29 22:06:33 +0000 | [diff] [blame] | 76 | virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value); |
| 77 | virtual void processRelocationRef(unsigned SectionID, |
| 78 | RelocationRef RelI, |
| 79 | ObjectImage &Obj, |
| 80 | ObjSectionToIDMap &ObjSectionToID, |
| 81 | const SymbolTableMap &Symbols, |
| 82 | StubMap &Stubs); |
| 83 | virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const; |
Andrew Kaylor | 7bb1344 | 2013-10-11 21:25:48 +0000 | [diff] [blame^] | 84 | virtual void registerEHFrames(); |
| 85 | virtual void finalizeLoad(ObjSectionToIDMap &SectionMap); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // end namespace llvm |
| 89 | |
| 90 | #endif |