]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/ELF/Relocations.h
Bring lld (release_39 branch, r279477) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / ELF / Relocations.h
1 //===- Relocations.h -------------------------------------------*- C++ -*-===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_ELF_RELOCATIONS_H
11 #define LLD_ELF_RELOCATIONS_H
12
13 #include "lld/Core/LLVM.h"
14
15 namespace lld {
16 namespace elf {
17 class SymbolBody;
18 template <class ELFT> class InputSection;
19 template <class ELFT> class InputSectionBase;
20
21 enum RelExpr {
22   R_ABS,
23   R_GOT,
24   R_GOTONLY_PC,
25   R_GOTREL,
26   R_GOT_FROM_END,
27   R_GOT_OFF,
28   R_GOT_PAGE_PC,
29   R_GOT_PC,
30   R_HINT,
31   R_MIPS_GOT_LOCAL_PAGE,
32   R_MIPS_GOT_OFF,
33   R_MIPS_TLSGD,
34   R_MIPS_TLSLD,
35   R_NEG_TLS,
36   R_PAGE_PC,
37   R_PC,
38   R_PLT,
39   R_PLT_PC,
40   R_PLT_PAGE_PC,
41   R_PPC_OPD,
42   R_PPC_PLT_OPD,
43   R_PPC_TOC,
44   R_RELAX_GOT_PC,
45   R_RELAX_GOT_PC_NOPIC,
46   R_RELAX_TLS_GD_TO_IE,
47   R_RELAX_TLS_GD_TO_IE_END,
48   R_RELAX_TLS_GD_TO_IE_ABS,
49   R_RELAX_TLS_GD_TO_IE_PAGE_PC,
50   R_RELAX_TLS_GD_TO_LE,
51   R_RELAX_TLS_GD_TO_LE_NEG,
52   R_RELAX_TLS_IE_TO_LE,
53   R_RELAX_TLS_LD_TO_LE,
54   R_SIZE,
55   R_THUNK_ABS,
56   R_THUNK_PC,
57   R_THUNK_PLT_PC,
58   R_TLS,
59   R_TLSDESC,
60   R_TLSDESC_PAGE,
61   R_TLSGD,
62   R_TLSGD_PC,
63   R_TLSLD,
64   R_TLSLD_PC
65 };
66
67 template <class ELFT> struct Relocation {
68   RelExpr Expr;
69   uint32_t Type;
70   InputSectionBase<ELFT> *InputSec;
71   uint64_t Offset;
72   uint64_t Addend;
73   SymbolBody *Sym;
74 };
75
76 template <class ELFT> void scanRelocations(InputSection<ELFT> &);
77
78 template <class ELFT>
79 void scanRelocations(InputSectionBase<ELFT> &, const typename ELFT::Shdr &);
80
81 template <class ELFT>
82 static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) {
83   return 0;
84 }
85
86 template <class ELFT>
87 static inline typename ELFT::uint getAddend(const typename ELFT::Rela &Rel) {
88   return Rel.r_addend;
89 }
90 }
91 }
92
93 #endif