blob: 12e3122b4c147d5c54dad72f9ab904a9cf8c4330 [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
Andrew Kaylorfb05a502012-11-02 19:45:23 +000040 void resolveX86_64Relocation(const SectionEntry &Section,
41 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000042 uint64_t Value,
43 uint32_t Type,
44 int64_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000045
Andrew Kaylorfb05a502012-11-02 19:45:23 +000046 void resolveX86Relocation(const SectionEntry &Section,
47 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000048 uint32_t Value,
49 uint32_t Type,
50 int32_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000051
Andrew Kaylorfb05a502012-11-02 19:45:23 +000052 void resolveARMRelocation(const SectionEntry &Section,
53 uint64_t Offset,
Danil Malyshev70d22cc2012-03-30 16:45:19 +000054 uint32_t Value,
55 uint32_t Type,
56 int32_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000057
Andrew Kaylorfb05a502012-11-02 19:45:23 +000058 void resolveMIPSRelocation(const SectionEntry &Section,
59 uint64_t Offset,
Akira Hatanaka11dfbe12012-08-20 17:53:24 +000060 uint32_t Value,
61 uint32_t Type,
62 int32_t Addend);
Akira Hatanaka111174b2012-08-17 21:28:04 +000063
Andrew Kaylorfb05a502012-11-02 19:45:23 +000064 void resolvePPC64Relocation(const SectionEntry &Section,
65 uint64_t Offset,
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000066 uint64_t Value,
67 uint32_t Type,
68 int64_t Addend);
69
Richard Sandifordca044082013-05-03 14:15:35 +000070 void resolveSystemZRelocation(const SectionEntry &Section,
71 uint64_t Offset,
72 uint64_t Value,
73 uint32_t Type,
74 int64_t Addend);
Eli Bendersky058d6472012-01-22 07:05:02 +000075
Adhemerval Zanella5fc11b32012-10-25 13:13:48 +000076 uint64_t findPPC64TOC() const;
77 void findOPDEntrySection(ObjectImage &Obj,
78 ObjSectionToIDMap &LocalSections,
79 RelocationValueRef &Rel);
80
Eli Bendersky058d6472012-01-22 07:05:02 +000081public:
Rafael Espindola2b065302013-04-29 22:06:33 +000082 RuntimeDyldELF(RTDyldMemoryManager *mm) : RuntimeDyldImpl(mm) {}
Preston Gurdcc31af92012-04-16 22:12:58 +000083
Rafael Espindola2b065302013-04-29 22:06:33 +000084 virtual void resolveRelocation(const RelocationEntry &RE, uint64_t Value);
85 virtual void processRelocationRef(unsigned SectionID,
86 RelocationRef RelI,
87 ObjectImage &Obj,
88 ObjSectionToIDMap &ObjSectionToID,
89 const SymbolTableMap &Symbols,
90 StubMap &Stubs);
91 virtual bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
92 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
Preston Gurdcc31af92012-04-16 22:12:58 +000093 virtual ~RuntimeDyldELF();
Eli Bendersky058d6472012-01-22 07:05:02 +000094};
95
96} // end namespace llvm
97
Danil Malyshev70d22cc2012-03-30 16:45:19 +000098#endif