Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 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> |
||
10 | #include <asm/processor.h> |
||
11 | #include <asm/system.h> /* for savesegment */ |
||
12 | |||
13 | #include <linux/utsname.h> |
||
14 | |||
15 | #define R_386_NONE 0 |
||
16 | #define R_386_32 1 |
||
17 | #define R_386_PC32 2 |
||
18 | #define R_386_GOT32 3 |
||
19 | #define R_386_PLT32 4 |
||
20 | #define R_386_COPY 5 |
||
21 | #define R_386_GLOB_DAT 6 |
||
22 | #define R_386_JMP_SLOT 7 |
||
23 | #define R_386_RELATIVE 8 |
||
24 | #define R_386_GOTOFF 9 |
||
25 | #define R_386_GOTPC 10 |
||
26 | #define R_386_NUM 11 |
||
27 | |||
28 | typedef unsigned long elf_greg_t; |
||
29 | |||
30 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) |
||
31 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
||
32 | |||
33 | typedef struct user_i387_struct elf_fpregset_t; |
||
34 | typedef struct user_fxsr_struct elf_fpxregset_t; |
||
35 | |||
36 | /* |
||
37 | * This is used to ensure we don't load something for the wrong architecture. |
||
38 | */ |
||
39 | #define elf_check_arch(x) \ |
||
40 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) |
||
41 | |||
42 | /* |
||
43 | * These are used to set parameters in the core dumps. |
||
44 | */ |
||
45 | #define ELF_CLASS ELFCLASS32 |
||
46 | #define ELF_DATA ELFDATA2LSB |
||
47 | #define ELF_ARCH EM_386 |
||
48 | |||
49 | /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx |
||
50 | contains a pointer to a function which might be registered using `atexit'. |
||
51 | This provides a mean for the dynamic linker to call DT_FINI functions for |
||
52 | shared libraries that have been loaded before the code runs. |
||
53 | |||
54 | A value of 0 tells we have no such handler. |
||
55 | |||
56 | We might as well make sure everything else is cleared too (except for %esp), |
||
57 | just to make things more deterministic. |
||
58 | */ |
||
59 | #define ELF_PLAT_INIT(_r, load_addr) do { \ |
||
60 | _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ |
||
61 | _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ |
||
62 | _r->eax = 0; \ |
||
63 | } while (0) |
||
64 | |||
65 | #define USE_ELF_CORE_DUMP |
||
66 | #define ELF_EXEC_PAGESIZE 4096 |
||
67 | |||
68 | /* This is the location that an ET_DYN program is loaded if exec'ed. Typical |
||
69 | use of this is to invoke "./ld.so someprog" to test out a new version of |
||
70 | the loader. We need to make sure that it is out of the way of the program |
||
71 | that it will "exec", and that there is sufficient room for the brk. */ |
||
72 | |||
73 | #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2) |
||
74 | |||
75 | /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is |
||
76 | now struct_user_regs, they are different) */ |
||
77 | |||
78 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
||
79 | pr_reg[0] = regs->ebx; \ |
||
80 | pr_reg[1] = regs->ecx; \ |
||
81 | pr_reg[2] = regs->edx; \ |
||
82 | pr_reg[3] = regs->esi; \ |
||
83 | pr_reg[4] = regs->edi; \ |
||
84 | pr_reg[5] = regs->ebp; \ |
||
85 | pr_reg[6] = regs->eax; \ |
||
86 | pr_reg[7] = regs->xds; \ |
||
87 | pr_reg[8] = regs->xes; \ |
||
88 | savesegment(fs,pr_reg[9]); \ |
||
89 | savesegment(gs,pr_reg[10]); \ |
||
90 | pr_reg[11] = regs->orig_eax; \ |
||
91 | pr_reg[12] = regs->eip; \ |
||
92 | pr_reg[13] = regs->xcs; \ |
||
93 | pr_reg[14] = regs->eflags; \ |
||
94 | pr_reg[15] = regs->esp; \ |
||
95 | pr_reg[16] = regs->xss; |
||
96 | |||
97 | /* This yields a mask that user programs can use to figure out what |
||
98 | instruction set this CPU supports. This could be done in user space, |
||
99 | but it's not easy, and we've already done it here. */ |
||
100 | |||
101 | #define ELF_HWCAP (boot_cpu_data.x86_capability[0]) |
||
102 | |||
103 | /* This yields a string that ld.so will use to load implementation |
||
104 | specific libraries for optimization. This is more specific in |
||
105 | intent than poking at uname or /proc/cpuinfo. |
||
106 | |||
107 | For the moment, we have only optimizations for the Intel generations, |
||
108 | but that could change... */ |
||
109 | |||
110 | #define ELF_PLATFORM (system_utsname.machine) |
||
111 | |||
112 | /* |
||
113 | * Architecture-neutral AT_ values in 0-17, leave some room |
||
114 | * for more of them, start the x86-specific ones at 32. |
||
115 | */ |
||
116 | #define AT_SYSINFO 32 |
||
117 | #define AT_SYSINFO_EHDR 33 |
||
118 | |||
119 | #ifdef __KERNEL__ |
||
120 | #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) |
||
121 | |||
122 | extern int dump_task_regs (struct task_struct *, elf_gregset_t *); |
||
123 | extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); |
||
124 | extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct *); |
||
125 | |||
126 | #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) |
||
127 | #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) |
||
128 | #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs) |
||
129 | |||
130 | #define VSYSCALL_BASE (__fix_to_virt(FIX_VSYSCALL)) |
||
131 | #define VSYSCALL_EHDR ((const struct elfhdr *) VSYSCALL_BASE) |
||
132 | #define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall) |
||
133 | extern void __kernel_vsyscall; |
||
134 | |||
135 | #define ARCH_DLINFO \ |
||
136 | do { \ |
||
137 | NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY); \ |
||
138 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE); \ |
||
139 | } while (0) |
||
140 | |||
141 | /* |
||
142 | * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out |
||
143 | * extra segments containing the vsyscall DSO contents. Dumping its |
||
144 | * contents makes post-mortem fully interpretable later without matching up |
||
145 | * the same kernel and hardware config to see what PC values meant. |
||
146 | * Dumping its extra ELF program headers includes all the other information |
||
147 | * a debugger needs to easily find how the vsyscall DSO was being used. |
||
148 | */ |
||
149 | #define ELF_CORE_EXTRA_PHDRS (VSYSCALL_EHDR->e_phnum) |
||
150 | #define ELF_CORE_WRITE_EXTRA_PHDRS \ |
||
151 | do { \ |
||
152 | const struct elf_phdr *const vsyscall_phdrs = \ |
||
153 | (const struct elf_phdr *) (VSYSCALL_BASE \ |
||
154 | + VSYSCALL_EHDR->e_phoff); \ |
||
155 | int i; \ |
||
156 | Elf32_Off ofs = 0; \ |
||
157 | for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \ |
||
158 | struct elf_phdr phdr = vsyscall_phdrs[i]; \ |
||
159 | if (phdr.p_type == PT_LOAD) { \ |
||
160 | BUG_ON(ofs != 0); \ |
||
161 | ofs = phdr.p_offset = offset; \ |
||
162 | phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz); \ |
||
163 | phdr.p_filesz = phdr.p_memsz; \ |
||
164 | offset += phdr.p_filesz; \ |
||
165 | } \ |
||
166 | else \ |
||
167 | phdr.p_offset += ofs; \ |
||
168 | phdr.p_paddr = 0; /* match other core phdrs */ \ |
||
169 | DUMP_WRITE(&phdr, sizeof(phdr)); \ |
||
170 | } \ |
||
171 | } while (0) |
||
172 | #define ELF_CORE_WRITE_EXTRA_DATA \ |
||
173 | do { \ |
||
174 | const struct elf_phdr *const vsyscall_phdrs = \ |
||
175 | (const struct elf_phdr *) (VSYSCALL_BASE \ |
||
176 | + VSYSCALL_EHDR->e_phoff); \ |
||
177 | int i; \ |
||
178 | for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) { \ |
||
179 | if (vsyscall_phdrs[i].p_type == PT_LOAD) \ |
||
180 | DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr, \ |
||
181 | PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \ |
||
182 | } \ |
||
183 | } while (0) |
||
184 | |||
185 | #endif |
||
186 | |||
187 | #endif |