blob: d71e8b703077455f8ffe1e4e2657c3f72c13b39a [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 {
Danil Malyshev70d22cc2012-03-30 16:45:19 +000034protected:
Andrew Kaylorfb05a502012-11-02 19:45:23 +000035 void resolveX86_64Relocation(const SectionEntry &Section,
36 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000037 uint64_t Value,
38 uint32_t Type,
39 int64_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000040
Andrew Kaylorfb05a502012-11-02 19:45:23 +000041 void resolveX86Relocation(const SectionEntry &Section,
42 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000043 uint32_t Value,
44 uint32_t Type,
45 int32_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000046
Andrew Kaylorfb05a502012-11-02 19:45:23 +000047 void resolveARMRelocation(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 resolveMIPSRelocation(const SectionEntry &Section,
54 uint64_t Offset,
Akira Hatanaka11dfbe12012-08-20 17:53:24 +000055 uint32_t Value,
56 uint32_t Type,
57 int32_t Addend);
Akira Hatanaka111174b2012-08-17 21:28:04 +000058
Andrew Kaylorfb05a502012-11-02 19:45:23 +000059 void resolvePPC64Relocation(const SectionEntry &Section,
60 uint64_t Offset,
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000061 uint64_t Value,
62 uint32_t Type,
63 int64_t Addend);
64
Andrew Kaylorfb05a502012-11-02 19:45:23 +000065 virtual void resolveRelocation(const SectionEntry &Section,
66 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000067 uint64_t Value,
68 uint32_t Type,
69 int64_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000070
Rafael Espindola4d4a48d2013-04-29 14:44:23 +000071 virtual void processRelocationRef(unsigned SectionID,
72 relocation_iterator RelI,
Preston Gurdcc31af92012-04-16 22:12:58 +000073 ObjectImage &Obj,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000074 ObjSectionToIDMap &ObjSectionToID,
Eli Benderskyfc079082012-05-01 06:58:59 +000075 const SymbolTableMap &Symbols,
76 StubMap &Stubs);
Eli Bendersky058d6472012-01-22 07:05:02 +000077
Tim Northover94bc73d2012-10-29 10:47:04 +000078 unsigned getCommonSymbolAlignment(const SymbolRef &Sym);
79
Andrew Kayloradc70562012-10-02 21:18:39 +000080 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
Preston Gurdcc31af92012-04-16 22:12:58 +000081
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000082 uint64_t findPPC64TOC() const;
83 void findOPDEntrySection(ObjectImage &Obj,
84 ObjSectionToIDMap &LocalSections,
85 RelocationValueRef &Rel);
86
Eli Bendersky058d6472012-01-22 07:05:02 +000087public:
Preston Gurdcc31af92012-04-16 22:12:58 +000088 RuntimeDyldELF(RTDyldMemoryManager *mm)
Andrew Kayloradc70562012-10-02 21:18:39 +000089 : RuntimeDyldImpl(mm) {}
Preston Gurdcc31af92012-04-16 22:12:58 +000090
91 virtual ~RuntimeDyldELF();
Eli Bendersky058d6472012-01-22 07:05:02 +000092
Andrew Kayloradc70562012-10-02 21:18:39 +000093 bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
Eli Bendersky058d6472012-01-22 07:05:02 +000094};
95
96} // end namespace llvm
97
Danil Malyshev70d22cc2012-03-30 16:45:19 +000098#endif