1: #include "defs.h"
   2: #include <sys/file.h>
   3: 
   4:     MAP txtmap;
   5:     MAP datmap;
   6:     int wtflag;
   7:     int kernel;
   8:     int fcor;
   9:     int fsym;
  10:     long    maxfile;
  11:     long    maxstor;
  12:     long    txtsiz;
  13:     long    datsiz;
  14:     long    bss;
  15:     long    datbas;
  16:     long    stksiz;
  17:     char    *errflg;
  18:     int magic;
  19:     long    entrypt;
  20:     long    var[];
  21:     int argcount;
  22:     int signo;
  23:     u_int   corhdr[ctob(USIZE)/sizeof(u_int)];
  24:     u_int   *uar0 = UAR0;
  25:     char    *symfil  = "a.out";
  26:     char    *corfil  = "core";
  27:     struct  ovlhdr  ovlseg;
  28:     long    ovlsiz;
  29:     long    ovloff[NOVL+1];
  30:     char    startov;
  31:     int overlay;
  32:     off_t   symoff, stroff;
  33: 
  34: setsym()
  35: {
  36:     struct  xexec   hdr;
  37:     int ovly;
  38: 
  39:     bzero(&txtmap, sizeof (txtmap));
  40:     fsym=getfile(symfil,1);
  41:     txtmap.ufd=fsym;
  42: 
  43:     if  (read(fsym, &hdr, sizeof (hdr)) >= (int)sizeof (hdr.e))
  44:         {
  45:         magic= hdr.e.a_magic;
  46:         txtsiz = hdr.e.a_text;
  47:         datsiz = hdr.e.a_data;
  48:         bss = hdr.e.a_bss;
  49:         entrypt = hdr.e.a_entry;
  50: 
  51:         txtmap.f1 = N_TXTOFF(hdr.e);
  52:         symoff = N_SYMOFF(hdr);
  53:         stroff = N_STROFF(hdr);
  54: 
  55:         switch (magic)
  56:             {
  57:             case 0407:
  58:                 txtmap.e1 = txtmap.e2 = txtsiz+datsiz;
  59:                 txtmap.f2 = txtmap.f1;
  60:                 break;
  61:             case 0410:
  62:                 txtmap.e1 = txtsiz;
  63:                 txtmap.b2 = round(txtsiz, TXTRNDSIZ);
  64:                 txtmap.e2 = txtmap.b2+datsiz;
  65:                 txtmap.f2 = txtsiz + txtmap.f1;
  66:                 break;
  67:             case 0405:
  68:             case 0411:
  69:                 txtmap.e1 = txtsiz;
  70:                 txtmap.e2 = datsiz;
  71:                 txtmap.f2 = txtsiz + txtmap.f1;
  72:                 break;
  73:             case 0430:
  74:             case 0431:
  75:                 ovlseg = hdr.o;
  76:                 txtmap.e1 = txtsiz;
  77:                 txtmap.bo = round(txtsiz, TXTRNDSIZ);
  78:                 FOR ovly = 0; ovly < NOVL; ovly++
  79:                 DO      ovloff[ovly] = ovlsiz + txtsiz
  80:                         + txtmap.f1;
  81:                     ovlsiz += ovlseg.ov_siz[ovly];
  82:                 OD
  83:                 IF magic == 0430
  84:                 THEN    txtmap.b2 =
  85:                     round(txtmap.bo+(long)ovlseg.max_ovl, TXTRNDSIZ);
  86:                 FI
  87:                 txtmap.f2 = txtmap.f1 + txtsiz+ovlsiz;
  88:                 txtmap.e2 = txtmap.b2 + datsiz;
  89:                 overlay = 1;
  90:                 break;
  91:             default:
  92:                 magic = 0;
  93:                 txtsiz = 0;
  94:                 datsiz = 0;
  95:                 bss = 0;
  96:                 entrypt = 0;
  97:             }
  98:         datbas = txtmap.b2;
  99:         symINI(&hdr);
 100:         }
 101:     IF magic==0 THEN txtmap.e1=maxfile; FI
 102: }
 103: 
 104: setcor()
 105: {
 106:     fcor=getfile(corfil,2);
 107:     datmap.ufd=fcor;
 108:     IF read(fcor, corhdr, sizeof corhdr)==sizeof corhdr
 109:     THEN    IF !kernel
 110:         THEN    txtsiz = ((U*)corhdr)->u_tsize << 6;
 111:             datsiz = ((U*)corhdr)->u_dsize << 6;
 112:             stksiz = ((U*)corhdr)->u_ssize << 6;
 113:             datmap.f1 = ctob(USIZE);
 114:             datmap.b2 = maxstor-stksiz;
 115:             datmap.e2 = maxstor;
 116:         ELSE    datsiz = round(datsiz+bss,64L);
 117:             stksiz = (long) ctob(USIZE);
 118:             datmap.f1 = 0;
 119:             datmap.b2 = 0140000L;
 120:             datmap.e2 = 0140000L + ctob(USIZE);
 121:         FI
 122:         switch (magic)
 123:             {
 124:             case 0407:
 125:                 datmap.b1 = 0;
 126:                 datmap.e1 = txtsiz+datsiz;
 127:                 IF kernel
 128:                 THEN    datmap.f2 = (long)corhdr[KA6] *
 129:                         0100L;
 130:                 ELSE    datmap.f2 = ctob(USIZE)+txtsiz+datsiz;
 131:                 FI
 132:                 break;
 133: 
 134:             case 0410:
 135:                 datmap.b1 = round(txtsiz, TXTRNDSIZ);
 136:                 datmap.e1 = datmap.b1+datsiz;
 137:                 datmap.f2 = datsiz+ctob(USIZE);
 138:                 break;
 139: 
 140:             case 0405:
 141:             case 0411:
 142:             case 0431:
 143:                 datmap.b1 = 0;
 144:                 datmap.e1 = datsiz;
 145:                 IF kernel
 146:                 THEN datmap.f2 = (long)corhdr[KA6] *
 147:                     0100L;
 148:                 ELSE datmap.f2 = datsiz+ctob(USIZE);
 149:                 FI
 150:                 break;
 151: 
 152:             case 0430:
 153:                 datmap.b1 = round(round(txtsiz,
 154:                     TXTRNDSIZ)+ovlseg.max_ovl,
 155:                     TXTRNDSIZ);
 156:                 datmap.e1 = datmap.b1+datsiz;
 157:                 IF kernel
 158:                 THEN    datmap.b1 = 0;
 159:                     datmap.f2 = (long)corhdr[KA6] *
 160:                         0100L;
 161:                 ELSE    datmap.f2 = datsiz+ctob(USIZE);
 162:                 FI
 163:                 break;
 164: 
 165:             default:
 166:                 magic = 0;
 167:                 datmap.b1 = 0;
 168:                 datmap.e1 = maxfile;
 169:                 datmap.f1 = 0;
 170:                 datmap.b2 = 0;
 171:                 datmap.e2 = 0;
 172:                 datmap.f2 = 0;
 173:             }
 174:         datbas = datmap.b1;
 175:         if (!kernel && magic) {
 176:             /*
 177: 			 * Note that we can no longer compare the magic
 178: 			 * number of the core against that of the object
 179: 			 * since the user structure no longer contains
 180: 			 * the exec header ...
 181: 			 */
 182:             register u_int *ar0;
 183:             ar0 = (u_int *)(((U *)corhdr)->u_ar0);
 184:             if (ar0 > (u_int *)0140000
 185:                 && ar0 < (u_int *)(0140000 + ctob(USIZE))
 186:                 && !((unsigned)ar0&01))
 187:                 uar0 = (u_int *)&corhdr[ar0-(u_int *)0140000];
 188:             if (overlay) {
 189:                 startov = ((U *)corhdr)->u_ovdata.uo_curov;
 190:                 var[VARC] = (long)startov;
 191:                 setovmap(startov);
 192:             }
 193:             /* else dig out __ovno if overlaid? */
 194:         }
 195:     ELSE    datmap.e1 = maxfile;
 196:     FI
 197: }
 198: 
 199: getfile(filnam,cnt)
 200:     char    *filnam;
 201:     int cnt;
 202: {
 203:     register int f;
 204: 
 205:     IF strcmp("-",filnam)
 206:     THEN    f = open(filnam,wtflag);
 207:         IF f < 0 ANDF argcount>cnt
 208:         THEN    IF wtflag
 209:             THEN    f = open(filnam, O_CREAT|O_TRUNC|wtflag,644);
 210:             FI
 211:             IF f < 0
 212:             THEN printf("cannot open `%s'\n", filnam);
 213:             FI
 214:         FI
 215:     ELSE    f = -1;
 216:     FI
 217:     return(f);
 218: }

Defined functions

getfile defined in line 199; used 2 times
setcor defined in line 104; used 2 times
setsym defined in line 34; used 1 times

Defined variables

argcount defined in line 21; used 1 times
bss defined in line 14; used 3 times
corfil defined in line 26; used 1 times
corhdr defined in line 23; used 12 times
datbas defined in line 15; used 2 times
datmap defined in line 5; used 33 times
datsiz defined in line 13; used 17 times
entrypt defined in line 19; used 2 times
errflg defined in line 17; never used
fcor defined in line 8; used 3 times
fsym defined in line 9; used 3 times
kernel defined in line 7; used 5 times
magic defined in line 18; used 8 times
maxfile defined in line 10; used 3 times
maxstor defined in line 11; used 2 times
overlay defined in line 31; used 2 times
ovloff defined in line 29; used 1 times
  • in line 79
ovlseg defined in line 27; used 4 times
ovlsiz defined in line 28; used 3 times
signo defined in line 22; never used
startov defined in line 30; used 3 times
stksiz defined in line 16; used 3 times
stroff defined in line 32; used 1 times
  • in line 53
symfil defined in line 25; used 2 times
symoff defined in line 32; used 1 times
  • in line 52
txtmap defined in line 4; used 29 times
txtsiz defined in line 12; used 17 times
uar0 defined in line 24; used 1 times
var defined in line 20; used 1 times
wtflag defined in line 6; used 3 times
Last modified: 1993-12-31
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 110
Valid CSS Valid XHTML 1.0 Strict