1#ifndef _ASM_POWERPC_ELF_H
2#define _ASM_POWERPC_ELF_H
3
4#ifdef __KERNEL__
5#include <linux/sched.h>
6#include <asm/page.h>
7#include <asm/string.h>
8#endif
9
10#include <linux/types.h>
11
12#include <asm/ptrace.h>
13#include <asm/cputable.h>
14#include <asm/auxvec.h>
15
16
17#define R_PPC_NONE 0
18#define R_PPC_ADDR32 1
19#define R_PPC_ADDR24 2
20#define R_PPC_ADDR16 3
21#define R_PPC_ADDR16_LO 4
22#define R_PPC_ADDR16_HI 5
23#define R_PPC_ADDR16_HA 6
24#define R_PPC_ADDR14 7
25#define R_PPC_ADDR14_BRTAKEN 8
26#define R_PPC_ADDR14_BRNTAKEN 9
27#define R_PPC_REL24 10
28#define R_PPC_REL14 11
29#define R_PPC_REL14_BRTAKEN 12
30#define R_PPC_REL14_BRNTAKEN 13
31#define R_PPC_GOT16 14
32#define R_PPC_GOT16_LO 15
33#define R_PPC_GOT16_HI 16
34#define R_PPC_GOT16_HA 17
35#define R_PPC_PLTREL24 18
36#define R_PPC_COPY 19
37#define R_PPC_GLOB_DAT 20
38#define R_PPC_JMP_SLOT 21
39#define R_PPC_RELATIVE 22
40#define R_PPC_LOCAL24PC 23
41#define R_PPC_UADDR32 24
42#define R_PPC_UADDR16 25
43#define R_PPC_REL32 26
44#define R_PPC_PLT32 27
45#define R_PPC_PLTREL32 28
46#define R_PPC_PLT16_LO 29
47#define R_PPC_PLT16_HI 30
48#define R_PPC_PLT16_HA 31
49#define R_PPC_SDAREL16 32
50#define R_PPC_SECTOFF 33
51#define R_PPC_SECTOFF_LO 34
52#define R_PPC_SECTOFF_HI 35
53#define R_PPC_SECTOFF_HA 36
54
55
56#define R_PPC_TLS 67
57#define R_PPC_DTPMOD32 68
58#define R_PPC_TPREL16 69
59#define R_PPC_TPREL16_LO 70
60#define R_PPC_TPREL16_HI 71
61#define R_PPC_TPREL16_HA 72
62#define R_PPC_TPREL32 73
63#define R_PPC_DTPREL16 74
64#define R_PPC_DTPREL16_LO 75
65#define R_PPC_DTPREL16_HI 76
66#define R_PPC_DTPREL16_HA 77
67#define R_PPC_DTPREL32 78
68#define R_PPC_GOT_TLSGD16 79
69#define R_PPC_GOT_TLSGD16_LO 80
70#define R_PPC_GOT_TLSGD16_HI 81
71#define R_PPC_GOT_TLSGD16_HA 82
72#define R_PPC_GOT_TLSLD16 83
73#define R_PPC_GOT_TLSLD16_LO 84
74#define R_PPC_GOT_TLSLD16_HI 85
75#define R_PPC_GOT_TLSLD16_HA 86
76#define R_PPC_GOT_TPREL16 87
77#define R_PPC_GOT_TPREL16_LO 88
78#define R_PPC_GOT_TPREL16_HI 89
79#define R_PPC_GOT_TPREL16_HA 90
80#define R_PPC_GOT_DTPREL16 91
81#define R_PPC_GOT_DTPREL16_LO 92
82#define R_PPC_GOT_DTPREL16_HI 93
83#define R_PPC_GOT_DTPREL16_HA 94
84
85
86#define R_PPC_NUM 95
87
88
89
90
91
92
93
94
95
96
97#define ELF_NGREG 48
98#define ELF_NFPREG 33
99
100typedef unsigned long elf_greg_t64;
101typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
102
103typedef unsigned int elf_greg_t32;
104typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
105typedef elf_gregset_t32 compat_elf_gregset_t;
106
107
108
109
110#ifdef __powerpc64__
111# define ELF_NVRREG32 33
112# define ELF_NVRREG 34
113# define ELF_NVSRHALFREG 32
114# define ELF_GREG_TYPE elf_greg_t64
115#else
116# define ELF_NEVRREG 34
117# define ELF_NVRREG 33
118# define ELF_GREG_TYPE elf_greg_t32
119# define ELF_ARCH EM_PPC
120# define ELF_CLASS ELFCLASS32
121# define ELF_DATA ELFDATA2MSB
122#endif
123
124#ifndef ELF_ARCH
125# define ELF_ARCH EM_PPC64
126# define ELF_CLASS ELFCLASS64
127# define ELF_DATA ELFDATA2MSB
128 typedef elf_greg_t64 elf_greg_t;
129 typedef elf_gregset_t64 elf_gregset_t;
130#else
131
132 typedef elf_greg_t32 elf_greg_t;
133 typedef elf_gregset_t32 elf_gregset_t;
134#endif
135
136
137typedef double elf_fpreg_t;
138typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159typedef __vector128 elf_vrreg_t;
160typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
161#ifdef __powerpc64__
162typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
163typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
164#endif
165
166#ifdef __KERNEL__
167
168
169
170#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
171#define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC)
172
173#define USE_ELF_CORE_DUMP
174#define CORE_DUMP_USE_REGSET
175#define ELF_EXEC_PAGESIZE PAGE_SIZE
176
177
178
179
180
181
182extern unsigned long randomize_et_dyn(unsigned long base);
183#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
184
185
186
187
188
189
190
191
192
193
194#define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
195 int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
196 (size_t)ELF_NGREG); \
197 for (i = 0; i < nregs; i++) \
198 elf_regs[i] = ((unsigned long *) regs)[i]; \
199 memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
200
201
202static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
203 struct pt_regs *regs)
204{
205 PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
206}
207#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
208
209typedef elf_vrregset_t elf_fpxregset_t;
210
211
212
213
214# define ELF_HWCAP (cur_cpu_spec->cpu_user_features)
215
216
217
218
219
220#define ELF_PLATFORM (cur_cpu_spec->platform)
221
222
223
224
225
226
227
228#define ELF_BASE_PLATFORM (powerpc_base_platform)
229
230#ifdef __powerpc64__
231# define ELF_PLAT_INIT(_r, load_addr) do { \
232 _r->gpr[2] = load_addr; \
233} while (0)
234#endif
235
236#ifdef __powerpc64__
237# define SET_PERSONALITY(ex) \
238do { \
239 unsigned long new_flags = 0; \
240 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
241 new_flags = _TIF_32BIT; \
242 if ((current_thread_info()->flags & _TIF_32BIT) \
243 != new_flags) \
244 set_thread_flag(TIF_ABI_PENDING); \
245 else \
246 clear_thread_flag(TIF_ABI_PENDING); \
247 if (personality(current->personality) != PER_LINUX32) \
248 set_personality(PER_LINUX | \
249 (current->personality & (~PER_MASK))); \
250} while (0)
251
252
253
254
255
256
257
258# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \
259 (exec_stk != EXSTACK_DISABLE_X) : 0)
260#else
261# define SET_PERSONALITY(ex) \
262 set_personality(PER_LINUX | (current->personality & (~PER_MASK)))
263# define elf_read_implies_exec(ex, exec_stk) (exec_stk != EXSTACK_DISABLE_X)
264#endif
265
266extern int dcache_bsize;
267extern int icache_bsize;
268extern int ucache_bsize;
269
270
271#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
272struct linux_binprm;
273extern int arch_setup_additional_pages(struct linux_binprm *bprm,
274 int uses_interp);
275#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b);
276
277
278#define STACK_RND_MASK (is_32bit_task() ? \
279 (0x7ff >> (PAGE_SHIFT - 12)) : \
280 (0x3ffff >> (PAGE_SHIFT - 12)))
281
282extern unsigned long arch_randomize_brk(struct mm_struct *mm);
283#define arch_randomize_brk arch_randomize_brk
284
285#endif
286
287
288
289
290
291
292
293
294
295
296
297#define ARCH_DLINFO \
298do { \
299 \
300 NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
301 NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
302 \
303 NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize); \
304 NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize); \
305 NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize); \
306 VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base) \
307} while (0)
308
309
310#define R_PPC64_NONE R_PPC_NONE
311#define R_PPC64_ADDR32 R_PPC_ADDR32
312#define R_PPC64_ADDR24 R_PPC_ADDR24
313#define R_PPC64_ADDR16 R_PPC_ADDR16
314#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO
315#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI
316#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA
317#define R_PPC64_ADDR14 R_PPC_ADDR14
318#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
319#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
320#define R_PPC64_REL24 R_PPC_REL24
321#define R_PPC64_REL14 R_PPC_REL14
322#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
323#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
324#define R_PPC64_GOT16 R_PPC_GOT16
325#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
326#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
327#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
328
329#define R_PPC64_COPY R_PPC_COPY
330#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
331#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
332#define R_PPC64_RELATIVE R_PPC_RELATIVE
333
334#define R_PPC64_UADDR32 R_PPC_UADDR32
335#define R_PPC64_UADDR16 R_PPC_UADDR16
336#define R_PPC64_REL32 R_PPC_REL32
337#define R_PPC64_PLT32 R_PPC_PLT32
338#define R_PPC64_PLTREL32 R_PPC_PLTREL32
339#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
340#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
341#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
342
343#define R_PPC64_SECTOFF R_PPC_SECTOFF
344#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
345#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
346#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
347#define R_PPC64_ADDR30 37
348#define R_PPC64_ADDR64 38
349#define R_PPC64_ADDR16_HIGHER 39
350#define R_PPC64_ADDR16_HIGHERA 40
351#define R_PPC64_ADDR16_HIGHEST 41
352#define R_PPC64_ADDR16_HIGHESTA 42
353#define R_PPC64_UADDR64 43
354#define R_PPC64_REL64 44
355#define R_PPC64_PLT64 45
356#define R_PPC64_PLTREL64 46
357#define R_PPC64_TOC16 47
358#define R_PPC64_TOC16_LO 48
359#define R_PPC64_TOC16_HI 49
360#define R_PPC64_TOC16_HA 50
361#define R_PPC64_TOC 51
362#define R_PPC64_PLTGOT16 52
363#define R_PPC64_PLTGOT16_LO 53
364#define R_PPC64_PLTGOT16_HI 54
365#define R_PPC64_PLTGOT16_HA 55
366
367#define R_PPC64_ADDR16_DS 56
368#define R_PPC64_ADDR16_LO_DS 57
369#define R_PPC64_GOT16_DS 58
370#define R_PPC64_GOT16_LO_DS 59
371#define R_PPC64_PLT16_LO_DS 60
372#define R_PPC64_SECTOFF_DS 61
373#define R_PPC64_SECTOFF_LO_DS 62
374#define R_PPC64_TOC16_DS 63
375#define R_PPC64_TOC16_LO_DS 64
376#define R_PPC64_PLTGOT16_DS 65
377#define R_PPC64_PLTGOT16_LO_DS 66
378
379
380#define R_PPC64_TLS 67
381#define R_PPC64_DTPMOD64 68
382#define R_PPC64_TPREL16 69
383#define R_PPC64_TPREL16_LO 70
384#define R_PPC64_TPREL16_HI 71
385#define R_PPC64_TPREL16_HA 72
386#define R_PPC64_TPREL64 73
387#define R_PPC64_DTPREL16 74
388#define R_PPC64_DTPREL16_LO 75
389#define R_PPC64_DTPREL16_HI 76
390#define R_PPC64_DTPREL16_HA 77
391#define R_PPC64_DTPREL64 78
392#define R_PPC64_GOT_TLSGD16 79
393#define R_PPC64_GOT_TLSGD16_LO 80
394#define R_PPC64_GOT_TLSGD16_HI 81
395#define R_PPC64_GOT_TLSGD16_HA 82
396#define R_PPC64_GOT_TLSLD16 83
397#define R_PPC64_GOT_TLSLD16_LO 84
398#define R_PPC64_GOT_TLSLD16_HI 85
399#define R_PPC64_GOT_TLSLD16_HA 86
400#define R_PPC64_GOT_TPREL16_DS 87
401#define R_PPC64_GOT_TPREL16_LO_DS 88
402#define R_PPC64_GOT_TPREL16_HI 89
403#define R_PPC64_GOT_TPREL16_HA 90
404#define R_PPC64_GOT_DTPREL16_DS 91
405#define R_PPC64_GOT_DTPREL16_LO_DS 92
406#define R_PPC64_GOT_DTPREL16_HI 93
407#define R_PPC64_GOT_DTPREL16_HA 94
408#define R_PPC64_TPREL16_DS 95
409#define R_PPC64_TPREL16_LO_DS 96
410#define R_PPC64_TPREL16_HIGHER 97
411#define R_PPC64_TPREL16_HIGHERA 98
412#define R_PPC64_TPREL16_HIGHEST 99
413#define R_PPC64_TPREL16_HIGHESTA 100
414#define R_PPC64_DTPREL16_DS 101
415#define R_PPC64_DTPREL16_LO_DS 102
416#define R_PPC64_DTPREL16_HIGHER 103
417#define R_PPC64_DTPREL16_HIGHERA 104
418#define R_PPC64_DTPREL16_HIGHEST 105
419#define R_PPC64_DTPREL16_HIGHESTA 106
420
421
422#define R_PPC64_NUM 107
423
424
425struct ppc64_opd_entry
426{
427 unsigned long funcaddr;
428 unsigned long r2;
429};
430
431#ifdef __KERNEL__
432
433#ifdef CONFIG_SPU_BASE
434
435#define NT_SPU 1
436
437#define ARCH_HAVE_EXTRA_ELF_NOTES
438
439#endif
440
441#endif
442
443#endif
444