blob: 07e704b45930e3592098e09c517ae69a10538a01 [file] [log] [blame]
Eli Bendersky76463fd2012-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 Bendersky76463fd2012-01-22 07:05:02 +000021namespace llvm {
Tim Northoverf00677d2012-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 Bendersky76463fd2012-01-22 07:05:02 +000033class RuntimeDyldELF : public RuntimeDyldImpl {
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000034protected:
Andrew Kaylora307a1c2012-11-02 19:45:23 +000035 void resolveX86_64Relocation(const SectionEntry &Section,
36 uint64_t Offset,
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000037 uint64_t Value,
38 uint32_t Type,
39 int64_t Addend);
Eli Bendersky76463fd2012-01-22 07:05:02 +000040
Andrew Kaylora307a1c2012-11-02 19:45:23 +000041 void resolveX86Relocation(const SectionEntry &Section,
42 uint64_t Offset,
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000043 uint32_t Value,
44 uint32_t Type,
45 int32_t Addend);
Eli Bendersky76463fd2012-01-22 07:05:02 +000046
Andrew Kaylora307a1c2012-11-02 19:45:23 +000047 void resolveARMRelocation(const SectionEntry &Section,
48 uint64_t Offset,
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000049 uint32_t Value,
50 uint32_t Type,
51 int32_t Addend);
Eli Bendersky76463fd2012-01-22 07:05:02 +000052
Andrew Kaylora307a1c2012-11-02 19:45:23 +000053 void resolveMIPSRelocation(const SectionEntry &Section,
54 uint64_t Offset,
Akira Hatanakab862f092012-08-20 17:53:24 +000055 uint32_t Value,
56 uint32_t Type,
57 int32_t Addend);
Akira Hatanakab889e0c2012-08-17 21:28:04 +000058
Andrew Kaylora307a1c2012-11-02 19:45:23 +000059 void resolvePPC64Relocation(const SectionEntry &Section,
60 uint64_t Offset,
Adhemerval Zanella6e8946c2012-10-25 13:13:48 +000061 uint64_t Value,
62 uint32_t Type,
63 int64_t Addend);
64
Andrew Kaylora307a1c2012-11-02 19:45:23 +000065 virtual void resolveRelocation(const SectionEntry &Section,
66 uint64_t Offset,
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000067 uint64_t Value,
68 uint32_t Type,
69 int64_t Addend);
Eli Bendersky76463fd2012-01-22 07:05:02 +000070
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000071 virtual void processRelocationRef(const ObjRelocationInfo &Rel,
Preston Gurd689ff9c2012-04-16 22:12:58 +000072 ObjectImage &Obj,
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000073 ObjSectionToIDMap &ObjSectionToID,
Eli Benderskyd98c9e92012-05-01 06:58:59 +000074 const SymbolTableMap &Symbols,
75 StubMap &Stubs);
Eli Bendersky76463fd2012-01-22 07:05:02 +000076
Tim Northoverf00677d2012-10-29 10:47:04 +000077 unsigned getCommonSymbolAlignment(const SymbolRef &Sym);
78
Andrew Kaylor3f23cef2012-10-02 21:18:39 +000079 virtual ObjectImage *createObjectImage(ObjectBuffer *InputBuffer);
Preston Gurd689ff9c2012-04-16 22:12:58 +000080
Adhemerval Zanella6e8946c2012-10-25 13:13:48 +000081 uint64_t findPPC64TOC() const;
82 void findOPDEntrySection(ObjectImage &Obj,
83 ObjSectionToIDMap &LocalSections,
84 RelocationValueRef &Rel);
85
Eli Bendersky76463fd2012-01-22 07:05:02 +000086public:
Preston Gurd689ff9c2012-04-16 22:12:58 +000087 RuntimeDyldELF(RTDyldMemoryManager *mm)
Andrew Kaylor3f23cef2012-10-02 21:18:39 +000088 : RuntimeDyldImpl(mm) {}
Preston Gurd689ff9c2012-04-16 22:12:58 +000089
90 virtual ~RuntimeDyldELF();
Eli Bendersky76463fd2012-01-22 07:05:02 +000091
Andrew Kaylor3f23cef2012-10-02 21:18:39 +000092 bool isCompatibleFormat(const ObjectBuffer *Buffer) const;
Eli Bendersky76463fd2012-01-22 07:05:02 +000093};
94
95} // end namespace llvm
96
Danil Malyshev0e4fa5f2012-03-30 16:45:19 +000097#endif