Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame^] | 9 | #ifndef _ASM_POWERPC_ELF_H |
| 10 | #define _ASM_POWERPC_ELF_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
David Howells | c3617f7 | 2012-10-09 09:47:26 +0100 | [diff] [blame^] | 12 | #include <linux/sched.h> /* for task_struct */ |
| 13 | #include <asm/page.h> |
| 14 | #include <asm/string.h> |
| 15 | #include <uapi/asm/elf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) |
Roland McGrath | 01e31db | 2008-01-02 17:03:11 -0800 | [diff] [blame] | 21 | #define compat_elf_check_arch(x) ((x)->e_machine == EM_PPC) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Roland McGrath | 8197038 | 2007-12-20 03:58:12 -0800 | [diff] [blame] | 23 | #define CORE_DUMP_USE_REGSET |
Olof Johansson | 637a6ff | 2005-09-20 13:47:41 +1000 | [diff] [blame] | 24 | #define ELF_EXEC_PAGESIZE PAGE_SIZE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Anton Blanchard | 501cb16 | 2009-02-22 01:50:07 +0000 | [diff] [blame] | 31 | extern unsigned long randomize_et_dyn(unsigned long base); |
| 32 | #define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Roland McGrath | 5f149cf | 2007-10-16 23:26:55 -0700 | [diff] [blame] | 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 */ |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 51 | static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, |
Roland McGrath | 5f149cf | 2007-10-16 23:26:55 -0700 | [diff] [blame] | 52 | struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Roland McGrath | 5f149cf | 2007-10-16 23:26:55 -0700 | [diff] [blame] | 54 | PPC_ELF_CORE_COPY_REGS(elf_regs, regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | } |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 56 | #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Mark Nelson | 1f7d666 | 2007-10-16 23:25:40 -0700 | [diff] [blame] | 58 | typedef elf_vrregset_t elf_fpxregset_t; |
| 59 | |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 60 | /* ELF_HWCAP yields a mask that user programs can use to figure out what |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. */ |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 63 | # define ELF_HWCAP (cur_cpu_spec->cpu_user_features) |
Paul Mackerras | 80f15dc | 2006-01-14 10:11:39 +1100 | [diff] [blame] | 64 | |
| 65 | /* This yields a string that ld.so will use to load implementation |
| 66 | specific libraries for optimization. This is more specific in |
| 67 | intent than poking at uname or /proc/cpuinfo. */ |
| 68 | |
| 69 | #define ELF_PLATFORM (cur_cpu_spec->platform) |
| 70 | |
Nathan Lynch | 9115d13 | 2008-07-16 09:58:51 +1000 | [diff] [blame] | 71 | /* While ELF_PLATFORM indicates the ISA supported by the platform, it |
| 72 | * may not accurately reflect the underlying behavior of the hardware |
| 73 | * (as in the case of running in Power5+ compatibility mode on a |
| 74 | * Power6 machine). ELF_BASE_PLATFORM allows ld.so to load libraries |
| 75 | * that are tuned for the real hardware. |
| 76 | */ |
| 77 | #define ELF_BASE_PLATFORM (powerpc_base_platform) |
| 78 | |
Kumar Gala | 400d221 | 2005-09-27 15:13:12 -0500 | [diff] [blame] | 79 | #ifdef __powerpc64__ |
Paul Mackerras | 06d67d5 | 2005-10-10 22:29:05 +1000 | [diff] [blame] | 80 | # define ELF_PLAT_INIT(_r, load_addr) do { \ |
| 81 | _r->gpr[2] = load_addr; \ |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 82 | } while (0) |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 83 | #endif /* __powerpc64__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 85 | #ifdef __powerpc64__ |
Martin Schwidefsky | 0b59268 | 2008-10-16 15:39:57 +0200 | [diff] [blame] | 86 | # define SET_PERSONALITY(ex) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | do { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ |
Andreas Schwab | 94f28da | 2010-01-30 10:20:59 +0000 | [diff] [blame] | 89 | set_thread_flag(TIF_32BIT); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | else \ |
Andreas Schwab | 94f28da | 2010-01-30 10:20:59 +0000 | [diff] [blame] | 91 | clear_thread_flag(TIF_32BIT); \ |
Paul Mackerras | ce10d97 | 2005-06-08 21:59:15 +1000 | [diff] [blame] | 92 | if (personality(current->personality) != PER_LINUX32) \ |
Eric B Munson | a91a03e | 2008-07-01 02:12:13 +1000 | [diff] [blame] | 93 | set_personality(PER_LINUX | \ |
| 94 | (current->personality & (~PER_MASK))); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | /* |
| 97 | * An executable for which elf_read_implies_exec() returns TRUE will |
Anton Blanchard | a2f95a5 | 2005-05-01 08:58:45 -0700 | [diff] [blame] | 98 | * have the READ_IMPLIES_EXEC personality flag set automatically. This |
| 99 | * is only required to work around bugs in old 32bit toolchains. Since |
| 100 | * the 64bit ABI has never had these issues dont enable the workaround |
| 101 | * even if we have an executable stack. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | */ |
Denis Kirjanov | cab175f | 2010-08-27 03:49:11 +0000 | [diff] [blame] | 103 | # define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \ |
Kumar Gala | d89ebca | 2009-04-28 03:32:36 +0000 | [diff] [blame] | 104 | (exec_stk == EXSTACK_DEFAULT) : 0) |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 105 | #else |
Andreas Schwab | 59e4c3a2 | 2009-04-16 06:22:01 +0000 | [diff] [blame] | 106 | # define SET_PERSONALITY(ex) \ |
| 107 | set_personality(PER_LINUX | (current->personality & (~PER_MASK))) |
Kumar Gala | d89ebca | 2009-04-28 03:32:36 +0000 | [diff] [blame] | 108 | # define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT) |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 109 | #endif /* __powerpc64__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | extern int dcache_bsize; |
| 112 | extern int icache_bsize; |
| 113 | extern int ucache_bsize; |
| 114 | |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 115 | /* vDSO has arch_setup_additional_pages */ |
| 116 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | struct linux_binprm; |
Benjamin Herrenschmidt | a7f290d | 2005-11-11 21:15:21 +1100 | [diff] [blame] | 118 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, |
Martin Schwidefsky | fc5243d | 2008-12-25 13:38:35 +0100 | [diff] [blame] | 119 | int uses_interp); |
Phil Carmody | 497888c | 2011-07-14 15:07:13 +0300 | [diff] [blame] | 120 | #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Anton Blanchard | 2dadb98 | 2009-02-22 01:50:02 +0000 | [diff] [blame] | 122 | /* 1GB for 64bit, 8MB for 32bit */ |
| 123 | #define STACK_RND_MASK (is_32bit_task() ? \ |
| 124 | (0x7ff >> (PAGE_SHIFT - 12)) : \ |
| 125 | (0x3ffff >> (PAGE_SHIFT - 12))) |
| 126 | |
Anton Blanchard | 912f9ee | 2009-02-22 01:50:04 +0000 | [diff] [blame] | 127 | extern unsigned long arch_randomize_brk(struct mm_struct *mm); |
| 128 | #define arch_randomize_brk arch_randomize_brk |
| 129 | |
Adrian Bunk | 178f8d7 | 2008-06-24 03:48:28 +1000 | [diff] [blame] | 130 | |
Arnd Bergmann | e055595 | 2006-11-27 19:18:55 +0100 | [diff] [blame] | 131 | #ifdef CONFIG_SPU_BASE |
Dwayne Grant McConnell | bf1ab97 | 2006-11-23 00:46:37 +0100 | [diff] [blame] | 132 | /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */ |
| 133 | #define NT_SPU 1 |
| 134 | |
Dwayne Grant McConnell | bf1ab97 | 2006-11-23 00:46:37 +0100 | [diff] [blame] | 135 | #define ARCH_HAVE_EXTRA_ELF_NOTES |
Michael Ellerman | e550149 | 2007-09-19 14:38:12 +1000 | [diff] [blame] | 136 | |
| 137 | #endif /* CONFIG_SPU_BASE */ |
Dwayne Grant McConnell | bf1ab97 | 2006-11-23 00:46:37 +0100 | [diff] [blame] | 138 | |
Becky Bruce | a99eb2e | 2005-09-19 19:17:27 -0500 | [diff] [blame] | 139 | #endif /* _ASM_POWERPC_ELF_H */ |