Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASMPARISC_ELF_H |
| 2 | #define __ASMPARISC_ELF_H |
| 3 | |
| 4 | /* |
| 5 | * ELF register definitions.. |
| 6 | */ |
| 7 | |
| 8 | #include <asm/ptrace.h> |
| 9 | |
| 10 | #define EM_PARISC 15 |
| 11 | |
| 12 | /* HPPA specific definitions. */ |
| 13 | |
| 14 | /* Legal values for e_flags field of Elf32_Ehdr. */ |
| 15 | |
| 16 | #define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ |
| 17 | #define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ |
| 18 | #define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ |
| 19 | #define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ |
| 20 | #define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch |
| 21 | prediction. */ |
| 22 | #define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ |
| 23 | #define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ |
| 24 | |
| 25 | /* Defined values for `e_flags & EF_PARISC_ARCH' are: */ |
| 26 | |
| 27 | #define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ |
| 28 | #define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ |
| 29 | #define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ |
| 30 | |
| 31 | /* Additional section indeces. */ |
| 32 | |
| 33 | #define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared |
| 34 | symbols in ANSI C. */ |
| 35 | #define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ |
| 36 | |
| 37 | /* Legal values for sh_type field of Elf32_Shdr. */ |
| 38 | |
| 39 | #define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ |
| 40 | #define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ |
| 41 | #define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ |
| 42 | |
| 43 | /* Legal values for sh_flags field of Elf32_Shdr. */ |
| 44 | |
| 45 | #define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ |
| 46 | #define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ |
| 47 | #define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ |
| 48 | |
| 49 | /* Legal values for ST_TYPE subfield of st_info (symbol type). */ |
| 50 | |
| 51 | #define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ |
| 52 | |
| 53 | #define STT_HP_OPAQUE (STT_LOOS + 0x1) |
| 54 | #define STT_HP_STUB (STT_LOOS + 0x2) |
| 55 | |
| 56 | /* HPPA relocs. */ |
| 57 | |
| 58 | #define R_PARISC_NONE 0 /* No reloc. */ |
| 59 | #define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ |
| 60 | #define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ |
| 61 | #define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ |
| 62 | #define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ |
| 63 | #define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ |
| 64 | #define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ |
| 65 | #define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ |
| 66 | #define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ |
| 67 | #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ |
| 68 | #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ |
| 69 | #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ |
| 70 | #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ |
| 71 | #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ |
| 72 | #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ |
| 73 | #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ |
| 74 | #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ |
| 75 | #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ |
| 76 | #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ |
| 77 | #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ |
| 78 | #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ |
| 79 | #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ |
| 80 | #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ |
| 81 | #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ |
| 82 | #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ |
| 83 | #define R_PARISC_FPTR64 64 /* 64 bits function address. */ |
| 84 | #define R_PARISC_PLABEL32 65 /* 32 bits function address. */ |
| 85 | #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ |
| 86 | #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ |
| 87 | #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ |
| 88 | #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ |
| 89 | #define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ |
| 90 | #define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ |
| 91 | #define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ |
| 92 | #define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ |
| 93 | #define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ |
| 94 | #define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ |
| 95 | #define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ |
| 96 | #define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ |
| 97 | #define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ |
| 98 | #define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ |
| 99 | #define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ |
| 100 | #define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ |
| 101 | #define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ |
| 102 | #define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ |
| 103 | #define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ |
| 104 | #define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ |
| 105 | #define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ |
| 106 | #define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ |
| 107 | #define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ |
| 108 | #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ |
| 109 | #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ |
| 110 | #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ |
| 111 | #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ |
| 112 | #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ |
| 113 | #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ |
| 114 | #define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ |
| 115 | #define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ |
| 116 | #define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ |
| 117 | #define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ |
| 118 | #define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ |
| 119 | #define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ |
| 120 | #define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ |
| 121 | #define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ |
| 122 | #define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ |
| 123 | #define R_PARISC_LORESERVE 128 |
| 124 | #define R_PARISC_COPY 128 /* Copy relocation. */ |
| 125 | #define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ |
| 126 | #define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ |
| 127 | #define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ |
| 128 | #define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ |
| 129 | #define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ |
| 130 | #define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ |
| 131 | #define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ |
| 132 | #define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ |
| 133 | #define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ |
| 134 | #define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ |
| 135 | #define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ |
| 136 | #define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ |
| 137 | #define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ |
| 138 | #define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ |
| 139 | #define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ |
| 140 | #define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ |
| 141 | #define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ |
| 142 | #define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ |
| 143 | #define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ |
| 144 | #define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ |
| 145 | #define R_PARISC_HIRESERVE 255 |
| 146 | |
| 147 | #define PA_PLABEL_FDESC 0x02 /* bit set if PLABEL points to |
| 148 | * a function descriptor, not |
| 149 | * an address */ |
| 150 | |
| 151 | /* The following are PA function descriptors |
| 152 | * |
| 153 | * addr: the absolute address of the function |
| 154 | * gp: either the data pointer (r27) for non-PIC code or the |
| 155 | * the PLT pointer (r19) for PIC code */ |
| 156 | |
| 157 | /* Format for the Elf32 Function descriptor */ |
| 158 | typedef struct elf32_fdesc { |
| 159 | __u32 addr; |
| 160 | __u32 gp; |
| 161 | } Elf32_Fdesc; |
| 162 | |
| 163 | /* Format for the Elf64 Function descriptor */ |
| 164 | typedef struct elf64_fdesc { |
| 165 | __u64 dummy[2]; /* FIXME: nothing uses these, why waste |
| 166 | * the space */ |
| 167 | __u64 addr; |
| 168 | __u64 gp; |
| 169 | } Elf64_Fdesc; |
| 170 | |
| 171 | /* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ |
| 172 | |
| 173 | #define PT_HP_TLS (PT_LOOS + 0x0) |
| 174 | #define PT_HP_CORE_NONE (PT_LOOS + 0x1) |
| 175 | #define PT_HP_CORE_VERSION (PT_LOOS + 0x2) |
| 176 | #define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) |
| 177 | #define PT_HP_CORE_COMM (PT_LOOS + 0x4) |
| 178 | #define PT_HP_CORE_PROC (PT_LOOS + 0x5) |
| 179 | #define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) |
| 180 | #define PT_HP_CORE_STACK (PT_LOOS + 0x7) |
| 181 | #define PT_HP_CORE_SHM (PT_LOOS + 0x8) |
| 182 | #define PT_HP_CORE_MMF (PT_LOOS + 0x9) |
| 183 | #define PT_HP_PARALLEL (PT_LOOS + 0x10) |
| 184 | #define PT_HP_FASTBIND (PT_LOOS + 0x11) |
| 185 | #define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) |
| 186 | #define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) |
| 187 | #define PT_HP_STACK (PT_LOOS + 0x14) |
| 188 | |
| 189 | #define PT_PARISC_ARCHEXT 0x70000000 |
| 190 | #define PT_PARISC_UNWIND 0x70000001 |
| 191 | |
| 192 | /* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ |
| 193 | |
| 194 | #define PF_PARISC_SBP 0x08000000 |
| 195 | |
| 196 | #define PF_HP_PAGE_SIZE 0x00100000 |
| 197 | #define PF_HP_FAR_SHARED 0x00200000 |
| 198 | #define PF_HP_NEAR_SHARED 0x00400000 |
| 199 | #define PF_HP_CODE 0x01000000 |
| 200 | #define PF_HP_MODIFY 0x02000000 |
| 201 | #define PF_HP_LAZYSWAP 0x04000000 |
| 202 | #define PF_HP_SBP 0x08000000 |
| 203 | |
| 204 | /* |
| 205 | * The following definitions are those for 32-bit ELF binaries on a 32-bit |
| 206 | * kernel and for 64-bit binaries on a 64-bit kernel. To run 32-bit binaries |
| 207 | * on a 64-bit kernel, arch/parisc64/kernel/binfmt_elf32.c defines these |
| 208 | * macros appropriately and then #includes binfmt_elf.c, which then includes |
| 209 | * this file. |
| 210 | */ |
| 211 | #ifndef ELF_CLASS |
| 212 | |
| 213 | /* |
| 214 | * This is used to ensure we don't load something for the wrong architecture. |
| 215 | * |
| 216 | * Note that this header file is used by default in fs/binfmt_elf.c. So |
| 217 | * the following macros are for the default case. However, for the 64 |
| 218 | * bit kernel we also support 32 bit parisc binaries. To do that |
| 219 | * arch/parisc64/kernel/binfmt_elf32.c defines its own set of these |
| 220 | * macros, and then it includes fs/binfmt_elf.c to provide an alternate |
| 221 | * elf binary handler for 32 bit binaries (on the 64 bit kernel). |
| 222 | */ |
Helge Deller | 513e7ec | 2007-01-28 15:09:20 +0100 | [diff] [blame] | 223 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | #define ELF_CLASS ELFCLASS64 |
| 225 | #else |
| 226 | #define ELF_CLASS ELFCLASS32 |
| 227 | #endif |
| 228 | |
| 229 | typedef unsigned long elf_greg_t; |
| 230 | |
| 231 | /* This yields a string that ld.so will use to load implementation |
| 232 | specific libraries for optimization. This is more specific in |
| 233 | intent than poking at uname or /proc/cpuinfo. |
| 234 | |
| 235 | For the moment, we have only optimizations for the Intel generations, |
| 236 | but that could change... */ |
| 237 | |
| 238 | #define ELF_PLATFORM ("PARISC\0" /*+((boot_cpu_data.x86-3)*5) */) |
| 239 | |
| 240 | #ifdef __KERNEL__ |
| 241 | #define SET_PERSONALITY(ex, ibcs2) \ |
| 242 | current->personality = PER_LINUX; \ |
| 243 | current->thread.map_base = DEFAULT_MAP_BASE; \ |
| 244 | current->thread.task_size = DEFAULT_TASK_SIZE \ |
| 245 | |
| 246 | #endif |
| 247 | |
| 248 | /* |
| 249 | * Fill in general registers in a core dump. This saves pretty |
| 250 | * much the same registers as hp-ux, although in a different order. |
| 251 | * Registers marked # below are not currently saved in pt_regs, so |
| 252 | * we use their current values here. |
| 253 | * |
| 254 | * gr0..gr31 |
| 255 | * sr0..sr7 |
| 256 | * iaoq0..iaoq1 |
| 257 | * iasq0..iasq1 |
| 258 | * cr11 (sar) |
| 259 | * cr19 (iir) |
| 260 | * cr20 (isr) |
| 261 | * cr21 (ior) |
| 262 | * # cr22 (ipsw) |
| 263 | * # cr0 (recovery counter) |
| 264 | * # cr24..cr31 (temporary registers) |
| 265 | * # cr8,9,12,13 (protection IDs) |
| 266 | * # cr10 (scr/ccr) |
| 267 | * # cr15 (ext int enable mask) |
| 268 | * |
| 269 | */ |
| 270 | |
| 271 | #define ELF_CORE_COPY_REGS(dst, pt) \ |
| 272 | memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ \ |
| 273 | memcpy(dst + 0, pt->gr, 32 * sizeof(elf_greg_t)); \ |
| 274 | memcpy(dst + 32, pt->sr, 8 * sizeof(elf_greg_t)); \ |
| 275 | memcpy(dst + 40, pt->iaoq, 2 * sizeof(elf_greg_t)); \ |
| 276 | memcpy(dst + 42, pt->iasq, 2 * sizeof(elf_greg_t)); \ |
| 277 | dst[44] = pt->sar; dst[45] = pt->iir; \ |
| 278 | dst[46] = pt->isr; dst[47] = pt->ior; \ |
| 279 | dst[48] = mfctl(22); dst[49] = mfctl(0); \ |
| 280 | dst[50] = mfctl(24); dst[51] = mfctl(25); \ |
| 281 | dst[52] = mfctl(26); dst[53] = mfctl(27); \ |
| 282 | dst[54] = mfctl(28); dst[55] = mfctl(29); \ |
| 283 | dst[56] = mfctl(30); dst[57] = mfctl(31); \ |
| 284 | dst[58] = mfctl( 8); dst[59] = mfctl( 9); \ |
| 285 | dst[60] = mfctl(12); dst[61] = mfctl(13); \ |
| 286 | dst[62] = mfctl(10); dst[63] = mfctl(15); |
| 287 | |
| 288 | #endif /* ! ELF_CLASS */ |
| 289 | |
| 290 | #define ELF_NGREG 80 /* We only need 64 at present, but leave space |
| 291 | for expansion. */ |
| 292 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 293 | |
| 294 | #define ELF_NFPREG 32 |
| 295 | typedef double elf_fpreg_t; |
| 296 | typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; |
| 297 | |
| 298 | struct task_struct; |
| 299 | |
| 300 | extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); |
| 301 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) |
| 302 | |
| 303 | struct pt_regs; /* forward declaration... */ |
| 304 | |
| 305 | |
| 306 | #define elf_check_arch(x) ((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELF_CLASS) |
| 307 | |
| 308 | /* |
| 309 | * These are used to set parameters in the core dumps. |
| 310 | */ |
| 311 | #define ELF_DATA ELFDATA2MSB |
| 312 | #define ELF_ARCH EM_PARISC |
| 313 | #define ELF_OSABI ELFOSABI_LINUX |
| 314 | |
| 315 | /* %r23 is set by ld.so to a pointer to a function which might be |
| 316 | registered using atexit. This provides a mean for the dynamic |
| 317 | linker to call DT_FINI functions for shared libraries that have |
| 318 | been loaded before the code runs. |
| 319 | |
| 320 | So that we can use the same startup file with static executables, |
| 321 | we start programs with a value of 0 to indicate that there is no |
| 322 | such function. */ |
| 323 | #define ELF_PLAT_INIT(_r, load_addr) _r->gr[23] = 0 |
| 324 | |
| 325 | #define USE_ELF_CORE_DUMP |
| 326 | #define ELF_EXEC_PAGESIZE 4096 |
| 327 | |
| 328 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 329 | use of this is to invoke "./ld.so someprog" to test out a new version of |
| 330 | the loader. We need to make sure that it is out of the way of the program |
| 331 | that it will "exec", and that there is sufficient room for the brk. |
| 332 | |
| 333 | (2 * TASK_SIZE / 3) turns into something undefined when run through a |
| 334 | 32 bit preprocessor and in some cases results in the kernel trying to map |
| 335 | ld.so to the kernel virtual base. Use a sane value instead. /Jes |
| 336 | */ |
| 337 | |
| 338 | #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000) |
| 339 | |
| 340 | /* This yields a mask that user programs can use to figure out what |
| 341 | instruction set this CPU supports. This could be done in user space, |
| 342 | but it's not easy, and we've already done it here. */ |
| 343 | |
| 344 | #define ELF_HWCAP 0 |
| 345 | /* (boot_cpu_data.x86_capability) */ |
| 346 | |
| 347 | #endif |