diff options
Diffstat (limited to 'include/asm-x86/elf.h')
-rw-r--r-- | include/asm-x86/elf.h | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h index fb62f9941e38..8f232dc5b5fe 100644 --- a/include/asm-x86/elf.h +++ b/include/asm-x86/elf.h | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | typedef unsigned long elf_greg_t; | 12 | typedef unsigned long elf_greg_t; |
13 | 13 | ||
14 | #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t)) | 14 | #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t)) |
15 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | 15 | typedef elf_greg_t elf_gregset_t[ELF_NGREG]; |
16 | 16 | ||
17 | typedef struct user_i387_struct elf_fpregset_t; | 17 | typedef struct user_i387_struct elf_fpregset_t; |
@@ -82,8 +82,9 @@ extern unsigned int vdso_enabled; | |||
82 | #define elf_check_arch_ia32(x) \ | 82 | #define elf_check_arch_ia32(x) \ |
83 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) | 83 | (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) |
84 | 84 | ||
85 | #ifdef CONFIG_X86_32 | ||
86 | #include <asm/processor.h> | 85 | #include <asm/processor.h> |
86 | |||
87 | #ifdef CONFIG_X86_32 | ||
87 | #include <asm/system.h> /* for savesegment */ | 88 | #include <asm/system.h> /* for savesegment */ |
88 | #include <asm/desc.h> | 89 | #include <asm/desc.h> |
89 | 90 | ||
@@ -99,10 +100,11 @@ extern unsigned int vdso_enabled; | |||
99 | We might as well make sure everything else is cleared too (except for %esp), | 100 | We might as well make sure everything else is cleared too (except for %esp), |
100 | just to make things more deterministic. | 101 | just to make things more deterministic. |
101 | */ | 102 | */ |
102 | #define ELF_PLAT_INIT(_r, load_addr) do { \ | 103 | #define ELF_PLAT_INIT(_r, load_addr) \ |
103 | _r->bx = 0; _r->cx = 0; _r->dx = 0; \ | 104 | do { \ |
104 | _r->si = 0; _r->di = 0; _r->bp = 0; \ | 105 | _r->bx = 0; _r->cx = 0; _r->dx = 0; \ |
105 | _r->ax = 0; \ | 106 | _r->si = 0; _r->di = 0; _r->bp = 0; \ |
107 | _r->ax = 0; \ | ||
106 | } while (0) | 108 | } while (0) |
107 | 109 | ||
108 | /* | 110 | /* |
@@ -110,24 +112,25 @@ extern unsigned int vdso_enabled; | |||
110 | * now struct_user_regs, they are different) | 112 | * now struct_user_regs, they are different) |
111 | */ | 113 | */ |
112 | 114 | ||
113 | #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ | 115 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
114 | pr_reg[0] = regs->bx; \ | 116 | do { \ |
115 | pr_reg[1] = regs->cx; \ | 117 | pr_reg[0] = regs->bx; \ |
116 | pr_reg[2] = regs->dx; \ | 118 | pr_reg[1] = regs->cx; \ |
117 | pr_reg[3] = regs->si; \ | 119 | pr_reg[2] = regs->dx; \ |
118 | pr_reg[4] = regs->di; \ | 120 | pr_reg[3] = regs->si; \ |
119 | pr_reg[5] = regs->bp; \ | 121 | pr_reg[4] = regs->di; \ |
120 | pr_reg[6] = regs->ax; \ | 122 | pr_reg[5] = regs->bp; \ |
121 | pr_reg[7] = regs->ds & 0xffff; \ | 123 | pr_reg[6] = regs->ax; \ |
122 | pr_reg[8] = regs->es & 0xffff; \ | 124 | pr_reg[7] = regs->ds & 0xffff; \ |
123 | pr_reg[9] = regs->fs & 0xffff; \ | 125 | pr_reg[8] = regs->es & 0xffff; \ |
124 | savesegment(gs, pr_reg[10]); \ | 126 | pr_reg[9] = regs->fs & 0xffff; \ |
125 | pr_reg[11] = regs->orig_ax; \ | 127 | savesegment(gs, pr_reg[10]); \ |
126 | pr_reg[12] = regs->ip; \ | 128 | pr_reg[11] = regs->orig_ax; \ |
127 | pr_reg[13] = regs->cs & 0xffff; \ | 129 | pr_reg[12] = regs->ip; \ |
128 | pr_reg[14] = regs->flags; \ | 130 | pr_reg[13] = regs->cs & 0xffff; \ |
129 | pr_reg[15] = regs->sp; \ | 131 | pr_reg[14] = regs->flags; \ |
130 | pr_reg[16] = regs->ss & 0xffff; \ | 132 | pr_reg[15] = regs->sp; \ |
133 | pr_reg[16] = regs->ss & 0xffff; \ | ||
131 | } while (0); | 134 | } while (0); |
132 | 135 | ||
133 | #define ELF_PLATFORM (utsname()->machine) | 136 | #define ELF_PLATFORM (utsname()->machine) |
@@ -135,12 +138,10 @@ extern unsigned int vdso_enabled; | |||
135 | 138 | ||
136 | #else /* CONFIG_X86_32 */ | 139 | #else /* CONFIG_X86_32 */ |
137 | 140 | ||
138 | #include <asm/processor.h> | ||
139 | |||
140 | /* | 141 | /* |
141 | * This is used to ensure we don't load something for the wrong architecture. | 142 | * This is used to ensure we don't load something for the wrong architecture. |
142 | */ | 143 | */ |
143 | #define elf_check_arch(x) \ | 144 | #define elf_check_arch(x) \ |
144 | ((x)->e_machine == EM_X86_64) | 145 | ((x)->e_machine == EM_X86_64) |
145 | 146 | ||
146 | #define compat_elf_check_arch(x) elf_check_arch_ia32(x) | 147 | #define compat_elf_check_arch(x) elf_check_arch_ia32(x) |
@@ -169,24 +170,30 @@ static inline void elf_common_init(struct thread_struct *t, | |||
169 | t->ds = t->es = ds; | 170 | t->ds = t->es = ds; |
170 | } | 171 | } |
171 | 172 | ||
172 | #define ELF_PLAT_INIT(_r, load_addr) do { \ | 173 | #define ELF_PLAT_INIT(_r, load_addr) \ |
173 | elf_common_init(¤t->thread, _r, 0); \ | 174 | do { \ |
174 | clear_thread_flag(TIF_IA32); \ | 175 | elf_common_init(¤t->thread, _r, 0); \ |
176 | clear_thread_flag(TIF_IA32); \ | ||
175 | } while (0) | 177 | } while (0) |
176 | 178 | ||
177 | #define COMPAT_ELF_PLAT_INIT(regs, load_addr) \ | 179 | #define COMPAT_ELF_PLAT_INIT(regs, load_addr) \ |
178 | elf_common_init(¤t->thread, regs, __USER_DS) | 180 | elf_common_init(¤t->thread, regs, __USER_DS) |
179 | #define compat_start_thread(regs, ip, sp) do { \ | 181 | |
180 | start_ia32_thread(regs, ip, sp); \ | 182 | #define compat_start_thread(regs, ip, sp) \ |
181 | set_fs(USER_DS); \ | 183 | do { \ |
182 | } while (0) | 184 | start_ia32_thread(regs, ip, sp); \ |
183 | #define COMPAT_SET_PERSONALITY(ex, ibcs2) do { \ | 185 | set_fs(USER_DS); \ |
184 | if (test_thread_flag(TIF_IA32)) \ | 186 | } while (0) |
185 | clear_thread_flag(TIF_ABI_PENDING); \ | 187 | |
186 | else \ | 188 | #define COMPAT_SET_PERSONALITY(ex, ibcs2) \ |
187 | set_thread_flag(TIF_ABI_PENDING); \ | 189 | do { \ |
188 | current->personality |= force_personality32; \ | 190 | if (test_thread_flag(TIF_IA32)) \ |
189 | } while (0) | 191 | clear_thread_flag(TIF_ABI_PENDING); \ |
192 | else \ | ||
193 | set_thread_flag(TIF_ABI_PENDING); \ | ||
194 | current->personality |= force_personality32; \ | ||
195 | } while (0) | ||
196 | |||
190 | #define COMPAT_ELF_PLATFORM ("i686") | 197 | #define COMPAT_ELF_PLATFORM ("i686") |
191 | 198 | ||
192 | /* | 199 | /* |
@@ -195,7 +202,8 @@ static inline void elf_common_init(struct thread_struct *t, | |||
195 | * getting dumped. | 202 | * getting dumped. |
196 | */ | 203 | */ |
197 | 204 | ||
198 | #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ | 205 | #define ELF_CORE_COPY_REGS(pr_reg, regs) \ |
206 | do { \ | ||
199 | unsigned v; \ | 207 | unsigned v; \ |
200 | (pr_reg)[0] = (regs)->r15; \ | 208 | (pr_reg)[0] = (regs)->r15; \ |
201 | (pr_reg)[1] = (regs)->r14; \ | 209 | (pr_reg)[1] = (regs)->r14; \ |
@@ -269,10 +277,12 @@ extern int force_personality32; | |||
269 | 277 | ||
270 | struct task_struct; | 278 | struct task_struct; |
271 | 279 | ||
272 | #define ARCH_DLINFO_IA32(vdso_enabled) \ | 280 | #define ARCH_DLINFO_IA32(vdso_enabled) \ |
273 | do if (vdso_enabled) { \ | 281 | do { \ |
282 | if (vdso_enabled) { \ | ||
274 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ | 283 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ |
275 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ | 284 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ |
285 | } \ | ||
276 | } while (0) | 286 | } while (0) |
277 | 287 | ||
278 | #ifdef CONFIG_X86_32 | 288 | #ifdef CONFIG_X86_32 |
@@ -290,9 +300,11 @@ do if (vdso_enabled) { \ | |||
290 | /* 1GB for 64bit, 8MB for 32bit */ | 300 | /* 1GB for 64bit, 8MB for 32bit */ |
291 | #define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) | 301 | #define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) |
292 | 302 | ||
293 | #define ARCH_DLINFO \ | 303 | #define ARCH_DLINFO \ |
294 | do if (vdso_enabled) { \ | 304 | do { \ |
295 | NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ | 305 | if (vdso_enabled) \ |
306 | NEW_AUX_ENT(AT_SYSINFO_EHDR, \ | ||
307 | (unsigned long)current->mm->context.vdso); \ | ||
296 | } while (0) | 308 | } while (0) |
297 | 309 | ||
298 | #define AT_SYSINFO 32 | 310 | #define AT_SYSINFO 32 |
@@ -305,8 +317,8 @@ do if (vdso_enabled) { \ | |||
305 | 317 | ||
306 | #define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) | 318 | #define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso) |
307 | 319 | ||
308 | #define VDSO_ENTRY \ | 320 | #define VDSO_ENTRY \ |
309 | ((unsigned long) VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall)) | 321 | ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall)) |
310 | 322 | ||
311 | struct linux_binprm; | 323 | struct linux_binprm; |
312 | 324 | ||