Richard Kuo | 8feca0e | 2011-10-31 18:27:03 -0500 | [diff] [blame] | 1 | /* |
| 2 | * ELF definitions for the Hexagon architecture |
| 3 | * |
| 4 | * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 and |
| 8 | * only version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 | * 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef __ASM_ELF_H |
| 22 | #define __ASM_ELF_H |
| 23 | |
| 24 | #include <asm/ptrace.h> |
| 25 | #include <asm/user.h> |
| 26 | |
| 27 | /* |
| 28 | * This should really be in linux/elf-em.h. |
| 29 | */ |
| 30 | #define EM_HEXAGON 164 /* QUALCOMM Hexagon */ |
| 31 | |
| 32 | struct elf32_hdr; |
| 33 | |
| 34 | /* |
| 35 | * ELF header e_flags defines. |
| 36 | */ |
| 37 | |
| 38 | /* should have stuff like "CPU type" and maybe "ABI version", etc */ |
| 39 | |
| 40 | /* Hexagon relocations */ |
| 41 | /* V2 */ |
| 42 | #define R_HEXAGON_NONE 0 |
| 43 | #define R_HEXAGON_B22_PCREL 1 |
| 44 | #define R_HEXAGON_B15_PCREL 2 |
| 45 | #define R_HEXAGON_B7_PCREL 3 |
| 46 | #define R_HEXAGON_LO16 4 |
| 47 | #define R_HEXAGON_HI16 5 |
| 48 | #define R_HEXAGON_32 6 |
| 49 | #define R_HEXAGON_16 7 |
| 50 | #define R_HEXAGON_8 8 |
| 51 | #define R_HEXAGON_GPREL16_0 9 |
| 52 | #define R_HEXAGON_GPREL16_1 10 |
| 53 | #define R_HEXAGON_GPREL16_2 11 |
| 54 | #define R_HEXAGON_GPREL16_3 12 |
| 55 | #define R_HEXAGON_HL16 13 |
| 56 | /* V3 */ |
| 57 | #define R_HEXAGON_B13_PCREL 14 |
| 58 | /* V4 */ |
| 59 | #define R_HEXAGON_B9_PCREL 15 |
| 60 | /* V4 (extenders) */ |
| 61 | #define R_HEXAGON_B32_PCREL_X 16 |
| 62 | #define R_HEXAGON_32_6_X 17 |
| 63 | /* V4 (extended) */ |
| 64 | #define R_HEXAGON_B22_PCREL_X 18 |
| 65 | #define R_HEXAGON_B15_PCREL_X 19 |
| 66 | #define R_HEXAGON_B13_PCREL_X 20 |
| 67 | #define R_HEXAGON_B9_PCREL_X 21 |
| 68 | #define R_HEXAGON_B7_PCREL_X 22 |
| 69 | #define R_HEXAGON_16_X 23 |
| 70 | #define R_HEXAGON_12_X 24 |
| 71 | #define R_HEXAGON_11_X 25 |
| 72 | #define R_HEXAGON_10_X 26 |
| 73 | #define R_HEXAGON_9_X 27 |
| 74 | #define R_HEXAGON_8_X 28 |
| 75 | #define R_HEXAGON_7_X 29 |
| 76 | #define R_HEXAGON_6_X 30 |
| 77 | /* V2 PIC */ |
| 78 | #define R_HEXAGON_32_PCREL 31 |
| 79 | #define R_HEXAGON_COPY 32 |
| 80 | #define R_HEXAGON_GLOB_DAT 33 |
| 81 | #define R_HEXAGON_JMP_SLOT 34 |
| 82 | #define R_HEXAGON_RELATIVE 35 |
| 83 | #define R_HEXAGON_PLT_B22_PCREL 36 |
| 84 | #define R_HEXAGON_GOTOFF_LO16 37 |
| 85 | #define R_HEXAGON_GOTOFF_HI16 38 |
| 86 | #define R_HEXAGON_GOTOFF_32 39 |
| 87 | #define R_HEXAGON_GOT_LO16 40 |
| 88 | #define R_HEXAGON_GOT_HI16 41 |
| 89 | #define R_HEXAGON_GOT_32 42 |
| 90 | #define R_HEXAGON_GOT_16 43 |
| 91 | |
| 92 | /* |
| 93 | * ELF register definitions.. |
| 94 | */ |
| 95 | typedef unsigned long elf_greg_t; |
| 96 | |
| 97 | typedef struct user_regs_struct elf_gregset_t; |
| 98 | #define ELF_NGREG (sizeof(elf_gregset_t)/sizeof(unsigned long)) |
| 99 | |
| 100 | /* Placeholder */ |
| 101 | typedef unsigned long elf_fpregset_t; |
| 102 | |
| 103 | /* |
| 104 | * Bypass the whole "regsets" thing for now and use the define. |
| 105 | */ |
| 106 | |
| 107 | #define ELF_CORE_COPY_REGS(DEST, REGS) \ |
| 108 | do { \ |
| 109 | DEST.r0 = REGS->r00; \ |
| 110 | DEST.r1 = REGS->r01; \ |
| 111 | DEST.r2 = REGS->r02; \ |
| 112 | DEST.r3 = REGS->r03; \ |
| 113 | DEST.r4 = REGS->r04; \ |
| 114 | DEST.r5 = REGS->r05; \ |
| 115 | DEST.r6 = REGS->r06; \ |
| 116 | DEST.r7 = REGS->r07; \ |
| 117 | DEST.r8 = REGS->r08; \ |
| 118 | DEST.r9 = REGS->r09; \ |
| 119 | DEST.r10 = REGS->r10; \ |
| 120 | DEST.r11 = REGS->r11; \ |
| 121 | DEST.r12 = REGS->r12; \ |
| 122 | DEST.r13 = REGS->r13; \ |
| 123 | DEST.r14 = REGS->r14; \ |
| 124 | DEST.r15 = REGS->r15; \ |
| 125 | DEST.r16 = REGS->r16; \ |
| 126 | DEST.r17 = REGS->r17; \ |
| 127 | DEST.r18 = REGS->r18; \ |
| 128 | DEST.r19 = REGS->r19; \ |
| 129 | DEST.r20 = REGS->r20; \ |
| 130 | DEST.r21 = REGS->r21; \ |
| 131 | DEST.r22 = REGS->r22; \ |
| 132 | DEST.r23 = REGS->r23; \ |
| 133 | DEST.r24 = REGS->r24; \ |
| 134 | DEST.r25 = REGS->r25; \ |
| 135 | DEST.r26 = REGS->r26; \ |
| 136 | DEST.r27 = REGS->r27; \ |
| 137 | DEST.r28 = REGS->r28; \ |
| 138 | DEST.r29 = pt_psp(REGS); \ |
| 139 | DEST.r30 = REGS->r30; \ |
| 140 | DEST.r31 = REGS->r31; \ |
| 141 | DEST.sa0 = REGS->sa0; \ |
| 142 | DEST.lc0 = REGS->lc0; \ |
| 143 | DEST.sa1 = REGS->sa1; \ |
| 144 | DEST.lc1 = REGS->lc1; \ |
| 145 | DEST.m0 = REGS->m0; \ |
| 146 | DEST.m1 = REGS->m1; \ |
| 147 | DEST.usr = REGS->usr; \ |
| 148 | DEST.p3_0 = REGS->preds; \ |
| 149 | DEST.gp = REGS->gp; \ |
| 150 | DEST.ugp = REGS->ugp; \ |
| 151 | DEST.pc = pt_elr(REGS); \ |
| 152 | DEST.cause = pt_cause(REGS); \ |
| 153 | DEST.badva = pt_badva(REGS); \ |
| 154 | } while (0); |
| 155 | |
| 156 | |
| 157 | |
| 158 | /* |
| 159 | * This is used to ensure we don't load something for the wrong architecture. |
| 160 | * Checks the machine and ABI type. |
| 161 | */ |
| 162 | #define elf_check_arch(hdr) ((hdr)->e_machine == EM_HEXAGON) |
| 163 | |
| 164 | /* |
| 165 | * These are used to set parameters in the core dumps. |
| 166 | */ |
| 167 | #define ELF_CLASS ELFCLASS32 |
| 168 | #define ELF_DATA ELFDATA2LSB |
| 169 | #define ELF_ARCH EM_HEXAGON |
| 170 | |
| 171 | #ifdef CONFIG_HEXAGON_ARCH_V2 |
| 172 | #define ELF_CORE_EFLAGS 0x1 |
| 173 | #endif |
| 174 | |
| 175 | #ifdef CONFIG_HEXAGON_ARCH_V3 |
| 176 | #define ELF_CORE_EFLAGS 0x2 |
| 177 | #endif |
| 178 | |
| 179 | #ifdef CONFIG_HEXAGON_ARCH_V4 |
| 180 | #define ELF_CORE_EFLAGS 0x3 |
| 181 | #endif |
| 182 | |
| 183 | /* |
| 184 | * Some architectures have ld.so set up a pointer to a function |
| 185 | * to be registered using atexit, to facilitate cleanup. So that |
| 186 | * static executables will be well-behaved, we would null the register |
| 187 | * in question here, in the pt_regs structure passed. For now, |
| 188 | * leave it a null macro. |
| 189 | */ |
| 190 | #define ELF_PLAT_INIT(regs, load_addr) do { } while (0) |
| 191 | |
| 192 | #define USE_ELF_CORE_DUMP |
| 193 | #define CORE_DUMP_USE_REGSET |
| 194 | |
| 195 | /* Hrm is this going to cause problems for changing PAGE_SIZE? */ |
| 196 | #define ELF_EXEC_PAGESIZE 4096 |
| 197 | |
| 198 | /* |
| 199 | * This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 200 | * use of this is to invoke "./ld.so someprog" to test out a new version of |
| 201 | * the loader. We need to make sure that it is out of the way of the program |
| 202 | * that it will "exec", and that there is sufficient room for the brk. |
| 203 | */ |
| 204 | #define ELF_ET_DYN_BASE 0x08000000UL |
| 205 | |
| 206 | /* |
| 207 | * This yields a mask that user programs can use to figure out what |
| 208 | * instruction set this cpu supports. |
| 209 | */ |
| 210 | #define ELF_HWCAP (0) |
| 211 | |
| 212 | /* |
| 213 | * This yields a string that ld.so will use to load implementation |
| 214 | * specific libraries for optimization. This is more specific in |
| 215 | * intent than poking at uname or /proc/cpuinfo. |
| 216 | */ |
| 217 | #define ELF_PLATFORM (NULL) |
| 218 | |
| 219 | #ifdef __KERNEL__ |
Jiri Kosina | 16f3e95 | 2012-10-04 17:12:20 -0700 | [diff] [blame^] | 220 | #define SET_PERSONALITY(ex) \ |
| 221 | set_personality(PER_LINUX | (current->personality & (~PER_MASK))) |
Richard Kuo | 8feca0e | 2011-10-31 18:27:03 -0500 | [diff] [blame] | 222 | #endif |
| 223 | |
| 224 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 |
| 225 | struct linux_binprm; |
| 226 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, |
| 227 | int uses_interp); |
| 228 | |
| 229 | |
| 230 | #endif |