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 */ 9 #ifndef _ASM_POWERPC_ELF_H 10 #define _ASM_POWERPC_ELF_H 11 12 #include <linux/sched.h> /* for task_struct */ 13 #include <asm/page.h> 14 #include <asm/string.h> 15 #include <uapi/asm/elf.h> 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) 21 #define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC) 22 23 #define CORE_DUMP_USE_REGSET 24 #define ELF_EXEC_PAGESIZE PAGE_SIZE 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 31 extern unsigned long randomize_et_dyn(unsigned long base); 32 #define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000)) 33 34 #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0) 35 36 /* 37 * Our registers are always unsigned longs, whether we're a 32 bit 38 * process or 64 bit, on either a 64 bit or 32 bit kernel. 39 * 40 * This macro relies on elf_regs[i] having the right type to truncate to, 41 * either u32 or u64. It defines the body of the elf_core_copy_regs 42 * function, either the native one with elf_gregset_t elf_regs or 43 * the 32-bit one with elf_gregset_t32 elf_regs. 44 */ 45 #define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \ 46 int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \ 47 (size_t)ELF_NGREG); \ 48 for (i = 0; i < nregs; i++) \ 49 elf_regs[i] = ((unsigned long *) regs)[i]; \ 50 memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0])) 51 52 /* Common routine for both 32-bit and 64-bit native processes */ 53 static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, 54 struct pt_regs *regs) 55 { 56 PPC_ELF_CORE_COPY_REGS(elf_regs, regs); 57 } 58 #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs); 59 60 typedef elf_vrregset_t elf_fpxregset_t; 61 62 /* ELF_HWCAP yields a mask that user programs can use to figure out what 63 instruction set this cpu supports. This could be done in userspace, 64 but it's not easy, and we've already done it here. */ 65 # define ELF_HWCAP (cur_cpu_spec->cpu_user_features) 66 # define ELF_HWCAP2 (cur_cpu_spec->cpu_user_features2) 67 68 /* This yields a string that ld.so will use to load implementation 69 specific libraries for optimization. This is more specific in 70 intent than poking at uname or /proc/cpuinfo. */ 71 72 #define ELF_PLATFORM (cur_cpu_spec->platform) 73 74 /* While ELF_PLATFORM indicates the ISA supported by the platform, it 75 * may not accurately reflect the underlying behavior of the hardware 76 * (as in the case of running in Power5+ compatibility mode on a 77 * Power6 machine). ELF_BASE_PLATFORM allows ld.so to load libraries 78 * that are tuned for the real hardware. 79 */ 80 #define ELF_BASE_PLATFORM (powerpc_base_platform) 81 82 #ifdef __powerpc64__ 83 # define ELF_PLAT_INIT(_r, load_addr) do { \ 84 _r->gpr[2] = load_addr; \ 85 } while (0) 86 #endif /* __powerpc64__ */ 87 88 #ifdef __powerpc64__ 89 # define SET_PERSONALITY(ex) \ 90 do { \ 91 if (((ex).e_flags & 0x3) == 2) \ 92 set_thread_flag(TIF_ELF2ABI); \ 93 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 94 set_thread_flag(TIF_32BIT); \ 95 else \ 96 clear_thread_flag(TIF_32BIT); \ 97 if (personality(current->personality) != PER_LINUX32) \ 98 set_personality(PER_LINUX | \ 99 (current->personality & (~PER_MASK))); \ 100 } while (0) 101 /* 102 * An executable for which elf_read_implies_exec() returns TRUE will 103 * have the READ_IMPLIES_EXEC personality flag set automatically. This 104 * is only required to work around bugs in old 32bit toolchains. Since 105 * the 64bit ABI has never had these issues dont enable the workaround 106 * even if we have an executable stack. 107 */ 108 # define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \ 109 (exec_stk == EXSTACK_DEFAULT) : 0) 110 #else 111 # define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT) 112 #endif /* __powerpc64__ */ 113 114 extern int dcache_bsize; 115 extern int icache_bsize; 116 extern int ucache_bsize; 117 118 /* vDSO has arch_setup_additional_pages */ 119 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 120 struct linux_binprm; 121 extern int arch_setup_additional_pages(struct linux_binprm *bprm, 122 int uses_interp); 123 #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b) 124 125 /* 1GB for 64bit, 8MB for 32bit */ 126 #define STACK_RND_MASK (is_32bit_task() ? \ 127 (0x7ff >> (PAGE_SHIFT - 12)) : \ 128 (0x3ffff >> (PAGE_SHIFT - 12))) 129 130 extern unsigned long arch_randomize_brk(struct mm_struct *mm); 131 #define arch_randomize_brk arch_randomize_brk 132 133 134 #ifdef CONFIG_SPU_BASE 135 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */ 136 #define NT_SPU 1 137 138 #define ARCH_HAVE_EXTRA_ELF_NOTES 139 140 #endif /* CONFIG_SPU_BASE */ 141 142 #endif /* _ASM_POWERPC_ELF_H */ 143