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/sys/imgact_aout.h

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 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 1992, 1993
    5  *      The Regents of the University of California.  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. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      from: @(#)exec.h        8.1 (Berkeley) 6/11/93
   32  * $FreeBSD: releng/12.0/sys/sys/imgact_aout.h 326023 2017-11-20 19:43:44Z pfg $
   33  */
   34 
   35 #ifndef _IMGACT_AOUT_H_
   36 #define _IMGACT_AOUT_H_
   37 
   38 #define N_GETMAGIC(ex) \
   39         ( le32toh((ex).a_midmag) & 0xffff )
   40 #define N_GETMID(ex) \
   41         ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
   42         ((ex).a_midmag >> 16) & 0x03ff )
   43 #define N_GETFLAG(ex) \
   44         ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
   45         ((ex).a_midmag >> 26) & 0x3f )
   46 #define N_SETMAGIC(ex,mag,mid,flag) \
   47         ( (ex).a_midmag = htole32((((flag) & 0x3f) <<26) | \
   48         (((mid) & 0x03ff) << 16) | \
   49         ((mag) & 0xffff)) )
   50 
   51 #define N_GETMAGIC_NET(ex) \
   52         (ntohl((ex).a_midmag) & 0xffff)
   53 #define N_GETMID_NET(ex) \
   54         ((ntohl((ex).a_midmag) >> 16) & 0x03ff)
   55 #define N_GETFLAG_NET(ex) \
   56         ((ntohl((ex).a_midmag) >> 26) & 0x3f)
   57 #define N_SETMAGIC_NET(ex,mag,mid,flag) \
   58         ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \
   59         | (((mag)&0xffff)) ) )
   60 
   61 #define N_ALIGN(ex,x) \
   62         (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
   63          N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
   64          ((x) + __LDPGSZ - 1) & ~(uint32_t)(__LDPGSZ - 1) : (x))
   65 
   66 /* Valid magic number check. */
   67 #define N_BADMAG(ex) \
   68         (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
   69          N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
   70          N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
   71          N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
   72 
   73 
   74 /* Address of the bottom of the text segment. */
   75 /*
   76  * This can not be done right.  Abuse a_entry in some cases to handle kernels.
   77  */
   78 #define N_TXTADDR(ex) \
   79         ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
   80         N_GETMAGIC(ex) == ZMAGIC) ? \
   81         (le32toh((ex).a_entry) < le32toh((ex).a_text) ? 0 : \
   82         le32toh((ex).a_entry) & ~__LDPGSZ) : __LDPGSZ)
   83 
   84 /* Address of the bottom of the data segment. */
   85 #define N_DATADDR(ex) \
   86         N_ALIGN(ex, N_TXTADDR(ex) + le32toh((ex).a_text))
   87 
   88 /* Text segment offset. */
   89 #define N_TXTOFF(ex) \
   90         (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
   91         N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
   92 
   93 /* Data segment offset. */
   94 #define N_DATOFF(ex) \
   95         N_ALIGN(ex, N_TXTOFF(ex) + le32toh((ex).a_text))
   96 
   97 /* Relocation table offset. */
   98 #define N_RELOFF(ex) \
   99         N_ALIGN(ex, N_DATOFF(ex) + le32toh((ex).a_data))
  100 
  101 /* Symbol table offset. */
  102 #define N_SYMOFF(ex) \
  103         (N_RELOFF(ex) + le32toh((ex).a_trsize) + le32toh((ex).a_drsize))
  104 
  105 /* String table offset. */
  106 #define N_STROFF(ex)    (N_SYMOFF(ex) + le32toh((ex).a_syms))
  107 
  108 /*
  109  * Header prepended to each a.out file.
  110  * Only manipulate the a_midmag field via the
  111  * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros.
  112  */
  113 
  114 struct exec {
  115      uint32_t   a_midmag;       /* flags<<26 | mid<<16 | magic */
  116      uint32_t   a_text;         /* text segment size */
  117      uint32_t   a_data;         /* initialized data size */
  118      uint32_t   a_bss;          /* uninitialized data size */
  119      uint32_t   a_syms;         /* symbol table size */
  120      uint32_t   a_entry;        /* entry point */
  121      uint32_t   a_trsize;       /* text relocation size */
  122      uint32_t   a_drsize;       /* data relocation size */
  123 };
  124 #define a_magic a_midmag        /* Hack for emulators */
  125 
  126 /* a_magic */
  127 #define OMAGIC          0407    /* old impure format */
  128 #define NMAGIC          0410    /* read-only text */
  129 #define ZMAGIC          0413    /* demand load format */
  130 #define QMAGIC          0314    /* "compact" demand load format */
  131 
  132 /* a_mid */
  133 #define MID_ZERO        0       /* unknown - implementation dependent */
  134 #define MID_SUN010      1       /* sun 68010/68020 binary */
  135 #define MID_SUN020      2       /* sun 68020-only binary */
  136 #define MID_I386        134     /* i386 BSD binary */
  137 #define MID_SPARC       138     /* sparc */
  138 #define MID_ARM6        143     /* ARM6 */
  139 #define MID_HP200       200     /* hp200 (68010) BSD binary */
  140 #define MID_HP300       300     /* hp300 (68020+68881) BSD binary */
  141 #define MID_HPUX        0x20C   /* hp200/300 HP-UX binary */
  142 #define MID_HPUX800     0x20B   /* hp800 HP-UX binary */
  143 
  144 /*
  145  * a_flags
  146  */
  147 #define EX_PIC          0x10    /* contains position independent code */
  148 #define EX_DYNAMIC      0x20    /* contains run-time link-edit info */
  149 #define EX_DPMASK       0x30    /* mask for the above */
  150 
  151 #ifdef _KERNEL
  152 struct thread;
  153 struct vnode;
  154 
  155 int     aout_coredump(struct thread *td, struct vnode *vp, off_t limit,
  156     int flags);
  157 #endif
  158 
  159 #endif /* !_IMGACT_AOUT_H_ */

Cache object: 2d6089adcdec2ff604412e6cce95eaaf


[ 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.