| 1 | /* |
| 2 | * arch/ubicom32/include/asm/elf.h |
| 3 | * Definitions for elf executable format for Ubicom32 architecture. |
| 4 | * |
| 5 | * (C) Copyright 2009, Ubicom, Inc. |
| 6 | * |
| 7 | * This file is part of the Ubicom32 Linux Kernel Port. |
| 8 | * |
| 9 | * The Ubicom32 Linux Kernel Port is free software: you can redistribute |
| 10 | * it and/or modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation, either version 2 of the |
| 12 | * License, or (at your option) any later version. |
| 13 | * |
| 14 | * The Ubicom32 Linux Kernel Port is distributed in the hope that it |
| 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 16 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with the Ubicom32 Linux Kernel Port. If not, |
| 21 | * see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | * Ubicom32 implementation derived from (with many thanks): |
| 24 | * arch/m68knommu |
| 25 | * arch/blackfin |
| 26 | * arch/parisc |
| 27 | */ |
| 28 | #ifndef _ASM_UBICOM32_ELF_H |
| 29 | #define _ASM_UBICOM32_ELF_H |
| 30 | |
| 31 | /* |
| 32 | * ELF register definitions.. |
| 33 | */ |
| 34 | |
| 35 | #include <asm/ptrace.h> |
| 36 | #include <asm/user.h> |
| 37 | |
| 38 | /* |
| 39 | * Processor specific flags for the ELF header e_flags field. |
| 40 | */ |
| 41 | #define EF_UBICOM32_V3 0x00000001 /* -fmarch=ubicom32v3 */ |
| 42 | #define EF_UBICOM32_V4 0x00000002 /* -fmarch=ubicom32v4 */ |
| 43 | #define EF_UBICOM32_PIC 0x80000000 /* -fpic */ |
| 44 | #define EF_UBICOM32_FDPIC 0x40000000 /* -mfdpic */ |
| 45 | |
| 46 | /* |
| 47 | * Ubicom32 ELF relocation types |
| 48 | */ |
| 49 | #define R_UBICOM32_NONE 0 |
| 50 | #define R_UBICOM32_16 1 |
| 51 | #define R_UBICOM32_32 2 |
| 52 | #define R_UBICOM32_LO16 3 |
| 53 | #define R_UBICOM32_HI16 4 |
| 54 | #define R_UBICOM32_21_PCREL 5 |
| 55 | #define R_UBICOM32_24_PCREL 6 |
| 56 | #define R_UBICOM32_HI24 7 |
| 57 | #define R_UBICOM32_LO7_S 8 |
| 58 | #define R_UBICOM32_LO7_2_S 9 |
| 59 | #define R_UBICOM32_LO7_4_S 10 |
| 60 | #define R_UBICOM32_LO7_D 11 |
| 61 | #define R_UBICOM32_LO7_2_D 12 |
| 62 | #define R_UBICOM32_LO7_4_D 13 |
| 63 | #define R_UBICOM32_32_HARVARD 14 |
| 64 | #define R_UBICOM32_LO7_CALLI 15 |
| 65 | #define R_UBICOM32_LO16_CALLI 16 |
| 66 | #define R_UBICOM32_GOT_HI24 17 |
| 67 | #define R_UBICOM32_GOT_LO7_S 18 |
| 68 | #define R_UBICOM32_GOT_LO7_2_S 19 |
| 69 | #define R_UBICOM32_GOT_LO7_4_S 20 |
| 70 | #define R_UBICOM32_GOT_LO7_D 21 |
| 71 | #define R_UBICOM32_GOT_LO7_2_D 22 |
| 72 | #define R_UBICOM32_GOT_LO7_4_D 23 |
| 73 | #define R_UBICOM32_FUNCDESC_GOT_HI24 24 |
| 74 | #define R_UBICOM32_FUNCDESC_GOT_LO7_S 25 |
| 75 | #define R_UBICOM32_FUNCDESC_GOT_LO7_2_S 26 |
| 76 | #define R_UBICOM32_FUNCDESC_GOT_LO7_4_S 27 |
| 77 | #define R_UBICOM32_FUNCDESC_GOT_LO7_D 28 |
| 78 | #define R_UBICOM32_FUNCDESC_GOT_LO7_2_D 29 |
| 79 | #define R_UBICOM32_FUNCDESC_GOT_LO7_4_D 30 |
| 80 | #define R_UBICOM32_GOT_LO7_CALLI 31 |
| 81 | #define R_UBICOM32_FUNCDESC_GOT_LO7_CALLI 32 |
| 82 | #define R_UBICOM32_FUNCDESC_VALUE 33 |
| 83 | #define R_UBICOM32_FUNCDESC 34 |
| 84 | #define R_UBICOM32_GOTOFFSET_LO 35 |
| 85 | #define R_UBICOM32_GOTOFFSET_HI 36 |
| 86 | #define R_UBICOM32_FUNCDESC_GOTOFFSET_LO 37 |
| 87 | #define R_UBICOM32_FUNCDESC_GOTOFFSET_HI 38 |
| 88 | #define R_UBICOM32_GNU_VTINHERIT 200 |
| 89 | #define R_UBICOM32_GNU_VTENTRY 201 |
| 90 | |
| 91 | typedef unsigned long elf_greg_t; |
| 92 | |
| 93 | #define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t)) |
| 94 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 95 | |
| 96 | typedef struct user_ubicom32fp_struct elf_fpregset_t; |
| 97 | |
| 98 | /* |
| 99 | * This is used to ensure we don't load something for the wrong architecture. |
| 100 | */ |
| 101 | #define elf_check_arch(x) ((x)->e_machine == EM_UBICOM32) |
| 102 | |
| 103 | #define elf_check_fdpic(x) ((x)->e_flags & EF_UBICOM32_FDPIC) |
| 104 | |
| 105 | #define elf_check_const_displacement(x) ((x)->e_flags & EF_UBICOM32_PIC) |
| 106 | |
| 107 | /* |
| 108 | * These are used to set parameters in the core dumps. |
| 109 | */ |
| 110 | #define ELF_CLASS ELFCLASS32 |
| 111 | #define ELF_DATA ELFDATA2MSB |
| 112 | #define ELF_ARCH EM_UBICOM32 |
| 113 | |
| 114 | /* For SVR4/m68k the function pointer to be registered with `atexit' is |
| 115 | passed in %a1. Although my copy of the ABI has no such statement, it |
| 116 | is actually used on ASV. */ |
| 117 | #define ELF_PLAT_INIT(_r, load_addr) _r->a1 = 0 |
| 118 | |
| 119 | #define ELF_FDPIC_PLAT_INIT(_regs, _exec_map_addr, _interp_map_addr, \ |
| 120 | _dynamic_addr) \ |
| 121 | do { \ |
| 122 | _regs->dn[1] = _exec_map_addr; \ |
| 123 | _regs->dn[2] = _interp_map_addr; \ |
| 124 | _regs->dn[3] = _dynamic_addr; \ |
| 125 | _regs->an[1] = 0; /* dl_fini will be set by ldso */ \ |
| 126 | } while (0) |
| 127 | |
| 128 | #define USE_ELF_CORE_DUMP |
| 129 | #define ELF_EXEC_PAGESIZE 4096 |
| 130 | |
| 131 | #ifdef __KERNEL__ |
| 132 | #ifdef CONFIG_UBICOM32_V4 |
| 133 | #define ELF_FDPIC_CORE_EFLAGS (EF_UBICOM32_FDPIC | EF_UBICOM32_V4) |
| 134 | #elif defined CONFIG_UBICOM32_V3 |
| 135 | #define ELF_FDPIC_CORE_EFLAGS (EF_UBICOM32_FDPIC | EF_UBICOM32_V3) |
| 136 | #else |
| 137 | #error Unknown/Unsupported ubicom32 architecture. |
| 138 | #endif |
| 139 | #endif |
| 140 | |
| 141 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 142 | use of this is to invoke "./ld.so someprog" to test out a new version of |
| 143 | the loader. We need to make sure that it is out of the way of the program |
| 144 | that it will "exec", and that there is sufficient room for the brk. */ |
| 145 | |
| 146 | #define ELF_ET_DYN_BASE 0xD0000000UL |
| 147 | |
| 148 | /* |
| 149 | * For Ubicom32, the elf_gregset_t and struct pt_regs are the same size |
| 150 | * data structure so a copy is performed instead of providing the |
| 151 | * ELF_CORE_COPY_REGS macro. |
| 152 | */ |
| 153 | |
| 154 | /* |
| 155 | * ELF_CORE_COPY_TASK_REGS is needed to dump register state from multi threaded user projects. |
| 156 | */ |
| 157 | extern int dump_task_regs(struct task_struct *, elf_gregset_t *); |
| 158 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) |
| 159 | |
| 160 | /* This yields a mask that user programs can use to figure out what |
| 161 | instruction set this cpu supports. */ |
| 162 | |
| 163 | #define ELF_HWCAP (0) |
| 164 | |
| 165 | /* This yields a string that ld.so will use to load implementation |
| 166 | specific libraries for optimization. This is more specific in |
| 167 | intent than poking at uname or /proc/cpuinfo. */ |
| 168 | |
| 169 | #define ELF_PLATFORM (NULL) |
| 170 | |
| 171 | #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) |
| 172 | |
| 173 | #endif /* _ASM_UBICOM32_ELF_H */ |
| 174 | |