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/exec_coff.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 /* $NetBSD: exec_coff.h,v 1.5 2003/08/08 18:54:16 christos Exp $ */
    2 
    3 /*-
    4  * Copyright (C) 2000 SAITOH Masanobu.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  */
   28 
   29 #ifndef _SYS_EXEC_COFF_H_
   30 #define _SYS_EXEC_COFF_H_
   31 
   32 #include <machine/coff_machdep.h>
   33 
   34 /*
   35  * COFF file header
   36  */
   37 
   38 struct coff_filehdr {
   39         u_short f_magic;        /* magic number */
   40         u_short f_nscns;        /* # of sections */
   41         long    f_timdat;       /* timestamp */
   42         long    f_symptr;       /* file offset of symbol table */
   43         long    f_nsyms;        /* # of symbol table entries */
   44         u_short f_opthdr;       /* size of optional header */
   45         u_short f_flags;        /* flags */
   46 };
   47 
   48 /* f_flags */
   49 #define COFF_F_RELFLG   0x1
   50 #define COFF_F_EXEC     0x2
   51 #define COFF_F_LNNO     0x4
   52 #define COFF_F_LSYMS    0x8
   53 #define COFF_F_SWABD    0x40
   54 #define COFF_F_AR16WR   0x80
   55 #define COFF_F_AR32WR   0x100
   56 #define COFF_F_AR32W    0x200
   57 
   58 /*
   59  * COFF system header
   60  */
   61 
   62 struct coff_aouthdr {
   63         short   a_magic;
   64         short   a_vstamp;
   65         long    a_tsize;
   66         long    a_dsize;
   67         long    a_bsize;
   68         long    a_entry;
   69         long    a_tstart;
   70         long    a_dstart;
   71 };
   72 
   73 /*
   74  * COFF section header
   75  */
   76 
   77 struct coff_scnhdr {
   78         char    s_name[8];
   79         long    s_paddr;
   80         long    s_vaddr;
   81         long    s_size;
   82         long    s_scnptr;
   83         long    s_relptr;
   84         long    s_lnnoptr;
   85         u_short s_nreloc;
   86         u_short s_nlnno;
   87         long    s_flags;
   88 };
   89 
   90 /* s_flags */
   91 #define COFF_STYP_REG           0x00
   92 #define COFF_STYP_DSECT         0x01
   93 #define COFF_STYP_NOLOAD        0x02
   94 #define COFF_STYP_GROUP         0x04
   95 #define COFF_STYP_PAD           0x08
   96 #define COFF_STYP_COPY          0x10
   97 #define COFF_STYP_TEXT          0x20
   98 #define COFF_STYP_DATA          0x40
   99 #define COFF_STYP_BSS           0x80
  100 #define COFF_STYP_INFO          0x200
  101 #define COFF_STYP_OVER          0x400
  102 #define COFF_STYP_SHLIB         0x800
  103 
  104 /*
  105  * COFF shared library header
  106  */
  107 
  108 struct coff_slhdr {
  109         long    entry_len;      /* in words */
  110         long    path_index;     /* in words */
  111         char    sl_name[1];
  112 };
  113 
  114 struct coff_exechdr {
  115         struct coff_filehdr f;
  116         struct coff_aouthdr a;
  117 };
  118 
  119 #define COFF_ROUND(val, by)     (((val) + by - 1) & ~(by - 1))
  120 
  121 #define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))
  122 
  123 #define COFF_HDR_SIZE \
  124         (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))
  125 
  126 #define COFF_BLOCK_ALIGN(ap, value) \
  127         ((ap)->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
  128          value)
  129 
  130 #define COFF_TXTOFF(fp, ap) \
  131         ((ap)->a_magic == COFF_ZMAGIC ? 0 : \
  132          COFF_ROUND(COFF_HDR_SIZE + (fp)->f_nscns * \
  133                     sizeof(struct coff_scnhdr), \
  134                     COFF_SEGMENT_ALIGNMENT(fp, ap)))
  135 
  136 #define COFF_DATOFF(fp, ap) \
  137         (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + (ap)->a_tsize))
  138 
  139 #define COFF_SEGMENT_ALIGN(fp, ap, value) \
  140         (COFF_ROUND(value, ((ap)->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
  141          COFF_SEGMENT_ALIGNMENT(fp, ap))))
  142 
  143 #ifdef _KERNEL
  144 int     exec_coff_makecmds __P((struct proc *, struct exec_package *));
  145 
  146 int     exec_coff_prep_omagic __P((struct proc *, struct exec_package *,
  147                                    struct coff_filehdr *,
  148                                    struct coff_aouthdr *));
  149 int     exec_coff_prep_nmagic __P((struct proc *, struct exec_package *,
  150                                    struct coff_filehdr *,
  151                                    struct coff_aouthdr *));
  152 int     exec_coff_prep_zmagic __P((struct proc *, struct exec_package *,
  153                                    struct coff_filehdr *,
  154                                    struct coff_aouthdr *));
  155 #endif /* _KERNEL */
  156 #endif /* !_SYS_EXEC_COFF_H_ */

Cache object: aa0e7a10b6c0c77a0523311c732719ee


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