elf_machdep.h revision 1.13 1 1.13 joerg /* $NetBSD: elf_machdep.h,v 1.13 2017/08/10 19:03:27 joerg Exp $ */
2 1.10 matt
3 1.10 matt #ifndef _POWERPC_ELF_MACHDEP_H_
4 1.10 matt #define _POWERPC_ELF_MACHDEP_H_
5 1.1 thorpej
6 1.3 kleink #define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
7 1.1 thorpej #define ELF32_MACHDEP_ID_CASES \
8 1.3 kleink case EM_PPC: \
9 1.1 thorpej break;
10 1.1 thorpej
11 1.6 ross #define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB
12 1.1 thorpej #define ELF64_MACHDEP_ID_CASES \
13 1.6 ross case EM_PPC64: \
14 1.6 ross break;
15 1.5 thorpej
16 1.5 thorpej #define ELF32_MACHDEP_ID EM_PPC
17 1.6 ross #define ELF64_MACHDEP_ID EM_PPC64
18 1.4 minoura
19 1.12 matt #ifndef ARCH_ELFSIZE
20 1.6 ross #ifdef _LP64
21 1.6 ross #define ARCH_ELFSIZE 64 /* MD native binary size */
22 1.6 ross #else
23 1.4 minoura #define ARCH_ELFSIZE 32 /* MD native binary size */
24 1.6 ross #endif
25 1.12 matt #endif
26 1.1 thorpej
27 1.9 matt /* Specify the value of _GLOBAL_OFFSET_TABLE_ */
28 1.9 matt #define DT_PPC_GOT DT_LOPROC
29 1.11 matt #define DT_PPC64_GLINK (DT_LOPROC + 0)
30 1.11 matt #define DT_PPC64_OPD (DT_LOPROC + 1)
31 1.11 matt #define DT_PPC64_OPDSZ (DT_LOPROC + 2)
32 1.11 matt #define DT_PPC64_TLSOPT (DT_LOPROC + 3)
33 1.9 matt
34 1.10 matt // A = the addend used to compute the value of relocatable field
35 1.10 matt // B = the base address of the shared object
36 1.10 matt // G = offset into the global offset table
37 1.10 matt // L = section offset or address of the procedure link table entry for the
38 1.10 matt // symbol + addend
39 1.10 matt // M = similar to G except the address which is stored may be the address of
40 1.10 matt // the procedure linkage table entry for the symbol
41 1.10 matt // P = the place (section offset or address) of the storage unit being
42 1.10 matt // relocated (computed using r_offset)
43 1.10 matt // R = the offset of the symbol with the section in which the symbol is defined
44 1.10 matt // S = the value of the symbol whose index resides in the relocation entry
45 1.10 matt //
46 1.10 matt // @dtpmod
47 1.10 matt // Computes the load module index of the load module that contains the
48 1.10 matt // definition of sym. The addend, if present, is ignored.
49 1.10 matt // @dtprel
50 1.10 matt // Computes a dtv-relative displacement, the difference between the value of
51 1.10 matt // S + A and the base address of the thread-local storage block that contains
52 1.10 matt // the definition of the symbol, minus 0x8000.
53 1.10 matt // @tprel
54 1.10 matt // Computes a tp-relative displacement, the difference between the value of
55 1.10 matt // S + A and the value of the thread pointer (r13).
56 1.10 matt // @got@tlsgd
57 1.10 matt // Allocates two contiguous entries in the GOT to hold a tls_index structure,
58 1.10 matt // with values @dtpmod and @dtprel, and computes the offset to the first
59 1.10 matt // entry relative to the TOC base (r2).
60 1.10 matt // @got@tlsld
61 1.10 matt // Allocates two contiguous entries in the GOT to hold a tls_index structure,
62 1.10 matt // with values @dtpmod and zero, and computes the offset to the first entry
63 1.10 matt // relative to the TOC base (r2).
64 1.10 matt // @got@dtprel
65 1.10 matt // Allocates an entry in the GOT with value @dtprel, and computes the offset
66 1.10 matt // to the entry relative to the TOC base (r2).
67 1.10 matt // @got@tprel
68 1.10 matt // Allocates an entry in the GOT with value @tprel, and computes the offset
69 1.10 matt // to the entry relative to the TOC base (r2).
70 1.10 matt //
71 1.10 matt // #lo(x) = (x & 0xffff)
72 1.10 matt // #hi(x) = ((x >> 16) & 0xffff)
73 1.10 matt // #ha(x) = (((x >> 16) + ((x & 0x80000) == 0x8000)) & 0xffff)
74 1.10 matt // #higher(x) = ((x >> 32) & 0xffff)
75 1.10 matt // #highera(x) =
76 1.10 matt // (((x >> 32) + ((x & 0xffff8000) == 0xffff8000)) & 0xffff)
77 1.10 matt // #highest(x) = ((x >> 48) & 0xffff)
78 1.10 matt // #highesta(x) =
79 1.10 matt // (((x >> 48) + ((x & 0xffffffff8000) == 0xffffffff8000)) & 0xffff)
80 1.10 matt // .TOC. = base TOC base of TOC section for object being relocated
81 1.10 matt
82 1.7 freza #define R_PPC_NONE 0
83 1.10 matt #define R_PPC_ADDR32 1 // S + A
84 1.10 matt #define R_PPC_ADDR24 2 // (S + A) >> 2
85 1.10 matt #define R_PPC_ADDR16 3 // S + A
86 1.10 matt #define R_PPC_ADDR16_LO 4 // #lo(S + A)
87 1.10 matt #define R_PPC_ADDR16_HI 5 // #hi(S + A)
88 1.10 matt #define R_PPC_ADDR16_HA 6 // #ha(S + A)
89 1.10 matt #define R_PPC_ADDR14 7 // (S + A) >> 2
90 1.10 matt #define R_PPC_ADDR14_TAKEN 8 // (S + A) >> 2
91 1.10 matt #define R_PPC_ADDR14_NTAKEN 9 // (S + A) >> 2
92 1.10 matt #define R_PPC_REL24 10 // (S + A - P) >> 2
93 1.10 matt #define R_PPC_REL14 11 // (S + A - P) >> 2
94 1.10 matt #define R_PPC_REL14_TAKEN 12 // (S + A - P) >> 2
95 1.10 matt #define R_PPC_REL14_NTAKEN 13 // (S + A - P) >> 2
96 1.10 matt #define R_PPC_GOT16 14 // G + A
97 1.10 matt #define R_PPC_GOT16_LO 15 // #lo(G + A)
98 1.10 matt #define R_PPC_GOT16_HI 16 // #hi(G + A)
99 1.10 matt #define R_PPC_GOT16_HA 17 // #ha(G + A)
100 1.10 matt #define R_PPC_PLTREL24 18 // (L + A - P) >> 2
101 1.10 matt #define R_PPC_COPY 19 // none
102 1.10 matt #define R_PPC_GLOB_DAT 20 // S + A
103 1.7 freza #define R_PPC_JMP_SLOT 21
104 1.10 matt #define R_PPC_RELATIVE 22 // B + A
105 1.10 matt #define R_PPC_LOCAL24PC 23 // (see R_PPC_REL24)
106 1.10 matt #define R_PPC_UADDR32 24 // S + A
107 1.10 matt #define R_PPC_UADDR16 25 // S + A
108 1.10 matt #define R_PPC_REL32 26 // S + A - P
109 1.10 matt #define R_PPC_PLT32 27 // L
110 1.10 matt #define R_PPC_PLTREL 28 // L - P
111 1.10 matt #define R_PPC_PLT16_LO 29 // #lo(L)
112 1.10 matt #define R_PPC_PLT16_HI 30 // #hi(L)
113 1.10 matt #define R_PPC_PLT16_HA 31 // #ha(L)
114 1.10 matt #define R_PPC_SDAREL16 32 // S + A - _SDA_BASE_
115 1.10 matt #define R_PPC_SECTOFF 33 // R + A
116 1.10 matt #define R_PPC_SECTOFF_LO 34 // #lo(R + A)
117 1.10 matt #define R_PPC_SECTOFF_HI 35 // #lo(R + A)
118 1.10 matt #define R_PPC_SECTOFF_HA 36 // #ha(R + A)
119 1.10 matt #define R_PPC_ADDR30 37 // (S + A - P) >> 2
120 1.10 matt /* PPC64 relocations */
121 1.10 matt #define R_PPC_ADDR64 38 // S + A
122 1.10 matt #define R_PPC_ADDR16_HIGHER 39 // #higher(S + A)
123 1.10 matt #define R_PPC_ADDR16_HIGHERA 40 // #highera(S + A)
124 1.10 matt #define R_PPC_ADDR16_HIGHEST 41 // #highest(S + A)
125 1.10 matt #define R_PPC_ADDR16_HIGHESTA 42 // #highesta(S + A)
126 1.10 matt #define R_PPC_UADDR64 43 // S + A
127 1.10 matt #define R_PPC_REL64 44 // S + A - P
128 1.10 matt #define R_PPC_PLT64 45 // L
129 1.10 matt #define R_PPC_PLTREL4 46 // L - P
130 1.10 matt #define R_PPC_TOC16 47 // S + A - .TOC.
131 1.10 matt #define R_PPC_TOC16_LO 48 // #lo(S + A - .TOC.)
132 1.10 matt #define R_PPC_TOC16_HI 49 // #lo(S + A - .TOC.)
133 1.10 matt #define R_PPC_TOC16_HA 50 // #ha(S + A - .TOC.)
134 1.10 matt #define R_PPC_TOC 51 // .TOC.
135 1.10 matt #define R_PPC_PLTGOT16 52 // M
136 1.10 matt #define R_PPC_PLTGOT16_LO 53 // #lo(M)
137 1.10 matt #define R_PPC_PLTGOT16_HI 54 // #lo(M)
138 1.10 matt #define R_PPC_PLTGOT16_HA 55 // #ha(M)
139 1.10 matt #define R_PPC_ADDR16_DS 56 // (S + A) >> 2
140 1.10 matt #define R_PPC_ADDR16_LO_DS 57 // #lo(S + A) >> 2
141 1.10 matt #define R_PPC_GOT16_DS 58 // G >> 2
142 1.10 matt #define R_PPC_GOT16_LO_DS 59 // #lo(G) >> 2
143 1.10 matt #define R_PPC_PLT16_LO_DS 60 // #lo(L) >> 2
144 1.10 matt #define R_PPC_SECTOFF16_DS 61 // (R + A) >> 2
145 1.10 matt #define R_PPC_SECTOFF16_LO_DS 62 // #lo(R + A) >> 2
146 1.10 matt #define R_PPC_TOC16_DS 63 // (S + A - .TOC.) >> 2
147 1.10 matt #define R_PPC_TOC16_LO_DS 64 // #lo(S + A - .TOC.) >> 2
148 1.10 matt #define R_PPC_PLTGOT16_DS 65 // M >> 2
149 1.10 matt #define R_PPC_PLTGOT16_LO_DS 66 // #lo(M) >> 2
150 1.2 tsubai
151 1.8 skrll /* TLS relocations */
152 1.10 matt #define R_PPC_TLS 67 // none
153 1.8 skrll
154 1.10 matt #define R_PPC_DTPMOD 68
155 1.10 matt #define R_PPC_TPREL16 69 // @tprel
156 1.10 matt #define R_PPC_TPREL16_LO 70 // #lo(@tprel)
157 1.10 matt #define R_PPC_TPREL16_HI 71 // #hi(@tprel)
158 1.10 matt #define R_PPC_TPREL16_HA 72 // #ha(@tprel)
159 1.10 matt #define R_PPC_TPREL 73 // @tprel
160 1.10 matt #define R_PPC_DTPREL16 74 // @got@dtprel
161 1.10 matt #define R_PPC_DTPREL16_LO 75 // #lo(@dtprel)
162 1.10 matt #define R_PPC_DTPREL16_HI 76 // #hi(@dtprel)
163 1.10 matt #define R_PPC_DTPREL16_HA 77 // #ha(@dtprel)
164 1.10 matt #define R_PPC_DTPREL 78 // @dtprel
165 1.10 matt
166 1.10 matt #define R_PPC_GOT_TLSGD16 79 // @got@tlsgd
167 1.10 matt #define R_PPC_GOT_TLSGD16_LO 80 // #lo(@got@tlsgd)
168 1.10 matt #define R_PPC_GOT_TLSGD16_HI 81 // #hi(@got@tlsgd)
169 1.10 matt #define R_PPC_GOT_TLSGD16_HA 82 // #ha(@got@tlsgd)
170 1.10 matt #define R_PPC_GOT_TLSLD16 83 // @got@tlsld
171 1.10 matt #define R_PPC_GOT_TLSLD16_LO 84 // #lo(@got@tlsld)
172 1.10 matt #define R_PPC_GOT_TLSLD16_HI 85 // #hi(@got@tlsld)
173 1.10 matt #define R_PPC_GOT_TLSLD16_HA 86 // #ha(@got@tlsld)
174 1.10 matt
175 1.10 matt #define R_PPC_GOT_TPREL16 87 // @got@tprel
176 1.10 matt #define R_PPC_GOT_TPREL16_LO 88 // #lo(@got@tprel)
177 1.10 matt #define R_PPC_GOT_TPREL16_HI 89 // #hi(@got@tprel)
178 1.10 matt #define R_PPC_GOT_TPREL16_HA 90 // #ha(@got@tprel)
179 1.10 matt #define R_PPC_GOT_DTPREL16 91 // @got@dtprel
180 1.10 matt #define R_PPC_GOT_DTPREL16_LO 92 // #lo(@got@dtprel)
181 1.10 matt #define R_PPC_GOT_DTPREL16_HI 93 // #hi(@got@dtprel)
182 1.10 matt #define R_PPC_GOT_DTPREL16_HA 94 // #ha(@got@dtprel)
183 1.8 skrll #define R_PPC_TLSGD 95
184 1.8 skrll #define R_PPC_TLSLD 96
185 1.8 skrll
186 1.10 matt /* PPC64 relocations */
187 1.10 matt #define R_PPC_TPREL16_DS 95 // @tprel
188 1.10 matt #define R_PPC_TPREL16_LO_DS 96 // #lo(@tprel)
189 1.10 matt #define R_PPC_TPREL16_HIGHER 97 // #higher(@tprel)
190 1.10 matt #define R_PPC_TPREL16_HIGHERA 98 // #highera(@tprel)
191 1.10 matt #define R_PPC_TPREL16_HIGHEST 99 // #highest(@tprel)
192 1.10 matt #define R_PPC_TPREL16_HIGHESTA 100 // #highesta(@tprel)
193 1.10 matt
194 1.10 matt #define R_PPC_DTPREL16_DS 101 // @dtprel
195 1.10 matt #define R_PPC_DTPREL16_LO_DS 102 // #lo(@dtprel)
196 1.10 matt #define R_PPC_DTPREL16_HIGHER 103 // #higher(@dtprel)
197 1.10 matt #define R_PPC_DTPREL16_HIGHERA 104 // #highera(@dtprel)
198 1.10 matt #define R_PPC_DTPREL16_HIGHEST 105 // #highest(@dtprel)
199 1.10 matt #define R_PPC_DTPREL16_HIGHESTA 106 // #highesta(@dtprel)
200 1.10 matt
201 1.13 joerg /* Indirect-function support */
202 1.13 joerg #define R_PPC_IRELATIVE 248
203 1.13 joerg
204 1.9 matt /* Used for the secure-plt PIC code sequences */
205 1.10 matt #define R_PPC_REL16 249 // S + A - P
206 1.10 matt #define R_PPC_REL16_LO 250 // #lo(S + A - P)
207 1.10 matt #define R_PPC_REL16_HI 251 // #hi(S + A - P)
208 1.10 matt #define R_PPC_REL16_HA 252 // #ha(S + A - P)
209 1.9 matt
210 1.7 freza #define R_TYPE(name) __CONCAT(R_PPC_,name)
211 1.10 matt
212 1.10 matt #endif /* _POWERPC_ELF_MACHDEP_H_ */
213