1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1994 Sean Eric Fagan 5 * Copyright (c) 1994 S��ren Schmidt 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer 13 * in this position and unchanged. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $FreeBSD$ 32 */ 33 34#ifndef _COFF_H 35#define _COFF_H 36 37struct filehdr { 38 unsigned short f_magic; /* magic number */ 39 unsigned short f_nscns; /* # of sections */ 40 long f_timdat; /* time stamp */ 41 long f_symptr; /* symbol table offset */ 42 long f_nsyms; /* # of symbols */ 43 unsigned short f_opthdr; /* size of system header */ 44 unsigned short f_flags; /* flags, see below */ 45}; 46 47enum filehdr_flags { 48 F_RELFLG = 0x01, /* relocs have been stripped */ 49 F_EXEC = 0x02, /* executable file (or shlib) */ 50 F_LNNO = 0x04, /* line numbers have been stripped */ 51 F_LSYMS = 0x08, /* symbols have been stripped */ 52 F_SWABD = 0x40, /* swabbed byte names */ 53 F_AR16WR = 0x80, /* 16-bit, byte reversed words */ 54 F_AR32WR = 0x100 /* 32-bit, byte reversed words */ 55}; 56 57struct aouthdr { 58 short magic; /* magic number -- see below */ 59 short vstamp; /* artifacts from a by-gone day */ 60 long tsize; /* */ 61 long dsize; /* */ 62 long bsize; /* */ 63 long entry; /* Entry point -- offset into file */ 64 long tstart; /* artifacts from a by-gone day */ 65 long dstart; /* */ 66}; 67 68#define I386_COFF 0x14c 69 70#define COFF_OMAGIC 0407 /* impure format */ 71#define COFF_NMAGIC 0410 /* read-only text */ 72#define COFF_ZMAGIC 0413 /* pagable from disk */ 73#define COFF_SHLIB 0443 /* a shared library */ 74 75struct scnhdr { 76 char s_name[8]; /* name of section (e.g., ".text") */ 77 long s_paddr; /* physical addr, used for standalone */ 78 long s_vaddr; /* virtual address */ 79 long s_size; /* size of section */ 80 long s_scnptr; /* file offset of section */ 81 long s_relptr; /* points to relocs for section */ 82 long s_lnnoptr; /* points to line numbers for section */ 83 unsigned short s_nreloc; /* # of relocs */ 84 unsigned short s_nlnno; /* # of line no's */ 85 long s_flags; /* section flags -- see below */ 86}; 87 88enum scnhdr_flags { 89 STYP_REG = 0x00, /* regular (alloc'ed, reloc'ed, loaded) */ 90 STYP_DSECT = 0x01, /* dummy (reloc'd) */ 91 STYP_NOLOAD = 0x02, /* no-load (reloc'd) */ 92 STYP_GROUP = 0x04, /* grouped */ 93 STYP_PAD = 0x08, /* padding (loaded) */ 94 STYP_COPY = 0x10, /* ??? */ 95 STYP_TEXT = 0x20, /* text */ 96 STYP_DATA = 0x40, /* data */ 97 STYP_BSS = 0x80, /* bss */ 98 STYP_INFO = 0x200, /* comment (!loaded, !alloc'ed, !reloc'd) */ 99 STYP_OVER = 0x400, /* overlay (!allocated, reloc'd, !loaded) */ 100 STYP_LIB = 0x800 /* lists shared library files */ 101}; 102 103struct slhdr { 104 long entry_length; 105 long path_index; 106 char *shlib_name; 107}; 108#endif /* _COFF_H */ 109