8 #include <linux/module.h>
10 #include <linux/time.h>
11 #include <linux/kernel.h>
13 #include <linux/mman.h>
14 #include <linux/a.out.h>
15 #include <linux/errno.h>
16 #include <linux/signal.h>
17 #include <linux/string.h>
20 #include <linux/stat.h>
21 #include <linux/fcntl.h>
22 #include <linux/ptrace.h>
24 #include <linux/binfmts.h>
25 #include <linux/personality.h>
29 #include <asm/uaccess.h>
30 #include <asm/pgalloc.h>
31 #include <asm/cacheflush.h>
39 static int load_aout_library(
struct file *);
77 dump->
regs.bx = regs->bx;
78 dump->
regs.cx = regs->cx;
79 dump->
regs.dx = regs->dx;
80 dump->
regs.si = regs->si;
81 dump->
regs.di = regs->di;
82 dump->
regs.bp = regs->bp;
83 dump->
regs.ax = regs->ax;
90 dump->
regs.orig_ax = regs->orig_ax;
91 dump->
regs.ip = regs->ip;
108 .load_binary = load_aout_binary,
109 .load_shlib = load_aout_library,
116 static void set_brk(
unsigned long start,
unsigned long end)
122 vm_brk(start, end - start);
133 #define DUMP_WRITE(addr, nr) \
134 if (!dump_write(file, (void *)(addr), (nr))) \
137 #define DUMP_SEEK(offset) \
138 if (!dump_seek(file, offset)) \
141 #define START_DATA() (u.u_tsize << PAGE_SHIFT)
142 #define START_STACK(u) (u.start_stack)
169 dump_thread32(regs, &dump);
201 dump_start = START_DATA(dump);
207 dump_start = START_STACK(dump);
232 put_user((
unsigned long) envp, --sp);
233 put_user((
unsigned long) argv, --sp);
265 unsigned long error, fd_offset, rlim;
269 ex = *((
struct exec *) bprm->
buf);
273 i_size_read(bprm->
file->f_path.dentry->d_inode) <
287 if (ex.a_data + ex.a_bss > rlim)
305 current->mm->end_code = ex.a_text +
307 current->mm->end_data = ex.a_data +
312 current->mm->cached_hole_size = 0;
324 unsigned long text_addr, map_size;
330 map_size = ex.a_text+ex.a_data;
339 error = bprm->
file->f_op->read(bprm->
file,
340 (
char __user *)text_addr,
341 ex.a_text+ex.a_data, &pos);
342 if ((
signed long)error < 0) {
350 static unsigned long error_time, error_time2;
351 if ((ex.a_text & 0xfff || ex.a_data & 0xfff) &&
358 if ((fd_offset & ~PAGE_MASK) != 0 &&
361 "fd_offset is not page aligned. Please convert "
363 bprm->
file->f_path.dentry->d_name.name);
368 if (!bprm->
file->f_op->mmap || (fd_offset & ~PAGE_MASK) != 0) {
369 loff_t pos = fd_offset;
374 ex.a_text+ex.a_data, &pos);
377 ex.a_text+ex.a_data);
396 fd_offset + ex.a_text);
408 (
unsigned long)create_aout_tables((
char __user *)bprm->
p, bprm);
415 (regs)->sp =
current->mm->start_stack;
425 static int load_aout_library(
struct file *file)
432 inode = file->
f_path.dentry->d_inode;
435 error =
kernel_read(file, 0, (
char *) &ex,
sizeof(ex));
436 if (error !=
sizeof(ex))
453 start_addr = ex.a_entry & 0xfffff000;
455 if ((
N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
459 static unsigned long error_time;
462 "N_TXTOFF is not page aligned. Please convert "
464 file->
f_path.dentry->d_name.name);
468 vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
470 file->
f_op->read(file, (
char __user *)start_addr,
471 ex.a_text + ex.a_data, &pos);
473 (
unsigned long) start_addr + ex.a_text +
480 error =
vm_mmap(file, start_addr, ex.a_text + ex.a_data,
485 if (error != start_addr)
489 bss = ex.a_text + ex.a_data + ex.a_bss;
491 error =
vm_brk(start_addr + len, bss - len);
493 if (error != start_addr + len)
501 static int __init init_aout_binfmt(
void)
503 register_binfmt(&aout_format);
507 static void __exit exit_aout_binfmt(
void)