home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / src / objfmt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-20  |  8.0 KB  |  275 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)objfmt.h    5.4 (Berkeley) 4/16/91
  34.  */
  35.  
  36. /*
  37.  * The size of the display.
  38.  */
  39. #define DSPLYSZ 20
  40.  
  41. /*
  42.  *    The structure of the runtime display
  43.  */
  44. #ifdef OBJ
  45. struct dispsave {
  46.     char *locvars;        /* pointer to local variables */
  47.     struct blockmark *stp;    /* pointer to local stack frame */
  48. };
  49.     /*
  50.      * The following union allows fast access to
  51.      * precomputed display entries
  52.      */
  53. union display {
  54.     struct dispsave frame[DSPLYSZ];
  55.     char *raw[2*DSPLYSZ];
  56. } display;
  57. #endif OBJ
  58. #ifdef PC
  59. #ifdef vax
  60.     /*
  61.      *    the display is made up of saved AP's and FP's.
  62.      *    FP's are used to find locals,
  63.      *    and AP's are used to find parameters.
  64.      *    FP and AP are untyped pointers,
  65.      *    but are used throughout as (char *).
  66.      *    the display is used by adding AP_OFFSET or FP_OFFSET to the 
  67.      *    address of the approriate display entry.
  68.      */
  69.     struct dispsave {
  70.     char    *savedAP;
  71.     char    *savedFP;
  72.     } display[ DSPLYSZ ];
  73.  
  74. #   define    AP_OFFSET    ( 0 )
  75. #   define    FP_OFFSET    ( sizeof (char *) )
  76. #endif vax
  77. #ifdef mc68000
  78.     /*
  79.      *    the display is just the saved a6.
  80.      *    arguments are at positive offsets,
  81.      *    locals are at negative offsets.
  82.      *    there are no offsets within the saved display structure.
  83.      */
  84.     struct dispsave {
  85.     char    *saveda6;
  86.     } display[ DSPLYSZ ];
  87.  
  88. #   define    AP_OFFSET    (0)
  89. #   define    FP_OFFSET    (0)
  90. #endif mc68000
  91. #ifdef tahoe
  92.     /*
  93.      *    the display is just the saved FP.
  94.      *    arguments are at positive offsets,
  95.      *    locals are at negative offsets.
  96.      *    there are no offsets within the saved display structure.
  97.      */
  98.     struct dispsave {
  99.     char    *savedFP;
  100.     } display[ DSPLYSZ ];
  101.  
  102. #   define    AP_OFFSET    0
  103. #   define    FP_OFFSET    0
  104. #endif tahoe
  105. #endif PC
  106.  
  107.     /*
  108.      *    the structure below describes the block mark used by the architecture.
  109.      *    this is the space used by the machine between the arguments and the
  110.      *    whatever is used to point to the arguments.
  111.      */
  112. #ifdef OBJ
  113. struct blockmark {
  114.     char *tos;        /* pointer to top of stack frame */
  115.     struct iorec *file;    /* pointer to active file name */
  116.     struct hdr {
  117.         long framesze;    /* number of bytes of local vars */
  118.         long nargs;    /* number of bytes of arguments */
  119.         long tests;    /* TRUE => perform runtime tests */
  120.         short offset;    /* offset of procedure in source file */
  121.         char name[1];    /* name of active procedure */
  122.     } *entry;
  123.     struct dispsave odisp;    /* previous display value for this level */
  124.     struct dispsave *dp;    /* pointer to active display entry */
  125.     char *pc;        /* previous location counter */
  126.     long lino;        /* previous line number */
  127. };
  128. #endif OBJ
  129. #ifdef PC
  130. #ifdef vax
  131.     /*
  132.      *    since we have the ap pointing to the number of args:
  133.      */
  134.     struct blockmark {
  135.         long    nargs;
  136.     };
  137. #endif vax
  138. #ifdef mc68000
  139.     /*
  140.      *    there's the saved pc (from the jsr)
  141.      *    and the saved a6 (from the link a6).
  142.      */
  143.     struct blockmark {
  144.     char    *savedpc;
  145.     char    *saveda6;
  146.     };
  147. #endif mc68000
  148. #ifdef tahoe
  149.     /*
  150.      *    since we have the fp pointing to its predecessor
  151.      */
  152.     struct blockmark {
  153.     long    savedfp;
  154.     };
  155. #endif tahoe
  156. #endif PC
  157.  
  158.     /*
  159.      *    formal routine structure:
  160.      */
  161. struct formalrtn {
  162.     long        (*fentryaddr)();    /* formal entry point */
  163.     long        fbn;            /* block number of function */
  164.     struct dispsave    fdisp[ DSPLYSZ ];    /* saved at first passing */
  165. };
  166. #ifndef PC
  167. #ifndef OBJ
  168. struct formalrtn    frtn;
  169. #endif
  170. #endif
  171.  
  172. #define    FENTRYOFFSET    0
  173. #define FBNOFFSET    ( FENTRYOFFSET + sizeof frtn.fentryaddr )
  174. #define    FDISPOFFSET    ( FBNOFFSET + sizeof frtn.fbn )
  175.  
  176. #ifdef OBJ
  177.     /*
  178.      *    the creation time, the size and the magic number of the obj file
  179.      */
  180.     struct pxhdr {
  181.         long    maketime;
  182.         long    objsize;
  183.         long    symtabsize;
  184.         short    magicnum;
  185.     };
  186.  
  187. /*
  188.  *    START defines the beginning of the text space.
  189.  *    This should be the defined external label "start",
  190.  *    however there is no way to access externals from C
  191.  *    whose names do not begin with an "_".
  192.  */
  193. #ifdef vax
  194. #   define HEADER_BYTES    2048            /* the size of px_header */
  195. #   define START 0x0                /* beginning of text */
  196. #endif vax
  197. #ifdef tahoe
  198. #   define HEADER_BYTES    2560            /* the size of px_header */
  199. #   define START 0x0                /* beginning of text */
  200. #endif tahoe
  201. #ifdef mc68000
  202. #   define HEADER_BYTES    3072            /* the size of px_header */
  203. #   define START 0x8000                /* beginning of text */
  204. #endif mc68000
  205. #   define INDX 1                /* amt to shift display index */
  206. #endif OBJ
  207.  
  208.         /*
  209.          *    these are because of varying sizes of pointers
  210.          */
  211. #ifdef ADDR16
  212. #    define PTR_AS O_AS2
  213. #    define PTR_RV O_RV2
  214. #    define PTR_IND O_IND2
  215. #    define PTR_CON O_CON2
  216. #    define PTR_DUP O_SDUP2
  217. #    define CON_INT O_CON2
  218. #    define INT_TYP (nl + T2INT)
  219. #    define PTR_DCL char *
  220. #    define TOOMUCH 50000
  221. #    define SHORTADDR 65536
  222. #    define MAXSET 65536        /* maximum set size */
  223. #endif ADDR16
  224. #ifdef ADDR32
  225. #    define PTR_AS O_AS4
  226. #    define PTR_RV O_RV4
  227. #    define PTR_IND O_IND4
  228. #    define PTR_CON O_CON4
  229. #    define PTR_DUP O_SDUP4
  230. #    define CON_INT O_CON24
  231. #    define INT_TYP (nl + T4INT)
  232. #    define PTR_DCL unsigned long        /* for pointer variables */
  233. #    define SHORTADDR 32768            /* maximum short address */
  234. #    define TOOMUCH 65536            /* maximum variable size */
  235. #    define MAXSET 65536            /* maximum set size */
  236. #endif ADDR32
  237.     /*
  238.      * Offsets due to the structure of the runtime stack.
  239.      * DPOFF1    is the amount of fixed storage in each block allocated
  240.      *         as local variables for the runtime system.
  241.      *        since locals are allocated negative offsets,
  242.      *        -DPOFF1 is the last used implicit local offset.
  243.      * DPOFF2    is the size of the block mark.
  244.      *        since arguments are allocated positive offsets,
  245.      *        DPOFF2 is the end of the implicit arguments.
  246.      *        for obj, the first argument has the highest offset
  247.      *        from the stackpointer.  and the block mark is an
  248.      *        implicit last parameter.
  249.      *        for pc, the first argument has the lowest offset
  250.      *        from the argumentpointer.  and the block mark is an
  251.      *        implicit first parameter.
  252.      */
  253. #    ifdef OBJ
  254. #        ifdef ADDR32
  255. #        define MAGICNUM 0403    /* obj magic number */
  256. #        define DPOFF1        0
  257. #        define DPOFF2        (sizeof (struct blockmark))
  258. #        define INPUT_OFF    -8    /* offset of `input' */
  259. #        define OUTPUT_OFF    -4    /* offset of `output' */
  260. #        endif ADDR32
  261. #        ifdef ADDR16
  262. #        define MAGICNUM 0404
  263. #        define DPOFF1        0
  264. #        define DPOFF2        (sizeof (struct blockmark))
  265. #        define INPUT_OFF    -2
  266. #        define OUTPUT_OFF    -4
  267. #        endif ADDR16
  268. #    endif OBJ
  269. #    ifdef    PC
  270. #        define DPOFF1    ( sizeof (struct rtlocals) )
  271. #        define DPOFF2    ( sizeof (struct blockmark) )
  272. #        define INPUT_OFF    0
  273. #        define OUTPUT_OFF    0
  274. #    endif PC
  275.