1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)objfmt.h 5.2 (Berkeley) 11/11/86 7 */ 8 9 /* 10 * The size of the display. 11 */ 12 #define DSPLYSZ 20 13 14 /* 15 * The structure of the runtime display 16 */ 17 #ifdef OBJ 18 struct dispsave { 19 char *locvars; /* pointer to local variables */ 20 struct blockmark *stp; /* pointer to local stack frame */ 21 }; 22 /* 23 * The following union allows fast access to 24 * precomputed display entries 25 */ 26 union display { 27 struct dispsave frame[DSPLYSZ]; 28 char *raw[2*DSPLYSZ]; 29 } display; 30 #endif OBJ 31 #ifdef PC 32 #ifdef vax 33 /* 34 * the display is made up of saved AP's and FP's. 35 * FP's are used to find locals, 36 * and AP's are used to find parameters. 37 * FP and AP are untyped pointers, 38 * but are used throughout as (char *). 39 * the display is used by adding AP_OFFSET or FP_OFFSET to the 40 * address of the approriate display entry. 41 */ 42 struct dispsave { 43 char *savedAP; 44 char *savedFP; 45 } display[ DSPLYSZ ]; 46 47 # define AP_OFFSET ( 0 ) 48 # define FP_OFFSET ( sizeof (char *) ) 49 #endif vax 50 #ifdef mc68000 51 /* 52 * the display is just the saved a6. 53 * arguments are at positive offsets, 54 * locals are at negative offsets. 55 * there are no offsets within the saved display structure. 56 */ 57 struct dispsave { 58 char *saveda6; 59 } display[ DSPLYSZ ]; 60 61 # define AP_OFFSET (0) 62 # define FP_OFFSET (0) 63 #endif mc68000 64 #ifdef tahoe 65 /* 66 * the display is just the saved FP. 67 * arguments are at positive offsets, 68 * locals are at negative offsets. 69 * there are no offsets within the saved display structure. 70 */ 71 struct dispsave { 72 char *savedFP; 73 } display[ DSPLYSZ ]; 74 75 # define AP_OFFSET 0 76 # define FP_OFFSET 0 77 #endif tahoe 78 #endif PC 79 80 /* 81 * the structure below describes the block mark used by the architecture. 82 * this is the space used by the machine between the arguments and the 83 * whatever is used to point to the arguments. 84 */ 85 #ifdef OBJ 86 struct blockmark { 87 char *tos; /* pointer to top of stack frame */ 88 struct iorec *file; /* pointer to active file name */ 89 struct hdr { 90 long framesze; /* number of bytes of local vars */ 91 long nargs; /* number of bytes of arguments */ 92 long tests; /* TRUE => perform runtime tests */ 93 short offset; /* offset of procedure in source file */ 94 char name[1]; /* name of active procedure */ 95 } *entry; 96 struct dispsave odisp; /* previous display value for this level */ 97 struct dispsave *dp; /* pointer to active display entry */ 98 char *pc; /* previous location counter */ 99 long lino; /* previous line number */ 100 }; 101 #endif OBJ 102 #ifdef PC 103 #ifdef vax 104 /* 105 * since we have the ap pointing to the number of args: 106 */ 107 struct blockmark { 108 long nargs; 109 }; 110 #endif vax 111 #ifdef mc68000 112 /* 113 * there's the saved pc (from the jsr) 114 * and the saved a6 (from the link a6). 115 */ 116 struct blockmark { 117 char *savedpc; 118 char *saveda6; 119 }; 120 #endif mc68000 121 #ifdef tahoe 122 /* 123 * since we have the fp pointing to its predecessor 124 */ 125 struct blockmark { 126 long savedfp; 127 }; 128 #endif tahoe 129 #endif PC 130 131 /* 132 * formal routine structure: 133 */ 134 struct formalrtn { 135 long (*fentryaddr)(); /* formal entry point */ 136 long fbn; /* block number of function */ 137 struct dispsave fdisp[ DSPLYSZ ]; /* saved at first passing */ 138 }; 139 #ifndef PC 140 #ifndef OBJ 141 struct formalrtn frtn; 142 #endif 143 #endif 144 145 #define FENTRYOFFSET 0 146 #define FBNOFFSET ( FENTRYOFFSET + sizeof frtn.fentryaddr ) 147 #define FDISPOFFSET ( FBNOFFSET + sizeof frtn.fbn ) 148 149 #ifdef OBJ 150 /* 151 * the creation time, the size and the magic number of the obj file 152 */ 153 struct pxhdr { 154 long maketime; 155 long objsize; 156 long symtabsize; 157 short magicnum; 158 }; 159 160 /* 161 * START defines the beginning of the text space. 162 * This should be the defined external label "start", 163 * however there is no way to access externals from C 164 * whose names do not begin with an "_". 165 */ 166 #ifdef vax 167 # define HEADER_BYTES 2048 /* the size of px_header */ 168 # define START 0x0 /* beginning of text */ 169 #endif vax 170 #ifdef tahoe 171 # define HEADER_BYTES 2048 /* the size of px_header */ 172 # define START 0x0 /* beginning of text */ 173 #endif tahoe 174 #ifdef mc68000 175 # define HEADER_BYTES 3072 /* the size of px_header */ 176 # define START 0x8000 /* beginning of text */ 177 #endif mc68000 178 # define INDX 1 /* amt to shift display index */ 179 #endif OBJ 180 181 /* 182 * these are because of varying sizes of pointers 183 */ 184 #ifdef ADDR16 185 # define PTR_AS O_AS2 186 # define PTR_RV O_RV2 187 # define PTR_IND O_IND2 188 # define PTR_CON O_CON2 189 # define PTR_DUP O_SDUP2 190 # define CON_INT O_CON2 191 # define INT_TYP (nl + T2INT) 192 # define PTR_DCL char * 193 # define TOOMUCH 50000 194 # define SHORTADDR 65536 195 # define MAXSET 65536 /* maximum set size */ 196 #endif ADDR16 197 #ifdef ADDR32 198 # define PTR_AS O_AS4 199 # define PTR_RV O_RV4 200 # define PTR_IND O_IND4 201 # define PTR_CON O_CON4 202 # define PTR_DUP O_SDUP4 203 # define CON_INT O_CON24 204 # define INT_TYP (nl + T4INT) 205 # define PTR_DCL unsigned long /* for pointer variables */ 206 # define SHORTADDR 32768 /* maximum short address */ 207 # define TOOMUCH 65536 /* maximum variable size */ 208 # define MAXSET 65536 /* maximum set size */ 209 #endif ADDR32 210 /* 211 * Offsets due to the structure of the runtime stack. 212 * DPOFF1 is the amount of fixed storage in each block allocated 213 * as local variables for the runtime system. 214 * since locals are allocated negative offsets, 215 * -DPOFF1 is the last used implicit local offset. 216 * DPOFF2 is the size of the block mark. 217 * since arguments are allocated positive offsets, 218 * DPOFF2 is the end of the implicit arguments. 219 * for obj, the first argument has the highest offset 220 * from the stackpointer. and the block mark is an 221 * implicit last parameter. 222 * for pc, the first argument has the lowest offset 223 * from the argumentpointer. and the block mark is an 224 * implicit first parameter. 225 */ 226 # ifdef OBJ 227 # ifdef ADDR32 228 # define MAGICNUM 0403 /* obj magic number */ 229 # define DPOFF1 0 230 # define DPOFF2 (sizeof (struct blockmark)) 231 # define INPUT_OFF -8 /* offset of `input' */ 232 # define OUTPUT_OFF -4 /* offset of `output' */ 233 # endif ADDR32 234 # ifdef ADDR16 235 # define MAGICNUM 0404 236 # define DPOFF1 0 237 # define DPOFF2 (sizeof (struct blockmark)) 238 # define INPUT_OFF -2 239 # define OUTPUT_OFF -4 240 # endif ADDR16 241 # endif OBJ 242 # ifdef PC 243 # define DPOFF1 ( sizeof (struct rtlocals) ) 244 # define DPOFF2 ( sizeof (struct blockmark) ) 245 # define INPUT_OFF 0 246 # define OUTPUT_OFF 0 247 # endif PC 248