Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASMi386_ELF_H |
| 2 | #define __ASMi386_ELF_H |
| 3 | |
| 4 | /* |
| 5 | * ELF register definitions.. |
| 6 | */ |
| 7 | |
| 8 | #include <asm/ptrace.h> |
| 9 | #include <asm/user.h> |
H. J. Lu | 36d57ac | 2005-09-06 15:16:49 -0700 | [diff] [blame] | 10 | #include <asm/auxvec.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #define R_386_NONE 0 |
| 13 | #define R_386_32 1 |
| 14 | #define R_386_PC32 2 |
| 15 | #define R_386_GOT32 3 |
| 16 | #define R_386_PLT32 4 |
| 17 | #define R_386_COPY 5 |
| 18 | #define R_386_GLOB_DAT 6 |
| 19 | #define R_386_JMP_SLOT 7 |
| 20 | #define R_386_RELATIVE 8 |
| 21 | #define R_386_GOTOFF 9 |
| 22 | #define R_386_GOTPC 10 |
| 23 | #define R_386_NUM 11 |
| 24 | |
| 25 | typedef unsigned long elf_greg_t; |
| 26 | |
| 27 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) |
| 28 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
| 29 | |
| 30 | typedef struct user_i387_struct elf_fpregset_t; |
| 31 | typedef struct user_fxsr_struct elf_fpxregset_t; |
| 32 | |
| 33 | /* |
| 34 | * This is used to ensure we don't load something for the wrong architecture. |
| 35 | */ |
| 36 | #define elf_check_arch(x) \ |
| 37 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) |
| 38 | |
| 39 | /* |
| 40 | * These are used to set parameters in the core dumps. |
| 41 | */ |
| 42 | #define ELF_CLASS ELFCLASS32 |
| 43 | #define ELF_DATA ELFDATA2LSB |
| 44 | #define ELF_ARCH EM_386 |
| 45 | |
David Woodhouse | 651c923 | 2006-09-12 20:36:04 -0700 | [diff] [blame] | 46 | #ifdef __KERNEL__ |
| 47 | |
| 48 | #include <asm/processor.h> |
| 49 | #include <asm/system.h> /* for savesegment */ |
| 50 | #include <asm/desc.h> |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx |
| 53 | contains a pointer to a function which might be registered using `atexit'. |
| 54 | This provides a mean for the dynamic linker to call DT_FINI functions for |
| 55 | shared libraries that have been loaded before the code runs. |
| 56 | |
| 57 | A value of 0 tells we have no such handler. |
| 58 | |
| 59 | We might as well make sure everything else is cleared too (except for %esp), |
| 60 | just to make things more deterministic. |
| 61 | */ |
| 62 | #define ELF_PLAT_INIT(_r, load_addr) do { \ |
| 63 | _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ |
| 64 | _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ |
| 65 | _r->eax = 0; \ |
| 66 | } while (0) |
| 67 | |
| 68 | #define USE_ELF_CORE_DUMP |
| 69 | #define ELF_EXEC_PAGESIZE 4096 |
| 70 | |
| 71 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
| 72 | use of this is to invoke "./ld.so someprog" to test out a new version of |
| 73 | the loader. We need to make sure that it is out of the way of the program |
| 74 | that it will "exec", and that there is sufficient room for the brk. */ |
| 75 | |
| 76 | #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) |
| 77 | |
| 78 | /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is |
| 79 | now struct_user_regs, they are different) */ |
| 80 | |
| 81 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
| 82 | pr_reg[0] = regs->ebx; \ |
| 83 | pr_reg[1] = regs->ecx; \ |
| 84 | pr_reg[2] = regs->edx; \ |
| 85 | pr_reg[3] = regs->esi; \ |
| 86 | pr_reg[4] = regs->edi; \ |
| 87 | pr_reg[5] = regs->ebp; \ |
| 88 | pr_reg[6] = regs->eax; \ |
Roland McGrath | 6ea65ff | 2007-03-23 14:26:33 -0700 | [diff] [blame] | 89 | pr_reg[7] = regs->xds & 0xffff; \ |
| 90 | pr_reg[8] = regs->xes & 0xffff; \ |
| 91 | pr_reg[9] = regs->xfs & 0xffff; \ |
Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 92 | savesegment(gs,pr_reg[10]); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | pr_reg[11] = regs->orig_eax; \ |
| 94 | pr_reg[12] = regs->eip; \ |
Roland McGrath | 6ea65ff | 2007-03-23 14:26:33 -0700 | [diff] [blame] | 95 | pr_reg[13] = regs->xcs & 0xffff; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | pr_reg[14] = regs->eflags; \ |
| 97 | pr_reg[15] = regs->esp; \ |
Roland McGrath | 6ea65ff | 2007-03-23 14:26:33 -0700 | [diff] [blame] | 98 | pr_reg[16] = regs->xss & 0xffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | /* This yields a mask that user programs can use to figure out what |
| 101 | instruction set this CPU supports. This could be done in user space, |
| 102 | but it's not easy, and we've already done it here. */ |
| 103 | |
| 104 | #define ELF_HWCAP (boot_cpu_data.x86_capability[0]) |
| 105 | |
| 106 | /* This yields a string that ld.so will use to load implementation |
| 107 | specific libraries for optimization. This is more specific in |
| 108 | intent than poking at uname or /proc/cpuinfo. |
| 109 | |
| 110 | For the moment, we have only optimizations for the Intel generations, |
| 111 | but that could change... */ |
| 112 | |
Serge E. Hallyn | e9ff399 | 2006-10-02 02:18:11 -0700 | [diff] [blame] | 113 | #define ELF_PLATFORM (utsname()->machine) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #define SET_PERSONALITY(ex, ibcs2) do { } while (0) |
| 116 | |
| 117 | /* |
| 118 | * An executable for which elf_read_implies_exec() returns TRUE will |
| 119 | * have the READ_IMPLIES_EXEC personality flag set automatically. |
| 120 | */ |
| 121 | #define elf_read_implies_exec(ex, executable_stack) (executable_stack != EXSTACK_DISABLE_X) |
| 122 | |
Tim Schmielau | 8c65b4a | 2005-11-07 00:59:43 -0800 | [diff] [blame] | 123 | struct task_struct; |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | extern int dump_task_regs (struct task_struct *, elf_gregset_t *); |
| 126 | extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); |
| 127 | extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct *); |
| 128 | |
| 129 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) |
| 130 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) |
| 131 | #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) |
| 132 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 133 | #define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) |
Jeremy Fitzhardinge | d4f7a2c | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 134 | #define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) |
| 135 | #define VDSO_PRELINK 0 |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 136 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 137 | #define VDSO_SYM(x) \ |
Jeremy Fitzhardinge | d4f7a2c | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 138 | (VDSO_CURRENT_BASE + (unsigned long)(x) - VDSO_PRELINK) |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 139 | |
| 140 | #define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE) |
Jeremy Fitzhardinge | d4f7a2c | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 141 | #define VDSO_EHDR ((const struct elfhdr *) VDSO_CURRENT_BASE) |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | extern void __kernel_vsyscall; |
| 144 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 145 | #define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall) |
| 146 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 147 | struct linux_binprm; |
Jeremy Fitzhardinge | d4f7a2c | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 148 | |
| 149 | #define ARCH_HAS_SETUP_ADDITIONAL_PAGES |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 150 | extern int arch_setup_additional_pages(struct linux_binprm *bprm, |
| 151 | int executable_stack); |
| 152 | |
| 153 | extern unsigned int vdso_enabled; |
| 154 | |
Jeremy Fitzhardinge | d4f7a2c | 2007-05-02 19:27:12 +0200 | [diff] [blame] | 155 | #define ARCH_DLINFO \ |
| 156 | do if (vdso_enabled) { \ |
| 157 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ |
| 158 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | } while (0) |
| 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | #endif |
| 162 | |
| 163 | #endif |