blob: 835b66fb516108e196c222435a2550c769afba5f [file] [log] [blame]
Eli Bendersky058d6472012-01-22 07:05:02 +00001//===-- 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
Eli Bendersky058d6472012-01-22 07:05:02 +000021namespace llvm {
Tim Northover94bc73d2012-10-29 10:47:04 +000022
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
Eli Bendersky058d6472012-01-22 07:05:02 +000033class RuntimeDyldELF : public RuntimeDyldImpl {
Rafael Espindolaf1f1c622013-04-29 17:24:34 +000034 void resolveRelocation(const SectionEntry &Section,
35 uint64_t Offset,
36 uint64_t Value,
37 uint32_t Type,
38 int64_t Addend);
39
Danil Malyshev70d22cc2012-03-30 16:45:19 +000040protected:
Andrew Kaylorfb05a502012-11-02 19:45:23 +000041 void resolveX86_64Relocation(const SectionEntry &Section,
42 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000043 uint64_t Value,
44 uint32_t Type,
45 int64_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000046
Andrew Kaylorfb05a502012-11-02 19:45:23 +000047 void resolveX86Relocation(const SectionEntry &Section,
48 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000049 uint32_t Value,
50 uint32_t Type,
51 int32_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000052
Andrew Kaylorfb05a502012-11-02 19:45:23 +000053 void resolveARMRelocation(const SectionEntry &Section,
54 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000055 uint32_t Value,
56 uint32_t Type,
57 int32_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000058
Andrew Kaylorfb05a502012-11-02 19:45:23 +000059 void resolveMIPSRelocation(const SectionEntry &Section,
60 uint64_t Offset,
Akira Hatanaka11dfbe12012-08-20 17:53:24 +000061 uint32_t Value,
62 uint32_t Type,
63 int32_t Addend);
Akira Hatanaka111174b2012-08-17 21:28:04 +000064
Andrew Kaylorfb05a502012-11-02 19:45:23 +000065 void resolvePPC64Relocation(const SectionEntry &Section,
66 uint64_t Offset,
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000067 uint64_t Value,
68 uint32_t Type,
69 int64_t Addend);
70
Rafael Espindolaf1f1c622013-04-29 17:24:34 +000071 virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value);
Eli Bendersky058d6472012-01-22 07:05:02 +000072
Rafael Espindola4d4a48d2013-04-29 14:44:23 +000073 virtual void processRelocationRef(unsigned SectionID,
74 relocation_iterator RelI,
Preston Gurdcc31af92012-04-16 22:12:58 +000075 ObjectImage &Obj,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000076 ObjSectionToIDMap &ObjSectionToID,
Eli Benderskyfc079082012-05-01 06:58:59 +000077 const SymbolTableMap &Symbols,
78 StubMap &Stubs);
Eli Bendersky058d6472012-01-22 07:05:02 +000079
Tim Northover94bc73d2012-10-29 10:47:04 +000080 unsigned getCommonSymbolAlignment(const SymbolRef &Sym);
81
Andrew Kayloradc70562012-10-02 21:18:39 +000082 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
Preston Gurdcc31af92012-04-16 22:12:58 +000083
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000084 uint64_t findPPC64TOC() const;
85 void findOPDEntrySection(ObjectImage &Obj,
86 ObjSectionToIDMap &LocalSections,
87 RelocationValueRef &Rel);
88
Eli Bendersky058d6472012-01-22 07:05:02 +000089public:
Preston Gurdcc31af92012-04-16 22:12:58 +000090 RuntimeDyldELF(RTDyldMemoryManager *mm)
Andrew Kayloradc70562012-10-02 21:18:39 +000091 : RuntimeDyldImpl(mm) {}
Preston Gurdcc31af92012-04-16 22:12:58 +000092
93 virtual ~RuntimeDyldELF();
Eli Bendersky058d6472012-01-22 07:05:02 +000094
Andrew Kayloradc70562012-10-02 21:18:39 +000095 bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
Eli Bendersky058d6472012-01-22 07:05:02 +000096};
97
98} // end namespace llvm
99
Danil Malyshev70d22cc2012-03-30 16:45:19 +0000100#endif