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