1 /* 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 3 * Licensed under the GPL 4 */ 5 #ifndef __UM_ELF_X86_H 6 #define __UM_ELF_X86_H 7 8 #include <asm/user.h> 9 #include <skas.h> 10 11 #ifdef CONFIG_X86_32 12 13 #define R_386_NONE 0 14 #define R_386_32 1 15 #define R_386_PC32 2 16 #define R_386_GOT32 3 17 #define R_386_PLT32 4 18 #define R_386_COPY 5 19 #define R_386_GLOB_DAT 6 20 #define R_386_JMP_SLOT 7 21 #define R_386_RELATIVE 8 22 #define R_386_GOTOFF 9 23 #define R_386_GOTPC 10 24 #define R_386_NUM 11 25 26 /* 27 * This is used to ensure we don't load something for the wrong architecture. 28 */ 29 #define elf_check_arch(x) \ 30 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) 31 32 #define ELF_CLASS ELFCLASS32 33 #define ELF_DATA ELFDATA2LSB 34 #define ELF_ARCH EM_386 35 36 #define ELF_PLAT_INIT(regs, load_addr) do { \ 37 PT_REGS_BX(regs) = 0; \ 38 PT_REGS_CX(regs) = 0; \ 39 PT_REGS_DX(regs) = 0; \ 40 PT_REGS_SI(regs) = 0; \ 41 PT_REGS_DI(regs) = 0; \ 42 PT_REGS_BP(regs) = 0; \ 43 PT_REGS_AX(regs) = 0; \ 44 } while (0) 45 46 /* Shamelessly stolen from include/asm-i386/elf.h */ 47 48 #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 49 pr_reg[0] = PT_REGS_BX(regs); \ 50 pr_reg[1] = PT_REGS_CX(regs); \ 51 pr_reg[2] = PT_REGS_DX(regs); \ 52 pr_reg[3] = PT_REGS_SI(regs); \ 53 pr_reg[4] = PT_REGS_DI(regs); \ 54 pr_reg[5] = PT_REGS_BP(regs); \ 55 pr_reg[6] = PT_REGS_AX(regs); \ 56 pr_reg[7] = PT_REGS_DS(regs); \ 57 pr_reg[8] = PT_REGS_ES(regs); \ 58 /* fake once used fs and gs selectors? */ \ 59 pr_reg[9] = PT_REGS_DS(regs); \ 60 pr_reg[10] = PT_REGS_DS(regs); \ 61 pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \ 62 pr_reg[12] = PT_REGS_IP(regs); \ 63 pr_reg[13] = PT_REGS_CS(regs); \ 64 pr_reg[14] = PT_REGS_EFLAGS(regs); \ 65 pr_reg[15] = PT_REGS_SP(regs); \ 66 pr_reg[16] = PT_REGS_SS(regs); \ 67 } while (0); 68 69 extern char * elf_aux_platform; 70 #define ELF_PLATFORM (elf_aux_platform) 71 72 extern unsigned long vsyscall_ehdr; 73 extern unsigned long vsyscall_end; 74 extern unsigned long __kernel_vsyscall; 75 76 /* 77 * This is the range that is readable by user mode, and things 78 * acting like user mode such as get_user_pages. 79 */ 80 #define FIXADDR_USER_START vsyscall_ehdr 81 #define FIXADDR_USER_END vsyscall_end 82 83 84 /* 85 * Architecture-neutral AT_ values in 0-17, leave some room 86 * for more of them, start the x86-specific ones at 32. 87 */ 88 #define AT_SYSINFO 32 89 #define AT_SYSINFO_EHDR 33 90 91 #define ARCH_DLINFO \ 92 do { \ 93 if ( vsyscall_ehdr ) { \ 94 NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \ 95 NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \ 96 } \ 97 } while (0) 98 99 #else 100 101 /* x86-64 relocation types, taken from asm-x86_64/elf.h */ 102 #define R_X86_64_NONE 0 /* No reloc */ 103 #define R_X86_64_64 1 /* Direct 64 bit */ 104 #define R_X86_64_PC32 2 /* PC relative 32 bit signed */ 105 #define R_X86_64_GOT32 3 /* 32 bit GOT entry */ 106 #define R_X86_64_PLT32 4 /* 32 bit PLT address */ 107 #define R_X86_64_COPY 5 /* Copy symbol at runtime */ 108 #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ 109 #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ 110 #define R_X86_64_RELATIVE 8 /* Adjust by program base */ 111 #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative 112 offset to GOT */ 113 #define R_X86_64_32 10 /* Direct 32 bit zero extended */ 114 #define R_X86_64_32S 11 /* Direct 32 bit sign extended */ 115 #define R_X86_64_16 12 /* Direct 16 bit zero extended */ 116 #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ 117 #define R_X86_64_8 14 /* Direct 8 bit sign extended */ 118 #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ 119 120 #define R_X86_64_NUM 16 121 122 /* 123 * This is used to ensure we don't load something for the wrong architecture. 124 */ 125 #define elf_check_arch(x) \ 126 ((x)->e_machine == EM_X86_64) 127 128 #define ELF_CLASS ELFCLASS64 129 #define ELF_DATA ELFDATA2LSB 130 #define ELF_ARCH EM_X86_64 131 132 #define ELF_PLAT_INIT(regs, load_addr) do { \ 133 PT_REGS_BX(regs) = 0; \ 134 PT_REGS_CX(regs) = 0; \ 135 PT_REGS_DX(regs) = 0; \ 136 PT_REGS_SI(regs) = 0; \ 137 PT_REGS_DI(regs) = 0; \ 138 PT_REGS_BP(regs) = 0; \ 139 PT_REGS_AX(regs) = 0; \ 140 PT_REGS_R8(regs) = 0; \ 141 PT_REGS_R9(regs) = 0; \ 142 PT_REGS_R10(regs) = 0; \ 143 PT_REGS_R11(regs) = 0; \ 144 PT_REGS_R12(regs) = 0; \ 145 PT_REGS_R13(regs) = 0; \ 146 PT_REGS_R14(regs) = 0; \ 147 PT_REGS_R15(regs) = 0; \ 148 } while (0) 149 150 #define ELF_CORE_COPY_REGS(pr_reg, _regs) \ 151 (pr_reg)[0] = (_regs)->regs.gp[0]; \ 152 (pr_reg)[1] = (_regs)->regs.gp[1]; \ 153 (pr_reg)[2] = (_regs)->regs.gp[2]; \ 154 (pr_reg)[3] = (_regs)->regs.gp[3]; \ 155 (pr_reg)[4] = (_regs)->regs.gp[4]; \ 156 (pr_reg)[5] = (_regs)->regs.gp[5]; \ 157 (pr_reg)[6] = (_regs)->regs.gp[6]; \ 158 (pr_reg)[7] = (_regs)->regs.gp[7]; \ 159 (pr_reg)[8] = (_regs)->regs.gp[8]; \ 160 (pr_reg)[9] = (_regs)->regs.gp[9]; \ 161 (pr_reg)[10] = (_regs)->regs.gp[10]; \ 162 (pr_reg)[11] = (_regs)->regs.gp[11]; \ 163 (pr_reg)[12] = (_regs)->regs.gp[12]; \ 164 (pr_reg)[13] = (_regs)->regs.gp[13]; \ 165 (pr_reg)[14] = (_regs)->regs.gp[14]; \ 166 (pr_reg)[15] = (_regs)->regs.gp[15]; \ 167 (pr_reg)[16] = (_regs)->regs.gp[16]; \ 168 (pr_reg)[17] = (_regs)->regs.gp[17]; \ 169 (pr_reg)[18] = (_regs)->regs.gp[18]; \ 170 (pr_reg)[19] = (_regs)->regs.gp[19]; \ 171 (pr_reg)[20] = (_regs)->regs.gp[20]; \ 172 (pr_reg)[21] = current->thread.arch.fs; \ 173 (pr_reg)[22] = 0; \ 174 (pr_reg)[23] = 0; \ 175 (pr_reg)[24] = 0; \ 176 (pr_reg)[25] = 0; \ 177 (pr_reg)[26] = 0; 178 179 #define ELF_PLATFORM "x86_64" 180 181 /* No user-accessible fixmap addresses, i.e. vsyscall */ 182 #define FIXADDR_USER_START 0 183 #define FIXADDR_USER_END 0 184 185 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 186 struct linux_binprm; 187 extern int arch_setup_additional_pages(struct linux_binprm *bprm, 188 int uses_interp); 189 190 extern unsigned long um_vdso_addr; 191 #define AT_SYSINFO_EHDR 33 192 #define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr) 193 194 #endif 195 196 typedef unsigned long elf_greg_t; 197 198 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) 199 typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 200 201 typedef struct user_i387_struct elf_fpregset_t; 202 203 #define task_pt_regs(t) (&(t)->thread.regs) 204 205 struct task_struct; 206 207 extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu); 208 209 #define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu) 210 211 #define ELF_EXEC_PAGESIZE 4096 212 213 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) 214 215 extern long elf_aux_hwcap; 216 #define ELF_HWCAP (elf_aux_hwcap) 217 218 #define SET_PERSONALITY(ex) do ; while(0) 219 220 #endif 221