home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / relsym.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  4.8 KB  |  193 lines

  1.  
  2. /*
  3.  *    @(#) relsym.h 2.1 88/05/18 
  4.  *
  5.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987.
  6.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987.
  7.  *    This Module contains Proprietary Information of
  8.  *    The Santa Cruz Operation, Microsoft Corporation
  9.  *    and AT&T, and should be treated as Confidential.
  10.  */
  11. /*
  12.  *    <sys/relsym.h> - Declarations for symbol table
  13.  *        and relocation record structures.
  14.  *
  15.  */
  16.  
  17. /*
  18.  *    Symbol table for x.out.
  19.  *    Each symbol in the table has the below structure, followed
  20.  *    immediately by its name in the form of a null terminated string.
  21.  *    No effort is made to word align subsequent "sym" structures in
  22.  *    the symbol table.  The contents of the s_seg field is defined
  23.  *    for XS_SXSEG symbols only.  For XR_S86ABS symbols, the segment
  24.  *    is stored in the high 16 bits of the s_value field, and the offset
  25.  *    in the low 16 bits.
  26.  */
  27.  
  28. struct sym {                /* symbol management */
  29.     unsigned short    s_type;        /* type */
  30.     unsigned short    s_seg;        /* file segment table index */
  31.     long        s_value;    /* address or value */
  32. };
  33.  
  34.  
  35. #define SYMLENGTH    50    /* max symbol name length */
  36.  
  37.  
  38. /*
  39.  *    Definitions for sym.s_type:
  40.  *
  41.  *    xxxxxxxxxx          extra
  42.  *              e         external
  43.  *               ttttt    type
  44.  */
  45.  
  46. #define S_UNDEF        0x0000
  47. #define S_ABS        0x0001
  48. #define S_TEXT        0x0002
  49. #define S_DATA        0x0003
  50. #define S_BSS        0x0004
  51. #define S_COMM        0x0005    /* for internal use only */
  52. #define S_REG        0x0006
  53. #define S_COMB        0x0007  /* for internal use only */
  54. #define S_SEG        0x0008    /* segment name */
  55. #define S_FN        0x001f
  56. #define S_TYPE        0x001f    /* mask */
  57.  
  58. #define S_EXTERN    0x0020
  59.  
  60. #define FORMAT    "%08lx"    /* symbol value format */
  61. #define FWIDTH    8    /* symbol value width  */
  62.  
  63.  
  64. /*
  65.  *    Relocation table entry for x.out and x.out segmented, long form.
  66.  *    This form is normally attached to ".o" files and may also be found
  67.  *    in segmented executables.
  68.  */
  69.  
  70. struct reloc {
  71.     unsigned short    r_desc;     /* descriptor */
  72.     unsigned short    r_symbol;   /* if extern, sym id; else segment id */
  73.     long        r_pos;        /* position of reloc in segment */
  74. };
  75.  
  76.  
  77. /*
  78.  *    Definitions for reloc.r_desc (short).
  79.  *
  80.  *    ss                  segment type
  81.  *      ss                size
  82.  *        d               displacement
  83.  *         rrr        reference type
  84.  *            xxxxxxxx    extra
  85.  */
  86.  
  87.  
  88.                 /* type of segment referenced */
  89. #define RD_TEXT    0x0000        /* text */
  90. #define RD_DATA    0x4000        /* data */
  91. #define RD_BSS    0x8000        /* bss */
  92. #define RD_EXT    0xc000        /* unknown, use type of reloc.r_symbol */
  93. #define RD_SEG    0xc000        /* segment type mask */
  94.  
  95.                 /* number of bytes involved in reference */
  96. #define RD_BYTE    0x0000        /* 1 */
  97. #define RD_WORD    0x1000        /* 2 */
  98. #define RD_LONG    0x2000        /* 4 */
  99. #define RD_SIZE    0x3000        /* size mask */
  100.  
  101. #define RD_DISP    0x0800        /* set if self relative (pc relative) */
  102.  
  103.                 /* type of reference */
  104. #define RD_ROFF    0x0000        /* offset only */
  105. #define RD_RSEG    0x0100        /* segment only */
  106. #define RD_RFAR    0x0200        /* segment and offset */
  107. #define RD_REFT    0x0700        /* reference type mask */
  108.  
  109.  
  110. /*
  111.  *    Relocation table entry for x.out, short form.
  112.  *    This form is normally attached to non-segmented executable files.
  113.  */
  114.  
  115. struct xreloc {
  116.     long    xr_cmd;        /* reloc command */
  117. };
  118.  
  119.  
  120. /*
  121.  *    Definitions for xreloc.xr_cmd (long).
  122.  *
  123.  *    c                                   set if code segment
  124.  *     l                                  set if long operand
  125.  *      oooooooooooooooooooooooooooooo    offset
  126.  */
  127.  
  128. #define XR_CODE    0x80000000L    /* code/data segment */
  129. #define XR_LONG    0x40000000L    /* long/short operand */
  130. #define XR_OFFS    0x3fffffffL    /* 30 bit offset mask */
  131.  
  132.  
  133. /*
  134.  *    Group structure for segmented x.out.
  135.  *    A segment of type XS_TGRPS contains an array of struct xgroup.
  136.  */
  137.  
  138. struct xgroup {
  139.     unsigned short    xg_gnoff;    /* string table group name offset */
  140.     unsigned short    xg_snoff;    /* string table segment name offset */
  141. };
  142.  
  143.  
  144.  
  145.  
  146. /*
  147.  *    All of the following are provided for compatibility only.
  148.  */
  149.  
  150. struct asym {                /* a.out, modified from struct nlist */
  151.     char        sa_name[8];    /* symbol name */
  152.     unsigned short    sa_type;    /* type flag */
  153.     unsigned short    sa_value;    /* value */
  154. };
  155.  
  156.  
  157. /*    Definitions for asym.sa_type and nlist.n_type.    */
  158.  
  159. #define    N_UNDF    0    /* undefined */
  160. #define    N_ABS    01    /* absolute */
  161. #define    N_TEXT    02    /* text symbol */
  162. #define    N_DATA    03    /* data symbol */
  163. #define    N_BSS    04    /* bss symbol */
  164. #define    N_TYPE    037
  165. #define    N_REG    024    /* register name */
  166. #define    N_FN    037    /* file name symbol */
  167. #define    N_EXT    040    /* external bit, or'ed in */
  168.  
  169.  
  170. struct bsym {            /* b.out, non-portable version of x.out */
  171.     char    sb_type;    /* use definitions for sym.s_type */
  172.     long    sb_value;
  173. };
  174.  
  175.  
  176. /*
  177.  *    Definitions for reloc.r_desc, compatible with bitfield
  178.  *        allocation from the low end of a word (pdp11).
  179.  */
  180.  
  181. #define RD_BTEXT    0x0000
  182. #define RD_BDATA    0x0001
  183. #define RD_BBSS        0x0002
  184. #define RD_BEXT        0x0003
  185. #define RD_BSEG        0x0003
  186.  
  187. #define RD_BBYTE    0x0000
  188. #define RD_BWORD    0x0004
  189. #define RD_BLONG    0x0008
  190. #define RD_BSIZE    0x000c
  191.  
  192. #define RD_BDISP    0x0010
  193.