/* defs.h (emx+gcc) */

/* Various definitions for emx utilities.

Copyright (c) 1992, 1993 Eberhard Mattes

This file is part of emxomf, listomf and emxexp.

This module is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.  This module is distributed in
the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Library General Public License for
more details.  You should have received a copy of the GNU Library
General Public License along with this library; if not, write to the
Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

As a special exception, emxomf, listomf and emxexp can be distributed
with emx.  */

#define FALSE 0
#define TRUE  1

#define NORETURN2 __attribute__ ((noreturn))

/* Stabs constants. */

#define N_EXT           0x01    /* Symbol is external */
#define N_ABS           0x02    /* Absolute address */
#define N_TEXT          0x04    /* In .text segment */
#define N_DATA          0x06    /* In .data segment */
#define N_BSS           0x08    /* In .bss segment */

#define N_SETA          0x14
#define N_SETT          0x16

#define N_GSYM          0x20
#define N_FUN           0x24
#define N_STSYM         0x26
#define N_LCSYM         0x28
#define N_RSYM          0x40
#define N_SLINE         0x44
#define N_SO            0x64
#define N_LSYM          0x80
#define N_SOL           0x84
#define N_PSYM          0xa0
#define N_LBRAC         0xc0
#define N_RBRAC         0xe0

#define N_IMP1          0x68    /* Import reference (emx specific) */
#define N_IMP2          0x6a    /* Import definition (emx specific) */

/* The maximum OMF record size supported by OMF linkers.  This value
   includes the record type, length and checksum fields. */

#define MAX_REC_SIZE    1024

/* OMF record types.  To get the 32-bit variant of a record type, add
   REC32. */

#define THEADR          0x80    /* Translator module header record */
#define COMENT          0x88    /* Comment record */
#define MODEND          0x8a    /* Module end record */
#define EXTDEF          0x8c    /* External names definition record */
#define TYPDEF          0x8e    /* Type definition record */
#define PUBDEF          0x90    /* Public names definition record */
#define LINNUM          0x94    /* Line numbers record */
#define LNAMES          0x96    /* List of names record */
#define SEGDEF          0x98    /* Segment definition record */
#define GRPDEF          0x9a    /* Group definition record */
#define FIXUPP          0x9c    /* Fixup record */
#define LEDATA          0xa0    /* Logical enumerated data record */
#define LIDATA          0xa2    /* Logical iterated data record */
#define COMDEF          0xb0    /* Communal names definition record */
#define COMDAT          0xc2    /* Common block */
#define LIBHDR          0xf0    /* Library header */
#define LIBEND          0xf1    /* Library end */

/* Add this constant (using the | operator) to get the 32-bit variant
   of a record type.  Some fields will contain 32-bit values instead
   of 16-bit values. */

#define REC32           0x01


typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;

/* The header of an a.out file. */

struct a_out_header
{
  word magic;                   /* Magic word, must be 0407 */
  byte machtype;                /* Machine type */
  byte flags;                   /* Flags */
  long text_size;               /* Length of text, in bytes */
  long data_size;               /* Length of initialized data, in bytes */
  long bss_size;                /* Length of uninitialized data, in bytes */
  long sym_size;                /* Length of symbol table, in bytes */
  long entry;                   /* Start address (entry point) */
  long trsize;                  /* Length of relocation info for text, bytes */
  long drsize;                  /* Length of relocation info for data, bytes */
};

/* This is the layout of a relocation table entry. */

struct reloc
{
  dword address;                /* Fixup location */
  dword symbolnum:24;           /* Symbol number or segment */
  dword pcrel:1;                /* Self-relative fixup if non-zero */
  dword length:2;               /* Fixup size (0: 1 byte, 1: 2, 2: 4 bytes) */
  dword ext:1;                  /* Reference to symbol or segment */
  dword unused:4;               /* Not used */
};

/* This is the layout of a symbol table entry. */

struct nlist
{
  dword string;                 /* Offset in string table */
  byte type;                    /* Type of the symbol */
  byte other;                   /* Other information */
  word desc;                    /* More information */
  dword value;                  /* Value (address) */
};


#pragma pack(1)

struct omf_rec
{
  byte rec_type;
  word rec_len;
};

#pragma pack()
