diff options
| author | jdolecek <jdolecek@NetBSD.org> | 2000-12-01 13:49:35 +0000 |
|---|---|---|
| committer | jdolecek <jdolecek@NetBSD.org> | 2000-12-01 13:49:35 +0000 |
| commit | 798f64c85b85b9c85976dc6e6ea80d5cef3782fa (patch) | |
| tree | c0fe9213c8c43da885390b824a5b8b0af2eedbcd /sys/compat/linux/common/linux_exec_aout.c | |
| parent | 81f0543ba693576f48d1234ed2eb129082fde09e (diff) | |
put linux_sys_uselib() to separate file linux_uselib.c
Diffstat (limited to 'sys/compat/linux/common/linux_exec_aout.c')
| -rw-r--r-- | sys/compat/linux/common/linux_exec_aout.c | 104 |
1 files changed, 1 insertions, 103 deletions
diff --git a/sys/compat/linux/common/linux_exec_aout.c b/sys/compat/linux/common/linux_exec_aout.c index c0b5a903c48..4f9a9bb20e3 100644 --- a/sys/compat/linux/common/linux_exec_aout.c +++ b/sys/compat/linux/common/linux_exec_aout.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_aout.c,v 1.43 2000/12/01 12:28:33 jdolecek Exp $ */ +/* $NetBSD: linux_exec_aout.c,v 1.44 2000/12/01 13:49:35 jdolecek Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -329,105 +329,3 @@ exec_linux_aout_prep_qmagic(p, epp) return exec_aout_setup_stack(p, epp); } - -/* - * The Linux system call to load shared libraries, a.out version. The - * a.out shared libs are just files that are mapped onto a fixed - * address in the process' address space. The address is given in - * a_entry. Read in the header, set up some VM commands and run them. - * - * Yes, both text and data are mapped at once, so we're left with - * writeable text for the shared libs. The Linux crt0 seemed to break - * sometimes when data was mapped seperately. It munmapped a uselib() - * of ld.so by hand, which failed with shared text and data for ld.so - * Yuck. - * - * Because of the problem with ZMAGIC executables (text starts - * at 0x400 in the file, but needs to be mapped at 0), ZMAGIC - * shared libs are not handled very efficiently :-( - */ - -int -linux_sys_uselib(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct linux_sys_uselib_args /* { - syscallarg(const char *) path; - } */ *uap = v; - caddr_t sg; - long bsize, dsize, tsize, taddr, baddr, daddr; - struct nameidata ni; - struct vnode *vp; - struct exec hdr; - struct exec_vmcmd_set vcset; - int i, magic, error; - size_t rem; - - sg = stackgap_init(p->p_emul); - CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); - - NDINIT(&ni, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); - - if ((error = namei(&ni))) - return error; - - vp = ni.ni_vp; - - if ((error = vn_rdwr(UIO_READ, vp, (caddr_t) &hdr, LINUX_AOUT_HDR_SIZE, - 0, UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, - &rem, p))) { - vrele(vp); - return error; - } - - if (rem != 0) { - vrele(vp); - return ENOEXEC; - } - - if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE) - return ENOEXEC; - - magic = LINUX_N_MAGIC(&hdr); - taddr = hdr.a_entry & (~(NBPG - 1)); - tsize = hdr.a_text; - daddr = taddr + tsize; - dsize = hdr.a_data + hdr.a_bss; - - if ((hdr.a_text != 0 || hdr.a_data != 0) && vp->v_writecount != 0) { - vrele(vp); - return ETXTBSY; - } - vn_marktext(vp); - - vcset.evs_cnt = 0; - vcset.evs_used = 0; - - NEW_VMCMD(&vcset, - magic == ZMAGIC ? vmcmd_map_readvn : vmcmd_map_pagedvn, - hdr.a_text + hdr.a_data, taddr, - vp, LINUX_N_TXTOFF(hdr, magic), - VM_PROT_READ|VM_PROT_EXECUTE|VM_PROT_WRITE); - - baddr = roundup(daddr + hdr.a_data, NBPG); - bsize = daddr + dsize - baddr; - if (bsize > 0) { - NEW_VMCMD(&vcset, vmcmd_map_zero, bsize, baddr, - NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - } - - for (i = 0; i < vcset.evs_used && !error; i++) { - struct exec_vmcmd *vcp; - - vcp = &vcset.evs_cmds[i]; - error = (*vcp->ev_proc)(p, vcp); - } - - kill_vmcmds(&vcset); - - vrele(vp); - - return error; -} |
