Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * ELF register definitions.. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation; either version | |
7 | * 2 of the License, or (at your option) any later version. | |
8 | */ | |
c3617f72 DH |
9 | #ifndef _ASM_POWERPC_ELF_H |
10 | #define _ASM_POWERPC_ELF_H | |
1da177e4 | 11 | |
c3617f72 DH |
12 | #include <linux/sched.h> /* for task_struct */ |
13 | #include <asm/page.h> | |
14 | #include <asm/string.h> | |
15 | #include <uapi/asm/elf.h> | |
1da177e4 LT |
16 | |
17 | /* | |
18 | * This is used to ensure we don't load something for the wrong architecture. | |
19 | */ | |
20 | #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) | |
01e31dba | 21 | #define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC) |
1da177e4 | 22 | |
81970387 | 23 | #define CORE_DUMP_USE_REGSET |
637a6ff6 | 24 | #define ELF_EXEC_PAGESIZE PAGE_SIZE |
1da177e4 LT |
25 | |
26 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical | |
27 | use of this is to invoke "./ld.so someprog" to test out a new version of | |
28 | the loader. We need to make sure that it is out of the way of the program | |
29 | that it will "exec", and that there is sufficient room for the brk. */ | |
30 | ||
501cb16d AB |
31 | extern unsigned long randomize_et_dyn(unsigned long base); |
32 | #define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000)) | |
1da177e4 | 33 | |
5f149cf0 RM |
34 | /* |
35 | * Our registers are always unsigned longs, whether we're a 32 bit | |
36 | * process or 64 bit, on either a 64 bit or 32 bit kernel. | |
37 | * | |
38 | * This macro relies on elf_regs[i] having the right type to truncate to, | |
39 | * either u32 or u64. It defines the body of the elf_core_copy_regs | |
40 | * function, either the native one with elf_gregset_t elf_regs or | |
41 | * the 32-bit one with elf_gregset_t32 elf_regs. | |
42 | */ | |
43 | #define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \ | |
44 | int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \ | |
45 | (size_t)ELF_NGREG); \ | |
46 | for (i = 0; i < nregs; i++) \ | |
47 | elf_regs[i] = ((unsigned long *) regs)[i]; \ | |
48 | memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0])) | |
49 | ||
50 | /* Common routine for both 32-bit and 64-bit native processes */ | |
a99eb2ef | 51 | static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, |
5f149cf0 | 52 | struct pt_regs *regs) |
1da177e4 | 53 | { |
5f149cf0 | 54 | PPC_ELF_CORE_COPY_REGS(elf_regs, regs); |
1da177e4 | 55 | } |
a99eb2ef | 56 | #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs); |
1da177e4 | 57 | |
1f7d6668 MN |
58 | typedef elf_vrregset_t elf_fpxregset_t; |
59 | ||
a99eb2ef | 60 | /* ELF_HWCAP yields a mask that user programs can use to figure out what |
1da177e4 LT |
61 | instruction set this cpu supports. This could be done in userspace, |
62 | but it's not easy, and we've already done it here. */ | |
a99eb2ef | 63 | # define ELF_HWCAP (cur_cpu_spec->cpu_user_features) |
2171364d | 64 | # define ELF_HWCAP2 (cur_cpu_spec->cpu_user_features2) |
1da177e4 LT |
65 | |
66 | /* This yields a string that ld.so will use to load implementation | |
67 | specific libraries for optimization. This is more specific in | |
80f15dc7 | 68 | intent than poking at uname or /proc/cpuinfo. */ |
1da177e4 | 69 | |
80f15dc7 | 70 | #define ELF_PLATFORM (cur_cpu_spec->platform) |
9115d134 NL |
71 | |
72 | /* While ELF_PLATFORM indicates the ISA supported by the platform, it | |
73 | * may not accurately reflect the underlying behavior of the hardware | |
74 | * (as in the case of running in Power5+ compatibility mode on a | |
75 | * Power6 machine). ELF_BASE_PLATFORM allows ld.so to load libraries | |
76 | * that are tuned for the real hardware. | |
77 | */ | |
78 | #define ELF_BASE_PLATFORM (powerpc_base_platform) | |
1da177e4 | 79 | |
80f15dc7 PM |
80 | #ifdef __powerpc64__ |
81 | # define ELF_PLAT_INIT(_r, load_addr) do { \ | |
82 | _r->gpr[2] = load_addr; \ | |
83 | } while (0) | |
84 | #endif /* __powerpc64__ */ | |
1da177e4 | 85 | |
a99eb2ef | 86 | #ifdef __powerpc64__ |
0b592682 | 87 | # define SET_PERSONALITY(ex) \ |
1da177e4 | 88 | do { \ |
1da177e4 | 89 | if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ |
94f28da8 | 90 | set_thread_flag(TIF_32BIT); \ |
1da177e4 | 91 | else \ |
94f28da8 | 92 | clear_thread_flag(TIF_32BIT); \ |
ce10d979 | 93 | if (personality(current->personality) != PER_LINUX32) \ |
a91a03ee EM |
94 | set_personality(PER_LINUX | \ |
95 | (current->personality & (~PER_MASK))); \ | |
1da177e4 | 96 | } while (0) |
1da177e4 LT |
97 | /* |
98 | * An executable for which elf_read_implies_exec() returns TRUE will | |
a2f95a5a AB |
99 | * have the READ_IMPLIES_EXEC personality flag set automatically. This |
100 | * is only required to work around bugs in old 32bit toolchains. Since | |
101 | * the 64bit ABI has never had these issues dont enable the workaround | |
102 | * even if we have an executable stack. | |
1da177e4 | 103 | */ |
cab175f9 | 104 | # define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \ |
d89ebca2 | 105 | (exec_stk == EXSTACK_DEFAULT) : 0) |
a99eb2ef | 106 | #else |
d89ebca2 | 107 | # define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT) |
a99eb2ef | 108 | #endif /* __powerpc64__ */ |
1da177e4 | 109 | |
1da177e4 LT |
110 | extern int dcache_bsize; |
111 | extern int icache_bsize; | |
112 | extern int ucache_bsize; | |
113 | ||
a7f290da BH |
114 | /* vDSO has arch_setup_additional_pages */ |
115 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES | |
1da177e4 | 116 | struct linux_binprm; |
a7f290da | 117 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, |
fc5243d9 | 118 | int uses_interp); |
497888cf | 119 | #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b) |
1da177e4 | 120 | |
2dadb987 AB |
121 | /* 1GB for 64bit, 8MB for 32bit */ |
122 | #define STACK_RND_MASK (is_32bit_task() ? \ | |
123 | (0x7ff >> (PAGE_SHIFT - 12)) : \ | |
124 | (0x3ffff >> (PAGE_SHIFT - 12))) | |
125 | ||
912f9ee2 AB |
126 | extern unsigned long arch_randomize_brk(struct mm_struct *mm); |
127 | #define arch_randomize_brk arch_randomize_brk | |
128 | ||
178f8d78 | 129 | |
e055595d | 130 | #ifdef CONFIG_SPU_BASE |
bf1ab978 DGM |
131 | /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */ |
132 | #define NT_SPU 1 | |
133 | ||
bf1ab978 | 134 | #define ARCH_HAVE_EXTRA_ELF_NOTES |
e5501492 ME |
135 | |
136 | #endif /* CONFIG_SPU_BASE */ | |
bf1ab978 | 137 | |
a99eb2ef | 138 | #endif /* _ASM_POWERPC_ELF_H */ |