105 lines
3.7 KiB
C
105 lines
3.7 KiB
C
/* $NetBSD: aout_machdep.c,v 1.1 2000/05/09 21:55:55 bjh21 Exp $ */
|
|
|
|
/*
|
|
* Copyright (c) 2000 Ben Harris
|
|
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by Christopher G. Demetriou.
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
* derived from this software without specific prior written permission
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
/* This file is part of NetBSD/arm26 -- a port of NetBSD to ARM2/3 machines. */
|
|
/*
|
|
* aout_machdep.c - odd a.out executable formats
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
|
|
__RCSID("$NetBSD: aout_machdep.c,v 1.1 2000/05/09 21:55:55 bjh21 Exp $");
|
|
|
|
#include <sys/exec.h>
|
|
#include <sys/exec_aout.h>
|
|
#include <sys/systm.h>
|
|
#include <sys/vnode.h>
|
|
#include <machine/aout_machdep.h>
|
|
#include <vm/vm.h>
|
|
|
|
int cpu_exec_aout_prep_ozmagic(struct proc *, struct exec_package *);
|
|
|
|
int
|
|
cpu_exec_aout_makecmds(struct proc *p, struct exec_package *epp)
|
|
{
|
|
struct exec *execp = epp->ep_hdr;
|
|
|
|
if (execp->a_midmag == ZMAGIC)
|
|
/* GNU binutils arm-acorn-aout format */
|
|
return cpu_exec_aout_prep_ozmagic(p, epp);
|
|
return ENOEXEC;
|
|
}
|
|
|
|
|
|
int cpu_exec_aout_prep_ozmagic(struct proc *p, struct exec_package *epp)
|
|
{
|
|
struct exec *execp = epp->ep_hdr;
|
|
|
|
epp->ep_taddr = USRTEXT;
|
|
epp->ep_tsize = execp->a_text;
|
|
epp->ep_daddr = epp->ep_taddr + execp->a_text;
|
|
epp->ep_dsize = execp->a_data + execp->a_bss;
|
|
epp->ep_entry = execp->a_entry;
|
|
|
|
/*
|
|
* check if vnode is in open for writing, because we want to
|
|
* demand-page out of it. if it is, don't do it, for various
|
|
* reasons
|
|
*/
|
|
if ((execp->a_text != 0 || execp->a_data != 0) &&
|
|
epp->ep_vp->v_writecount != 0) {
|
|
#ifdef DIAGNOSTIC
|
|
if (epp->ep_vp->v_flag & VTEXT)
|
|
panic("exec: a VTEXT vnode has writecount != 0\n");
|
|
#endif
|
|
return ETXTBSY;
|
|
}
|
|
epp->ep_vp->v_flag |= VTEXT;
|
|
|
|
/* set up command for text segment */
|
|
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
|
|
epp->ep_taddr, epp->ep_vp, __LDPGSZ, VM_PROT_READ|VM_PROT_EXECUTE);
|
|
|
|
/* set up command for data segment */
|
|
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data,
|
|
epp->ep_daddr, epp->ep_vp, __LDPGSZ + execp->a_text,
|
|
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
|
|
|
/* set up command for bss segment */
|
|
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
|
|
epp->ep_daddr + execp->a_data, NULLVP, 0,
|
|
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
|
|
|
return exec_aout_setup_stack(p, epp);
|
|
|
|
}
|