* don't have the [onz]magic setup functions set up the stack.
* add arguments describing the vnode and ecoff header of the executable being set up to the [onz]magic setup functions. * export the stack setup function and the [onz]magic setup functions. * call the MD ecoff hook _before_ the [onz]magic and stack setup functions, and bail out early if the MD hook sets up vmcmds.
This commit is contained in:
parent
5338149302
commit
e85db685e9
|
@ -1,8 +1,8 @@
|
|||
/* $NetBSD: exec_ecoff.c,v 1.9 1996/09/27 03:38:28 cgd Exp $ */
|
||||
/* $NetBSD: exec_ecoff.c,v 1.10 1999/04/27 05:36:43 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass
|
||||
* Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
|
||||
* Copyright (c) 1993, 1994, 1996, 1999 Christopher G. Demetriou
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -15,7 +15,8 @@
|
|||
* 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.
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
|
@ -42,11 +43,6 @@
|
|||
|
||||
#include <sys/exec_ecoff.h>
|
||||
|
||||
int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *));
|
||||
int exec_ecoff_prep_nmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_ecoff_prep_zmagic __P((struct proc *, struct exec_package *));
|
||||
int exec_ecoff_setup_stack __P((struct proc *, struct exec_package *));
|
||||
|
||||
/*
|
||||
* exec_ecoff_makecmds(): Check if it's an ecoff-format executable.
|
||||
*
|
||||
|
@ -71,23 +67,41 @@ exec_ecoff_makecmds(p, epp)
|
|||
|
||||
if (ECOFF_BADMAG(execp))
|
||||
return ENOEXEC;
|
||||
|
||||
|
||||
error = cpu_exec_ecoff_hook(p, epp);
|
||||
|
||||
/*
|
||||
* if there was an error or there are already vmcmds set up,
|
||||
* we return. (the latter can happen if cpu_exec_ecoff_hook()
|
||||
* recursively invokes check_exec() to handle loading of a
|
||||
* dynamically linked binary's shared loader.
|
||||
*/
|
||||
if (error || epp->ep_vmcmds.evs_cnt)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* prepare the exec package to map the executable.
|
||||
*/
|
||||
switch (execp->a.magic) {
|
||||
case ECOFF_OMAGIC:
|
||||
error = exec_ecoff_prep_omagic(p, epp);
|
||||
error = exec_ecoff_prep_omagic(p, epp, epp->ep_hdr,
|
||||
epp->ep_vp);
|
||||
break;
|
||||
case ECOFF_NMAGIC:
|
||||
error = exec_ecoff_prep_nmagic(p, epp);
|
||||
error = exec_ecoff_prep_nmagic(p, epp, epp->ep_hdr,
|
||||
epp->ep_vp);
|
||||
break;
|
||||
case ECOFF_ZMAGIC:
|
||||
error = exec_ecoff_prep_zmagic(p, epp);
|
||||
error = exec_ecoff_prep_zmagic(p, epp, epp->ep_hdr,
|
||||
epp->ep_vp);
|
||||
break;
|
||||
default:
|
||||
return ENOEXEC;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
error = cpu_exec_ecoff_hook(p, epp);
|
||||
/* set up the stack */
|
||||
if (!error)
|
||||
error = exec_ecoff_setup_stack(p, epp);
|
||||
|
||||
if (error)
|
||||
kill_vmcmds(&epp->ep_vmcmds);
|
||||
|
@ -142,11 +156,12 @@ exec_ecoff_setup_stack(p, epp)
|
|||
* exec_ecoff_prep_omagic(): Prepare a ECOFF OMAGIC binary's exec package
|
||||
*/
|
||||
int
|
||||
exec_ecoff_prep_omagic(p, epp)
|
||||
exec_ecoff_prep_omagic(p, epp, execp, vp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
struct ecoff_exechdr *execp;
|
||||
struct vnode *vp;
|
||||
{
|
||||
struct ecoff_exechdr *execp = epp->ep_hdr;
|
||||
struct ecoff_aouthdr *eap = &execp->a;
|
||||
|
||||
epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
|
||||
|
@ -157,7 +172,7 @@ exec_ecoff_prep_omagic(p, epp)
|
|||
|
||||
/* set up command for text and data segments */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
|
||||
eap->tsize + eap->dsize, epp->ep_taddr, epp->ep_vp,
|
||||
eap->tsize + eap->dsize, epp->ep_taddr, vp,
|
||||
ECOFF_TXTOFF(execp),
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
|
@ -167,7 +182,7 @@ exec_ecoff_prep_omagic(p, epp)
|
|||
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
return exec_ecoff_setup_stack(p, epp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -175,11 +190,12 @@ exec_ecoff_prep_omagic(p, epp)
|
|||
* package.
|
||||
*/
|
||||
int
|
||||
exec_ecoff_prep_nmagic(p, epp)
|
||||
exec_ecoff_prep_nmagic(p, epp, execp, vp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
struct ecoff_exechdr *execp;
|
||||
struct vnode *vp;
|
||||
{
|
||||
struct ecoff_exechdr *execp = epp->ep_hdr;
|
||||
struct ecoff_aouthdr *eap = &execp->a;
|
||||
|
||||
epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
|
||||
|
@ -190,12 +206,12 @@ exec_ecoff_prep_nmagic(p, epp)
|
|||
|
||||
/* set up command for text segment */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_tsize,
|
||||
epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(execp),
|
||||
epp->ep_taddr, vp, ECOFF_TXTOFF(execp),
|
||||
VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for data segment */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_dsize,
|
||||
epp->ep_daddr, epp->ep_vp, ECOFF_DATOFF(execp),
|
||||
epp->ep_daddr, vp, ECOFF_DATOFF(execp),
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for bss segment */
|
||||
|
@ -204,7 +220,7 @@ exec_ecoff_prep_nmagic(p, epp)
|
|||
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
return exec_ecoff_setup_stack(p, epp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -217,11 +233,12 @@ exec_ecoff_prep_nmagic(p, epp)
|
|||
* text, data, bss, and stack segments.
|
||||
*/
|
||||
int
|
||||
exec_ecoff_prep_zmagic(p, epp)
|
||||
exec_ecoff_prep_zmagic(p, epp, execp, vp)
|
||||
struct proc *p;
|
||||
struct exec_package *epp;
|
||||
struct ecoff_exechdr *execp;
|
||||
struct vnode *vp;
|
||||
{
|
||||
struct ecoff_exechdr *execp = epp->ep_hdr;
|
||||
struct ecoff_aouthdr *eap = &execp->a;
|
||||
|
||||
epp->ep_taddr = ECOFF_SEGMENT_ALIGN(execp, eap->text_start);
|
||||
|
@ -236,23 +253,23 @@ exec_ecoff_prep_zmagic(p, epp)
|
|||
* reasons
|
||||
*/
|
||||
if ((eap->tsize != 0 || eap->dsize != 0) &&
|
||||
epp->ep_vp->v_writecount != 0) {
|
||||
vp->v_writecount != 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (epp->ep_vp->v_flag & VTEXT)
|
||||
if (vp->v_flag & VTEXT)
|
||||
panic("exec: a VTEXT vnode has writecount != 0\n");
|
||||
#endif
|
||||
return ETXTBSY;
|
||||
}
|
||||
epp->ep_vp->v_flag |= VTEXT;
|
||||
vp->v_flag |= VTEXT;
|
||||
|
||||
/* set up command for text segment */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->tsize,
|
||||
epp->ep_taddr, epp->ep_vp, ECOFF_TXTOFF(execp),
|
||||
epp->ep_taddr, vp, ECOFF_TXTOFF(execp),
|
||||
VM_PROT_READ|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for data segment */
|
||||
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, eap->dsize,
|
||||
epp->ep_daddr, epp->ep_vp, ECOFF_DATOFF(execp),
|
||||
epp->ep_daddr, vp, ECOFF_DATOFF(execp),
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
/* set up command for bss segment */
|
||||
|
@ -260,5 +277,5 @@ exec_ecoff_prep_zmagic(p, epp)
|
|||
ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0,
|
||||
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
|
||||
|
||||
return exec_ecoff_setup_stack(p, epp);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec_ecoff.h,v 1.10 1996/09/26 22:39:14 cgd Exp $ */
|
||||
/* $NetBSD: exec_ecoff.h,v 1.11 1999/04/27 05:36:43 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Adam Glass
|
||||
|
@ -104,6 +104,15 @@ struct ecoff_exechdr {
|
|||
|
||||
#ifdef _KERNEL
|
||||
int exec_ecoff_makecmds __P((struct proc *, struct exec_package *));
|
||||
int exec_ecoff_setup_stack __P((struct proc *, struct exec_package *));
|
||||
int cpu_exec_ecoff_hook __P((struct proc *, struct exec_package *));
|
||||
|
||||
int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *,
|
||||
struct ecoff_exechdr *, struct vnode *));
|
||||
int exec_ecoff_prep_nmagic __P((struct proc *, struct exec_package *,
|
||||
struct ecoff_exechdr *, struct vnode *));
|
||||
int exec_ecoff_prep_zmagic __P((struct proc *, struct exec_package *,
|
||||
struct ecoff_exechdr *, struct vnode *));
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_SYS_EXEC_ECOFF_H_ */
|
||||
|
|
Loading…
Reference in New Issue