Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2003 PathScale, Inc. |
Jeff Dike | f0c4cad | 2007-10-16 01:27:18 -0700 | [diff] [blame] | 3 | * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the GPL |
| 6 | */ |
| 7 | #ifndef __UM_ELF_X86_64_H |
| 8 | #define __UM_ELF_X86_64_H |
| 9 | |
Jeff Dike | d1254b1 | 2007-08-30 23:56:20 -0700 | [diff] [blame] | 10 | #include <linux/sched.h> |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 11 | #include <asm/user.h> |
Jeff Dike | d1254b1 | 2007-08-30 23:56:20 -0700 | [diff] [blame] | 12 | #include "skas.h" |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 13 | |
Jeff Dike | ba9950c | 2005-05-20 13:59:07 -0700 | [diff] [blame] | 14 | /* x86-64 relocation types, taken from asm-x86_64/elf.h */ |
| 15 | #define R_X86_64_NONE 0 /* No reloc */ |
| 16 | #define R_X86_64_64 1 /* Direct 64 bit */ |
| 17 | #define R_X86_64_PC32 2 /* PC relative 32 bit signed */ |
| 18 | #define R_X86_64_GOT32 3 /* 32 bit GOT entry */ |
| 19 | #define R_X86_64_PLT32 4 /* 32 bit PLT address */ |
| 20 | #define R_X86_64_COPY 5 /* Copy symbol at runtime */ |
| 21 | #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ |
| 22 | #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ |
| 23 | #define R_X86_64_RELATIVE 8 /* Adjust by program base */ |
| 24 | #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative |
| 25 | offset to GOT */ |
| 26 | #define R_X86_64_32 10 /* Direct 32 bit zero extended */ |
| 27 | #define R_X86_64_32S 11 /* Direct 32 bit sign extended */ |
| 28 | #define R_X86_64_16 12 /* Direct 16 bit zero extended */ |
| 29 | #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ |
| 30 | #define R_X86_64_8 14 /* Direct 8 bit sign extended */ |
| 31 | #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ |
| 32 | |
| 33 | #define R_X86_64_NUM 16 |
| 34 | |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 35 | typedef unsigned long elf_greg_t; |
| 36 | |
| 37 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) |
| 38 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 39 | |
Jeff Dike | 058ac30 | 2007-10-16 01:27:17 -0700 | [diff] [blame] | 40 | typedef struct user_i387_struct elf_fpregset_t; |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * This is used to ensure we don't load something for the wrong architecture. |
| 44 | */ |
| 45 | #define elf_check_arch(x) \ |
| 46 | ((x)->e_machine == EM_X86_64) |
| 47 | |
| 48 | #define ELF_CLASS ELFCLASS64 |
| 49 | #define ELF_DATA ELFDATA2LSB |
| 50 | #define ELF_ARCH EM_X86_64 |
| 51 | |
| 52 | #define ELF_PLAT_INIT(regs, load_addr) do { \ |
| 53 | PT_REGS_RBX(regs) = 0; \ |
| 54 | PT_REGS_RCX(regs) = 0; \ |
| 55 | PT_REGS_RDX(regs) = 0; \ |
| 56 | PT_REGS_RSI(regs) = 0; \ |
| 57 | PT_REGS_RDI(regs) = 0; \ |
| 58 | PT_REGS_RBP(regs) = 0; \ |
| 59 | PT_REGS_RAX(regs) = 0; \ |
| 60 | PT_REGS_R8(regs) = 0; \ |
| 61 | PT_REGS_R9(regs) = 0; \ |
| 62 | PT_REGS_R10(regs) = 0; \ |
| 63 | PT_REGS_R11(regs) = 0; \ |
| 64 | PT_REGS_R12(regs) = 0; \ |
| 65 | PT_REGS_R13(regs) = 0; \ |
| 66 | PT_REGS_R14(regs) = 0; \ |
| 67 | PT_REGS_R15(regs) = 0; \ |
| 68 | } while (0) |
| 69 | |
Jeff Dike | d1254b1 | 2007-08-30 23:56:20 -0700 | [diff] [blame] | 70 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
Jeff Dike | 18baddd | 2007-10-16 01:27:07 -0700 | [diff] [blame] | 71 | (pr_reg)[0] = (regs)->regs.gp[0]; \ |
| 72 | (pr_reg)[1] = (regs)->regs.gp[1]; \ |
| 73 | (pr_reg)[2] = (regs)->regs.gp[2]; \ |
| 74 | (pr_reg)[3] = (regs)->regs.gp[3]; \ |
| 75 | (pr_reg)[4] = (regs)->regs.gp[4]; \ |
| 76 | (pr_reg)[5] = (regs)->regs.gp[5]; \ |
| 77 | (pr_reg)[6] = (regs)->regs.gp[6]; \ |
| 78 | (pr_reg)[7] = (regs)->regs.gp[7]; \ |
| 79 | (pr_reg)[8] = (regs)->regs.gp[8]; \ |
| 80 | (pr_reg)[9] = (regs)->regs.gp[9]; \ |
| 81 | (pr_reg)[10] = (regs)->regs.gp[10]; \ |
| 82 | (pr_reg)[11] = (regs)->regs.gp[11]; \ |
| 83 | (pr_reg)[12] = (regs)->regs.gp[12]; \ |
| 84 | (pr_reg)[13] = (regs)->regs.gp[13]; \ |
| 85 | (pr_reg)[14] = (regs)->regs.gp[14]; \ |
| 86 | (pr_reg)[15] = (regs)->regs.gp[15]; \ |
| 87 | (pr_reg)[16] = (regs)->regs.gp[16]; \ |
| 88 | (pr_reg)[17] = (regs)->regs.gp[17]; \ |
| 89 | (pr_reg)[18] = (regs)->regs.gp[18]; \ |
| 90 | (pr_reg)[19] = (regs)->regs.gp[19]; \ |
| 91 | (pr_reg)[20] = (regs)->regs.gp[20]; \ |
Jeff Dike | d1254b1 | 2007-08-30 23:56:20 -0700 | [diff] [blame] | 92 | (pr_reg)[21] = current->thread.arch.fs; \ |
| 93 | (pr_reg)[22] = 0; \ |
| 94 | (pr_reg)[23] = 0; \ |
| 95 | (pr_reg)[24] = 0; \ |
| 96 | (pr_reg)[25] = 0; \ |
| 97 | (pr_reg)[26] = 0; |
| 98 | |
| 99 | static inline int elf_core_copy_fpregs(struct task_struct *t, |
| 100 | elf_fpregset_t *fpu) |
| 101 | { |
| 102 | int cpu = current_thread->cpu; |
| 103 | return save_fp_registers(userspace_pid[cpu], (unsigned long *) fpu); |
| 104 | } |
| 105 | |
| 106 | #define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu) |
| 107 | |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 108 | #ifdef TIF_IA32 /* XXX */ |
Jeff Dike | ba9950c | 2005-05-20 13:59:07 -0700 | [diff] [blame] | 109 | #error XXX, indeed |
| 110 | clear_thread_flag(TIF_IA32); |
Bodo Stroesser | dbc35cc7 | 2005-05-05 16:15:35 -0700 | [diff] [blame] | 111 | #endif |
| 112 | |
| 113 | #define USE_ELF_CORE_DUMP |
| 114 | #define ELF_EXEC_PAGESIZE 4096 |
| 115 | |
| 116 | #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) |
| 117 | |
| 118 | extern long elf_aux_hwcap; |
| 119 | #define ELF_HWCAP (elf_aux_hwcap) |
| 120 | |
| 121 | #define ELF_PLATFORM "x86_64" |
| 122 | |
| 123 | #define SET_PERSONALITY(ex, ibcs2) do ; while(0) |
| 124 | |
| 125 | #endif |