home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_07 / MARK_WC2.LZH / INCLUDE / NOUT.H < prev    next >
C/C++ Source or Header  |  1988-04-27  |  4KB  |  132 lines

  1. /*
  2.  * nout.h -- give structure of Mark Williams "n.out" object format.
  3.  *
  4.  * Copyright (c) 1986-1988, Mark Williams Company, Chicago
  5.  * This file and its contents may not be copied or distributed
  6.  * without permission.
  7.  */
  8.  
  9. #ifndef     L_OUT_H
  10. #define     L_OUT_H
  11.  
  12. #define    NCPLN    16        /* Chars in loader name */
  13. #define NLSEG    9        /* No. of segments */
  14. #define    NXSEG    6        /* No. of segments used by exec */
  15. #define    L_MAGIC    0407        /* Magic number */
  16.  
  17. /*
  18.  * The following gives the header for n.out.
  19.  * It sits at the front of the file,
  20.  * and contains control information and
  21.  * the sizes of the other segments
  22.  * of the file.
  23.  * These values are in canonical byte order
  24.  * in disk files, they should be converted
  25.  * to native byte order with canint() and
  26.  * canlong() when read from the file, and
  27.  * converted back to canonical order when
  28.  * written back to a file.
  29.  *
  30.  * Gemdos format executable files written
  31.  * by the MWC linker or converted by drtomw
  32.  * have a ldheader inserted into the gemdos
  33.  * symbol table with the MWC debug and symbol
  34.  * segments.
  35.  * The LF_FAKE flag is set in the ldheader l_flag.
  36.  */
  37. struct    ldheader {
  38.     short    l_magic;    /* Magic number */
  39.     short    l_flag;        /* Flags */
  40.     short    l_machine;    /* Type of target machine */
  41.     short    l_tbase;    /* Text starts here */
  42.     long    l_ssize[NLSEG];    /* Segment sizes */
  43.     long    l_entry;    /* Entry point */
  44. };
  45.  
  46. /* Flags */
  47. #define LF_SHR        01    /* Bound shared */
  48. #define LF_SEP        02    /* Bound separated */
  49. #define LF_NRB        04    /* No relocation bits */
  50. #define    LF_KER        010    /* Loadable driver */
  51. #define    LF_32        020    /* 32-bit format l.out */
  52. #define    LF_SLREF    040    /* References shared library */
  53. #define    LF_SLIB        0100    /* Is the shared library */
  54. #define LF_DEBUG    0200    /* Debug information is present */
  55. #define LF_FAKE        0400    /* Header is displaced to end of exe or prg */
  56.  
  57. /* Formats */
  58. #define    AFMT    "%08lx"        /* Address */
  59.  
  60. /* Machines */
  61. #ifndef    MTYPE_H
  62. #include <mtype.h>
  63. #endif
  64.  
  65. /* Segments */
  66. #define    L_SHRI    0        /* Shared Instruction space */
  67. #define    L_PRVI    1        /* Private Instruction space */
  68. #define    L_BSSI    2        /* Uninitialised Instruction */
  69. #define    L_SHRD    3        /* Shared Data space */
  70. #define    L_PRVD    4        /* Private Data space */
  71. #define    L_BSSD    5        /* Uninitalised Data */
  72. #define L_DEBUG 6        /* Debug tables */
  73. #define L_SYM    7        /* Symbols */
  74. #define L_REL    8        /* Relocation */
  75.  
  76. #define L_ABS    9        /* Absolute (symbol table only) */
  77. #define L_REF    10        /* Reference (symbol table) */
  78.  
  79. #define    L_GLOBAL    020    /* Global bit, or'ed in */
  80.  
  81. /*
  82.  * Symbols.
  83.  * These live in the "L_SYM" section
  84.  * of the file; the size of this section
  85.  * determines the number of symbols.
  86.  * The ls_type and ls_addr fields are kept
  87.  * in canonical byte order.
  88.  */
  89. struct    ldsym {
  90.     char    ls_id[NCPLN];    /* Symbol name */
  91.     short    ls_type;    /* Global + Seg. */
  92.     long    ls_addr;    /* Value of symbol */
  93. };
  94.  
  95. /*
  96.  * The nlist structure for the nlist routine.
  97.  */
  98. struct nlist    {
  99.     char    n_name[NCPLN];    /* Symbol name */
  100.     short    n_type;        /* Type flag */
  101.     long    n_value;    /* Value */
  102. };
  103.  
  104.  
  105. /*
  106.  * Relocation is a byte stream.
  107.  * The first byte is an opcode
  108.  * which specifies the size of the relocated item,
  109.  * whether the item is program counter relative,
  110.  * and the segment to which the item refers.
  111.  * The next four bytes are a long address
  112.  * stored in canonical byte order
  113.  * which identifies the location of the item
  114.  * to be relocated.
  115.  * If the opcode specifies L_SYM as the segment,
  116.  * then the next two bytes are a symbol index
  117.  * stored in canonical byte order
  118.  * which identifies the symbol to which the item
  119.  * wishes to refer.
  120.  */
  121. #define LR_SEG    017        /* Seg., L_SYM => Sym. based */
  122. #define LR_PCR    020        /* PC-rel. flag */
  123. #define LR_OP    0340        /* Opcode */
  124.  
  125. #define LR_BYTE    (0<<5)        /* Rel. a byte */
  126. #define LR_WORD    (1<<5)        /* Rel. a word */
  127. #define    LR_LONG    (2<<5)        /* Rel. a long */
  128.  
  129. #endif
  130.  
  131. /* End of nout.h */
  132.