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