Eli Bendersky | 058d647 | 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 | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 21 | namespace llvm { |
Tim Northover | 94bc73d | 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 | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 33 | class RuntimeDyldELF : public RuntimeDyldImpl { |
Rafael Espindola | f1f1c62 | 2013-04-29 17:24:34 +0000 | [diff] [blame^] | 34 | void resolveRelocation(const SectionEntry &Section, |
| 35 | uint64_t Offset, |
| 36 | uint64_t Value, |
| 37 | uint32_t Type, |
| 38 | int64_t Addend); |
| 39 | |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 40 | protected: |
Andrew Kaylor | fb05a50 | 2012-11-02 19:45:23 +0000 | [diff] [blame] | 41 | void resolveX86_64Relocation(const SectionEntry &Section, |
| 42 | uint64_t Offset, |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 43 | uint64_t Value, |
| 44 | uint32_t Type, |
| 45 | int64_t Addend); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 46 | |
Andrew Kaylor | fb05a50 | 2012-11-02 19:45:23 +0000 | [diff] [blame] | 47 | void resolveX86Relocation(const SectionEntry &Section, |
| 48 | uint64_t Offset, |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 49 | uint32_t Value, |
| 50 | uint32_t Type, |
| 51 | int32_t Addend); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 52 | |
Andrew Kaylor | fb05a50 | 2012-11-02 19:45:23 +0000 | [diff] [blame] | 53 | void resolveARMRelocation(const SectionEntry &Section, |
| 54 | uint64_t Offset, |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 55 | uint32_t Value, |
| 56 | uint32_t Type, |
| 57 | int32_t Addend); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 58 | |
Andrew Kaylor | fb05a50 | 2012-11-02 19:45:23 +0000 | [diff] [blame] | 59 | void resolveMIPSRelocation(const SectionEntry &Section, |
| 60 | uint64_t Offset, |
Akira Hatanaka | 11dfbe1 | 2012-08-20 17:53:24 +0000 | [diff] [blame] | 61 | uint32_t Value, |
| 62 | uint32_t Type, |
| 63 | int32_t Addend); |
Akira Hatanaka | 111174b | 2012-08-17 21:28:04 +0000 | [diff] [blame] | 64 | |
Andrew Kaylor | fb05a50 | 2012-11-02 19:45:23 +0000 | [diff] [blame] | 65 | void resolvePPC64Relocation(const SectionEntry &Section, |
| 66 | uint64_t Offset, |
Adhemerval Zanella | 5fc11b3 | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 67 | uint64_t Value, |
| 68 | uint32_t Type, |
| 69 | int64_t Addend); |
| 70 | |
Rafael Espindola | f1f1c62 | 2013-04-29 17:24:34 +0000 | [diff] [blame^] | 71 | virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 72 | |
Rafael Espindola | 4d4a48d | 2013-04-29 14:44:23 +0000 | [diff] [blame] | 73 | virtual void processRelocationRef(unsigned SectionID, |
| 74 | relocation_iterator RelI, |
Preston Gurd | cc31af9 | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 75 | ObjectImage &Obj, |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 76 | ObjSectionToIDMap &ObjSectionToID, |
Eli Bendersky | fc07908 | 2012-05-01 06:58:59 +0000 | [diff] [blame] | 77 | const SymbolTableMap &Symbols, |
| 78 | StubMap &Stubs); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 79 | |
Tim Northover | 94bc73d | 2012-10-29 10:47:04 +0000 | [diff] [blame] | 80 | unsigned getCommonSymbolAlignment(const SymbolRef &Sym); |
| 81 | |
Andrew Kaylor | adc7056 | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 82 | virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer); |
Preston Gurd | cc31af9 | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 83 | |
Adhemerval Zanella | 5fc11b3 | 2012-10-25 13:13:48 +0000 | [diff] [blame] | 84 | uint64_t findPPC64TOC() const; |
| 85 | void findOPDEntrySection(ObjectImage &Obj, |
| 86 | ObjSectionToIDMap &LocalSections, |
| 87 | RelocationValueRef &Rel); |
| 88 | |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 89 | public: |
Preston Gurd | cc31af9 | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 90 | RuntimeDyldELF(RTDyldMemoryManager *mm) |
Andrew Kaylor | adc7056 | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 91 | : RuntimeDyldImpl(mm) {} |
Preston Gurd | cc31af9 | 2012-04-16 22:12:58 +0000 | [diff] [blame] | 92 | |
| 93 | virtual ~RuntimeDyldELF(); |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 94 | |
Andrew Kaylor | adc7056 | 2012-10-02 21:18:39 +0000 | [diff] [blame] | 95 | bool isCompatibleFormat(const ObjectBuffer *Buffer) const; |
Eli Bendersky | 058d647 | 2012-01-22 07:05:02 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | } // end namespace llvm |
| 99 | |
Danil Malyshev | 70d22cc | 2012-03-30 16:45:19 +0000 | [diff] [blame] | 100 | #endif |