/*
- * irixelf.c: Code to load IRIX ELF executables which conform to
- * the MIPS ABI.
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
*
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
+ * irixelf.c: Code to load IRIX ELF executables conforming to the MIPS ABI.
+ * Based off of work by Eric Youngdale.
*
- * Based upon work which is:
- * Copyright 1993, 1994: Eric Youngdale (ericy@cais.com).
+ * Copyright (C) 1993 - 1994 Eric Youngdale <ericy@cais.com>
+ * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
+ * Copyright (C) 2004 Steven J. Hill <sjhill@realitydiluted.com>
*/
-
#include <linux/module.h>
-
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/sched.h>
end = PAGE_ALIGN(end);
if (end <= start)
return;
+ down_write(¤t->mm->mmap_sem);
do_brk(start, end - start);
+ up_write(¤t->mm->mmap_sem);
}
__put_user((unsigned long)p,argv++);
p += strlen_user(p);
}
- __put_user(NULL, argv);
+ __put_user((unsigned long) NULL, argv);
current->mm->arg_end = current->mm->env_start = (unsigned long) p;
while (envc-->0) {
__put_user((unsigned long)p,envp++);
p += strlen_user(p);
}
- __put_user(NULL, envp);
+ __put_user((unsigned long) NULL, envp);
current->mm->env_end = (unsigned long) p;
return sp;
}
/* Map the last of the bss segment */
if (last_bss > len) {
+ down_write(¤t->mm->mmap_sem);
do_brk(len, (last_bss - len));
+ up_write(¤t->mm->mmap_sem);
}
kfree(elf_phdata);
unsigned long v;
struct prda *pp;
+ down_write(¤t->mm->mmap_sem);
v = do_brk (PRDA_ADDRESS, PAGE_SIZE);
+ up_write(¤t->mm->mmap_sem);
if (v < 0)
return;
}
retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *)elf_phdata, size);
+
if (retval < 0)
goto out_free_ph;
/* Do this so that we can load the interpreter, if need be. We will
* change some of these later.
*/
- // current->mm->rss = 0;
- vx_rsspages_sub(current->mm, current->mm->rss);
- setup_arg_pages(bprm, EXSTACK_DEFAULT);
+ set_mm_counter(current->mm, rss, 0);
+ setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
current->mm->start_stack = bprm->p;
/* At this point, we assume that the image should be loaded at
len = (elf_phdata->p_filesz + elf_phdata->p_vaddr+ 0xfff) & 0xfffff000;
bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
- if (bss > len)
+ if (bss > len) {
+ down_write(¤t->mm->mmap_sem);
do_brk(len, bss-len);
+ up_write(¤t->mm->mmap_sem);
+ }
kfree(elf_phdata);
return 0;
}
/* First get the verification out of the way. */
hp = user_phdrp;
- retval = verify_area(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt));
- if(retval) {
+ if (!access_ok(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt))) {
#ifdef DEBUG_ELF
- printk("irix_mapelf: verify_area fails!\n");
+ printk("irix_mapelf: access_ok fails!\n");
#endif
- return retval;
+ return -EFAULT;
}
#ifdef DEBUG_ELF
}
#ifdef DEBUG_ELF
- printk("irix_mapelf: Success, returning %08lx\n", user_phdrp->p_vaddr);
+ printk("irix_mapelf: Success, returning %08lx\n",
+ (unsigned long) user_phdrp->p_vaddr);
#endif
fput(filp);
return user_phdrp->p_vaddr;
static int __init init_irix_binfmt(void)
{
+ int init_inventory(void);
+ extern asmlinkage unsigned long sys_call_table;
+ extern asmlinkage unsigned long sys_call_table_irix5;
+
+ init_inventory();
+
+ /*
+ * Copy the IRIX5 syscall table (8000 bytes) into the main syscall
+ * table. The IRIX5 calls are located by an offset of 8000 bytes
+ * from the beginning of the main table.
+ */
+ memcpy((void *) ((unsigned long) &sys_call_table + 8000),
+ &sys_call_table_irix5, 8000);
+
return register_binfmt(&irix_format);
}