Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 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 | |
| 19 | using namespace llvm; |
| 20 | |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 21 | namespace llvm { |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame^] | 22 | |
| 23 | namespace { |
| 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 | |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 33 | class RuntimeDyldELF : public RuntimeDyldImpl { |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 34 | protected: |
| 35 | void resolveX86_64Relocation(uint8_t *LocalAddress, |
| 36 | uint64_t FinalAddress, |
| 37 | uint64_t Value, |
| 38 | uint32_t Type, |
| 39 | int64_t Addend); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 40 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 41 | void resolveX86Relocation(uint8_t *LocalAddress, |
| 42 | uint32_t FinalAddress, |
| 43 | uint32_t Value, |
| 44 | uint32_t Type, |
| 45 | int32_t Addend); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 46 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 47 | void resolveARMRelocation(uint8_t *LocalAddress, |
| 48 | uint32_t FinalAddress, |
| 49 | uint32_t Value, |
| 50 | uint32_t Type, |
| 51 | int32_t Addend); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 52 | |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 53 | void resolveMIPSRelocation(uint8_t *LocalAddress, |
Akira Hatanaka | b862f09 | 2012-08-20 17:53:24 +0000 | [diff] [blame] | 54 | uint32_t FinalAddress, |
| 55 | uint32_t Value, |
| 56 | uint32_t Type, |
| 57 | int32_t Addend); |
Akira Hatanaka | b889e0c | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 58 | |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 59 | void resolvePPC64Relocation(uint8_t *LocalAddress, |
| 60 | uint64_t FinalAddress, |
| 61 | uint64_t Value, |
| 62 | uint32_t Type, |
| 63 | int64_t Addend); |
| 64 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 65 | virtual void resolveRelocation(uint8_t *LocalAddress, |
| 66 | uint64_t FinalAddress, |
| 67 | uint64_t Value, |
| 68 | uint32_t Type, |
| 69 | int64_t Addend); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 70 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 71 | virtual void processRelocationRef(const ObjRelocationInfo &Rel, |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 72 | ObjectImage &Obj, |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 73 | ObjSectionToIDMap &ObjSectionToID, |
Eli Bendersky | d98c9e9 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 74 | const SymbolTableMap &Symbols, |
| 75 | StubMap &Stubs); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 76 | |
Tim Northover | f00677d | 2012-10-29 10:47:04 +0000 | [diff] [blame^] | 77 | unsigned getCommonSymbolAlignment(const SymbolRef &Sym); |
| 78 | |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 79 | virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer); |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 80 | |
Adhemerval Zanella | 6e8946c | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 81 | uint64_t findPPC64TOC() const; |
| 82 | void findOPDEntrySection(ObjectImage &Obj, |
| 83 | ObjSectionToIDMap &LocalSections, |
| 84 | RelocationValueRef &Rel); |
| 85 | |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 86 | public: |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 87 | RuntimeDyldELF(RTDyldMemoryManager *mm) |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 88 | : RuntimeDyldImpl(mm) {} |
Preston Gurd | 689ff9c | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 89 | |
| 90 | virtual ~RuntimeDyldELF(); |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 91 | |
Andrew Kaylor | 3f23cef | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 92 | bool isCompatibleFormat(const ObjectBuffer *Buffer) const; |
Eli Bendersky | 76463fd | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | } // end namespace llvm |
| 96 | |
Danil Malyshev | 0e4fa5f | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 97 | #endif |