Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys * don't have the [onz]magic setup functions set up the s...



details:   https://anonhg.NetBSD.org/src/rev/1f27f0f4a5de
branches:  trunk
changeset: 472309:1f27f0f4a5de
user:      cgd <cgd%NetBSD.org@localhost>
date:      Tue Apr 27 05:36:43 1999 +0000

description:
* 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.

diffstat:

 sys/kern/exec_ecoff.c |  79 ++++++++++++++++++++++++++++++--------------------
 sys/sys/exec_ecoff.h  |  11 ++++++-
 2 files changed, 58 insertions(+), 32 deletions(-)

diffs (232 lines):

diff -r f9ad6e91f06e -r 1f27f0f4a5de sys/kern/exec_ecoff.c
--- a/sys/kern/exec_ecoff.c     Tue Apr 27 05:28:44 1999 +0000
+++ b/sys/kern/exec_ecoff.c     Tue Apr 27 05:36:43 1999 +0000
@@ -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 @@
 
        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_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 @@
 
        /* 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 @@
                    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 @@
  *                           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 @@
 
        /* 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 @@
                    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 @@
  * 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 @@
         * 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 @@
            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;
 }
diff -r f9ad6e91f06e -r 1f27f0f4a5de sys/sys/exec_ecoff.h
--- a/sys/sys/exec_ecoff.h      Tue Apr 27 05:28:44 1999 +0000
+++ b/sys/sys/exec_ecoff.h      Tue Apr 27 05:36:43 1999 +0000
@@ -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 @@
 
 #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_ */



Home | Main Index | Thread Index | Old Index