The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/freebsd/freebsd_exec_aout.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: freebsd_exec_aout.c,v 1.8 2007/12/08 18:35:58 dsl Exp $        */
    2 
    3 /*
    4  * Copyright (c) 1993, 1994 Christopher G. Demetriou
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by Christopher G. Demetriou.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __KERNEL_RCSID(0, "$NetBSD: freebsd_exec_aout.c,v 1.8 2007/12/08 18:35:58 dsl Exp $");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/proc.h>
   39 #include <sys/exec.h>
   40 
   41 #ifndef EXEC_AOUT
   42 #define EXEC_AOUT       /* to get a.out specific stuff */
   43 #endif
   44 
   45 #include <compat/freebsd/freebsd_exec.h>
   46 
   47 /*
   48 * exec_aout_makecmds(): Check if it's an a.out-format executable.
   49 *
   50 * Given a lwp pointer and an exec package pointer, see if the referent
   51 * of the epp is in a.out format.  First check 'standard' magic numbers for
   52 * this architecture.  If that fails, try a CPU-dependent hook.
   53  *
   54  * This function, in the former case, or the hook, in the latter, is
   55  * responsible for creating a set of vmcmds which can be used to build
   56  * the process's vm space and inserting them into the exec package.
   57  */
   58 
   59 int
   60 exec_freebsd_aout_makecmds(struct lwp *l, struct exec_package *epp)
   61 {
   62         u_long midmag;
   63         int error = ENOEXEC;
   64         struct exec *execp = epp->ep_hdr;
   65 
   66         if (epp->ep_hdrvalid < sizeof(struct exec))
   67                 return ENOEXEC;
   68 
   69         midmag = FREEBSD_N_GETMID(*execp) << 16 | FREEBSD_N_GETMAGIC(*execp);
   70 
   71         /* assume FreeBSD's MID_MACHINE and [ZQNO]MAGIC is same as NetBSD's */
   72         switch (midmag) {
   73         case (MID_MACHINE << 16) | ZMAGIC:
   74                 error = exec_aout_prep_oldzmagic(l, epp);
   75                 break;
   76         case (MID_MACHINE << 16) | QMAGIC:
   77                 error = exec_aout_prep_zmagic(l, epp);
   78                 break;
   79         case (MID_MACHINE << 16) | NMAGIC:
   80                 error = exec_aout_prep_nmagic(l, epp);
   81                 break;
   82         case (MID_MACHINE << 16) | OMAGIC:
   83                 error = exec_aout_prep_omagic(l, epp);
   84                 break;
   85         }
   86         if (error)
   87                 kill_vmcmds(&epp->ep_vmcmds);
   88 
   89         return error;
   90 }

Cache object: 078bd881e46c8eeae7cd6066b518bddd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.