|
|
1.1 ! root 1: static char ID[] = "@(#) display.c: 1.1 1/9/82"; ! 2: ! 3: #include <stdio.h> ! 4: #include "structs.h" ! 5: #include "extrns.h" ! 6: #include "tv.h" ! 7: #include "ldtv.h" ! 8: #include "y.tab.h" ! 9: ! 10: char *DS[] = { ! 11: "** BAD 0 **", ! 12: "** BAD 1 **", ! 13: "** BAD 2 **", ! 14: "AILDFILE", ! 15: "AILDLBRY", ! 16: "AIEVEXPR", ! 17: "AIDFNSCN", ! 18: "AIADDSCN", ! 19: "AIADFILE", ! 20: "AIBOND", ! 21: "AIDFOWNR", ! 22: "AIOWNATR", ! 23: "AIDFNGRP", ! 24: "AIDFNSYM" ! 25: }; ! 26: char *OP[] = { ! 27: "** BAD OP 0 **", ! 28: "** BAD OP 1 **", ! 29: "NAME", ! 30: "LONGINT", ! 31: "INT", ! 32: "ALIGN", ! 33: "DOT", ! 34: "LEN", ! 35: "MEMORY", ! 36: "ORG", ! 37: "REGIONS", ! 38: "SECTIONS", ! 39: "PHY", ! 40: "AND", ! 41: "ANDAND", ! 42: "BNOT", ! 43: "COLON", ! 44: "COMMA", ! 45: "DIV", ! 46: "EQ", ! 47: "EQEQ", ! 48: "GE", ! 49: "** BAD OP 22 **", ! 50: "GT", ! 51: "LBRACE", ! 52: "** BAD OP 25 **", ! 53: "LE", ! 54: "LPAREN", ! 55: "LSHIFT", ! 56: "LT", ! 57: "MINUS", ! 58: "MULT", ! 59: "NE", ! 60: "NOT", ! 61: "OR", ! 62: "OROR", ! 63: "PC", ! 64: "PLUS", ! 65: "RBRACE", ! 66: "RPAREN", ! 67: "RSHIFT", ! 68: "SEMICOL", ! 69: "DIVEQ", ! 70: "MINUSEQ", ! 71: "MULTEQ", ! 72: "PLUSEQ", ! 73: "FILENAME", ! 74: "TV", ! 75: "SPARE", ! 76: "DSECT", ! 77: "NOLOAD", ! 78: "BLOCK", ! 79: "UMINUS", ! 80: "GROUP" ! 81: }; ! 82: /*eject*/ ! 83: main(argc,argv) ! 84: int argc; ! 85: char *argv[]; ! 86: { ! 87: ! 88: /* ! 89: * List a ld "intermediate file" ! 90: */ ! 91: ! 92: /* ! 93: * Open the "transfer file" ! 94: */ ! 95: ! 96: if( (trnfdes = fopen( argv[1], "r" )) == NULL ) { ! 97: printf( "\nFailure in opening the transfer file %s\n", ! 98: argv[1] ); ! 99: exit( 1 ); ! 100: } ! 101: printf( "\nStart of ld lister program for file %s\n", argv[1] ); ! 102: ! 103: /* ! 104: * List the file ! 105: */ ! 106: ! 107: lst_tf_hdr(); ! 108: lst_tf(); ! 109: ! 110: printf( "\nEnd of ld lister program\n" ); ! 111: } ! 112: /*eject*/ ! 113: lst_tf_hdr() ! 114: { ! 115: ! 116: /* ! 117: * Read and print control and descriptor information ! 118: */ ! 119: ! 120: fseek( trnfdes, 0L, 0 ); ! 121: ! 122: /* ! 123: * Print the sizes of the lists built during PASS 1 ! 124: * ! 125: * 1. define symbol directives ! 126: * 2. MEMORY directives ! 127: * 3. REGIONS directives ! 128: * 4. input *.o and archive library files ! 129: * 5. output sections ! 130: * 6. assignment directives ! 131: */ ! 132: ! 133: fread( &symcnt, sizeof(int), 1, trnfdes ); ! 134: fread( &memcnt, sizeof(int), 1, trnfdes ); ! 135: fread( ®cnt, sizeof(int), 1, trnfdes ); ! 136: fread( &ldfcnt, sizeof(int), 1, trnfdes ); ! 137: fread( &bldcnt, sizeof(int), 1, trnfdes ); ! 138: fread( &expcnt, sizeof(int), 1, trnfdes ); ! 139: fread( &tvslotcnt, sizeof(int), 1, trnfdes ); ! 140: ! 141: printf( "\nList sizes:\n\tSYM: %d MEM: %d REG: %d LDF : %d BLD: %d EXP : %d TV : %d\n", ! 142: symcnt, memcnt, regcnt, ldfcnt, bldcnt, expcnt, tvslotcnt ); ! 143: ! 144: /* ! 145: * Print the ld control flags ! 146: */ ! 147: ! 148: fread( &aflag, sizeof(char), 1, trnfdes ); ! 149: fread( &cflag, sizeof(char), 1, trnfdes ); ! 150: fread( &dflag, sizeof(char), 1, trnfdes ); ! 151: fread( &iflag, sizeof(char), 1, trnfdes ); ! 152: fread( &mflag, sizeof(char), 1, trnfdes ); ! 153: fread( &rflag, sizeof(char), 1, trnfdes ); ! 154: fread( &sflag, sizeof(char), 1, trnfdes ); ! 155: fread( &tvflag, sizeof(char), 1, trnfdes ); ! 156: fread( &Hflag, sizeof(char), 1, trnfdes ); ! 157: fread( &Sflag, sizeof(char), 1, trnfdes ); ! 158: fread( &Vflag, sizeof(char), 1, trnfdes ); ! 159: fread( &Xflag, sizeof(char), 1, trnfdes ); ! 160: fread( &hflag, sizeof(int), 1, trnfdes ); ! 161: fread( &pflag, sizeof(int), 1, trnfdes ); ! 162: fread( &Bflag, sizeof(int), 1, trnfdes ); ! 163: #if U3B ! 164: fread( &xflag, sizeof(char), 1, trnfdes ); ! 165: ! 166: printf( "\nFlag values:\n\ta c d i m p r s x tv H O S V h B" ); ! 167: printf( "\n\t%d %d %d %d %d %d %d %d %d %d %d %d %d %d %04x %04x\n", ! 168: aflag,cflag,dflag,iflag,mflag,pflag,rflag,sflag,xflag,tvflag,Hflag, ! 169: Xflag,Sflag,Vflag,hflag,Bflag); ! 170: #else ! 171: printf( "\nFlag values:\n\ta c d i m p r s tv H S V X h B" ); ! 172: printf( "\n\t%d %d %d %d %d %d %d %d %d %d %d %d %d %04x %04x\n", ! 173: aflag,cflag,dflag,iflag,mflag,pflag,rflag,sflag,tvflag,Hflag, ! 174: Sflag,Vflag,Xflag,hflag,Bflag); ! 175: #endif ! 176: ! 177: /* ! 178: * Print various values extracted from the parse ! 179: */ ! 180: ! 181: fread( &globfill, sizeof(short), 1, trnfdes ); ! 182: fread( &magic, sizeof(unsigned short), 1, trnfdes ); ! 183: fread( outfilnm, 128, 1, trnfdes ); ! 184: fread( epsymbol, 8, 1, trnfdes ); ! 185: fread( &tvspec, sizeof(TVINFO), 1, trnfdes ); ! 186: ! 187: printf( "\nControl values:\n\tglobal fill: %04x magic: %04x a.out: (%.128s) ep: (%.8s)", ! 188: globfill, magic, outfilnm, epsymbol ); ! 189: #if B16 || X86 ! 190: printf( "\n\ttv: %04x (%8.8s) (%04x,%04x) (%04x) %d %d %08lx (%04x,%04x)\n", ! 191: tvspec.tvosptr, tvspec.tvfnfill, tvspec.tvfill.tv_ip, ! 192: tvspec.tvfill.tv_cs, tvspec.tvinflnm, tvspec.tvinlnno, ! 193: tvspec.tvlength, tvspec.tvbndadr, tvspec.tvrange[0], ! 194: tvspec.tvrange[1] ); ! 195: #else ! 196: printf( "\n\ttv: %04x (%8.8s) (%08lx) (%04x) %d %d %08lx (%04x,%04x)\n", ! 197: tvspec.tvosptr, tvspec.tvfnfill, tvspec.tvfill.tv_addr, ! 198: tvspec.tvinflnm, tvspec.tvinlnno, ! 199: tvspec.tvlength, tvspec.tvbndadr, tvspec.tvrange[0], ! 200: tvspec.tvrange[1] ); ! 201: #endif ! 202: ! 203: ! 204: /* ! 205: * Print the siza of the saved strings ! 206: */ ! 207: ! 208: fread( &strleng, sizeof(int), 1, trnfdes ); ! 209: ! 210: printf( "\nString area length: %d\n", strleng ); ! 211: } ! 212: /*eject*/ ! 213: lst_tf() ! 214: { ! 215: ! 216: /* ! 217: * Print the bulk of the information extracted from PASS 1: ! 218: * ! 219: * 1. The names of input ifiles, input *.o and archive files, and ! 220: * output sections ! 221: * 2. The data structures describing the ld directives ! 222: */ ! 223: ! 224: extern char *calloc(); ! 225: /* ! 226: * 1. Read and print saved strings ! 227: */ ! 228: ! 229: strbase = calloc(1,strleng); ! 230: fread( strbase, 1, strleng, trnfdes ); ! 231: ! 232: strnext = strbase; ! 233: strlimit = strbase + strleng; ! 234: printf( "\nSaved strings:" ); ! 235: while( strnext < strlimit ) { ! 236: printf( "\n\t%5d : (%s)", (strnext-strbase), strnext ); ! 237: while( *strnext++ ) ! 238: ; ! 239: } ! 240: printf( "\n" ); ! 241: ! 242: /* ! 243: * 2a. Read and print DFNSYM data structures ! 244: */ ! 245: ! 246: printf( "\nDFNSYM data structures:" ); ! 247: while( symcnt-- ) ! 248: prtds1(); ! 249: printf( "\n" ); ! 250: ! 251: /* ! 252: * 2b. Read and print MEMTYPE data structures ! 253: */ ! 254: ! 255: printf( "\nMEMTYPE data structures:" ); ! 256: while( memcnt-- ) ! 257: prtds2(); ! 258: printf( "\n" ); ! 259: ! 260: /* ! 261: * 2c. Read and print REGION data structures ! 262: */ ! 263: ! 264: printf( "\nREGION data structures:" ); ! 265: while( regcnt-- ) ! 266: prtds3(); ! 267: printf( "\n" ); ! 268: ! 269: /* ! 270: * 2d. Read and print information on input *.o and archive library files ! 271: */ ! 272: ! 273: printf( "\nLDFILE data structures:" ); ! 274: while( ldfcnt-- ) ! 275: prtds4(); ! 276: printf( "\n" ); ! 277: ! 278: ! 279: /* ! 280: * 2e. Read and print information on output sections ! 281: */ ! 282: ! 283: printf( "\nBLDOSCN data structures:" ); ! 284: while( bldcnt-- ) ! 285: prtds5(); ! 286: ! 287: printf( "\n" ); ! 288: ! 289: /* ! 290: * 2e. Read and print information on assignments ! 291: */ ! 292: ! 293: printf( "\nEVEXPR data structures:" ); ! 294: while( expcnt-- ) ! 295: prtds10(); ! 296: printf( "\n" ); ! 297: ! 298: /* ! 299: * 2f. Read and print information on tv slot assignments ! 300: */ ! 301: ! 302: printf( "\nTVASSIGN data structures:" ); ! 303: while( tvslotcnt-- ) ! 304: prtds11(); ! 305: printf( "\n" ); ! 306: } ! 307: /*eject*/ ! 308: prtds1() ! 309: { ! 310: /* ! 311: * Read and print one DFNSYM data structure ! 312: */ ! 313: ! 314: ACTITEM a; ! 315: ! 316: fread( &a, 1, sizeof(ACTITEM), trnfdes ); ! 317: ! 318: printf( "\n\t%04x %s (%s) %d (%s) %s %08lx", ! 319: a.dfnsym.ainext, DS[a.dfnsym.aitype], (strbase+a.dfnsym.aiinflnm), ! 320: a.dfnsym.aiinlnno, (strbase+a.dfnsym.aisymbol), ! 321: (a.dfnsym.aideflag ? "DEF" : "UNDEF"), a.dfnsym.aidefval ); ! 322: } ! 323: prtds2() ! 324: { ! 325: /* ! 326: * Read and print one MEMTYPE data structure ! 327: */ ! 328: ! 329: MEMTYPE m; ! 330: ! 331: fread( &m, 1, sizeof(MEMTYPE), trnfdes ); ! 332: ! 333: printf( "\n\t%04x (%8.8s) %08lx %08lx %d %04x %04x", ! 334: m.mtnext, m.mtname, m.mtorig, m.mtlength, m.mtattr, ! 335: m.mtaddrhd, m.mtaddrtl ); ! 336: } ! 337: prtds3() ! 338: { ! 339: /* ! 340: * Read and print one REGION data structure ! 341: */ ! 342: ! 343: REGION r; ! 344: ! 345: fread( &r, 1, sizeof(REGION), trnfdes ); ! 346: ! 347: printf( "\n\t%04x (%8.8s) %08lx %08lx %08lx %04x %04x", ! 348: r.rgnext, r.rgname, r.rgorig, r.rglength, r.rgvaddr, ! 349: r.rgaddrhd, r.rgaddrtl ); ! 350: } ! 351: prtds4() ! 352: { ! 353: /* ! 354: * Read and print one AILDFILE or AILDLBRY data structure ! 355: */ ! 356: ! 357: ACTITEM a; ! 358: ! 359: fread( &a, 1, sizeof(ACTITEM), trnfdes ); ! 360: ! 361: printf( "\n\t%04x %s (%s) %d (%s)", ! 362: a.ldlbry.ainext, DS[a.ldlbry.aitype], (strbase+a.ldlbry.aiinflnm), ! 363: a.ldlbry.aiinlnno, (strbase+a.ldlbry.aifilnam) ); ! 364: } ! 365: prtds5() ! 366: { ! 367: /* ! 368: * Read and print one AIDFNSCN or AIDFNGRP data structure ! 369: */ ! 370: ! 371: ACTITEM a, b; ! 372: ! 373: fread( &a, 1, sizeof(ACTITEM), trnfdes ); ! 374: ! 375: printf( "\n\t%s%04x %s (%s) %d (%s) %04x (%s)\n\t\t\t%08lx %d %08lx %08lx %d %d (%04x,%04x)", ! 376: (a.dfnscn.aitype == AIDFNSCN) ? " " : "", ! 377: a.dfnscn.ainext, DS[a.dfnscn.aitype], (strbase+a.dfnscn.aiinflnm), ! 378: a.dfnscn.aiinlnno, a.dfnscn.ainame, a.dfnscn.aifill, ! 379: a.dfnscn.aiowname, a.dfnscn.aibndadr, a.dfnscn.aiattown, ! 380: a.dfnscn.aialign, a.dfnscn.aiblock, (unsigned) a.dfnscn.aifillfg, ! 381: (unsigned) a.dfnscn.aisctype, a.dfnscn.sectspec.head, a.dfnscn.sectspec.tail ); ! 382: ! 383: switch( a.dfnscn.aitype ) { ! 384: case AIDFNSCN: ! 385: if( ! a.dfnscn.sectspec.head ) ! 386: return; ! 387: do { ! 388: fread( &b, 1, sizeof(ACTITEM), trnfdes ); ! 389: switch( b.adfile.aitype ) { ! 390: case AIADDSCN: ! 391: prtds6(&b); ! 392: if( b.addscn.ainext ) ! 393: break; ! 394: return; ! 395: case AIADFILE: ! 396: prtds7(&b); ! 397: if( b.adfile.ainext || b.adfile.ainadscs ) ! 398: break; ! 399: return; ! 400: case AIEVEXPR: ! 401: prtds8(&b, 1); ! 402: if( b.evexpr.ainext ) ! 403: break; ! 404: return; ! 405: default: ! 406: printf( "\n***** failure listing an AIDFNSCN data structure\n"); ! 407: return; ! 408: } ! 409: } ! 410: while( 1 ); ! 411: break; ! 412: case AIDFNGRP: ! 413: do { ! 414: fread( &b, 1, sizeof(ACTITEM), trnfdes ); ! 415: switch( b.dfnscn.aitype ) { ! 416: case AIDFNSCN: ! 417: fseek( trnfdes, (long) -sizeof(ACTITEM), 1 ); ! 418: prtds5(); ! 419: if( b.dfnscn.ainext ) ! 420: break; ! 421: return; ! 422: default: ! 423: printf( "\n***** failure listing an AIDFNGRP data structure\n"); ! 424: return; ! 425: } ! 426: } ! 427: while( 1 ); ! 428: break; ! 429: default: ! 430: printf( "\n***** failure listing an AIDFNxxx data structure\n"); ! 431: } ! 432: ! 433: } ! 434: /*eject*/ ! 435: prtds6(a) ! 436: ACTITEM *a; ! 437: { ! 438: /* ! 439: * Print one AIADDSCN data structure ! 440: */ ! 441: ! 442: printf( "\n\t\t %04x %s (%s) %d (%s) %04x (%s)", ! 443: a->addscn.ainext, DS[a->addscn.aitype], (strbase+a->addscn.aiinflnm), ! 444: a->addscn.aiinlnno, a->addscn.ainame, a->addscn.aifill, ! 445: (strbase+a->addscn.aiscfile) ); ! 446: } ! 447: prtds7(a) ! 448: ACTITEM *a; ! 449: { ! 450: /* ! 451: * Print one AIADFILE data structure ! 452: */ ! 453: ! 454: printf( "\n\t\t%04x %s (%s) %d (%s) %d %d %d", ! 455: a->adfile.ainext, DS[a->adfile.aitype], (strbase+a->adfile.aiinflnm), ! 456: a->adfile.aiinlnno, (strbase+a->adfile.aifilnam), a->adfile.ainadscs, ! 457: a->adfile.aifill2, (unsigned) a->adfile.aifilflg ); ! 458: } ! 459: prtds8(a, type) ! 460: ACTITEM *a; ! 461: int type; ! 462: { ! 463: /* ! 464: * Print one AIEVEXPR data structure ! 465: */ ! 466: ENODE e; ! 467: ! 468: printf( "\n\t%s%04x %s (%s) %d %04x\n\n\t\tROOT:", ! 469: (type == 1) ? " " : "", ! 470: a->evexpr.ainext, DS[a->evexpr.aitype], (strbase+a->evexpr.aiinflnm), ! 471: a->evexpr.aiinlnno, a->evexpr.aiexptr ); ! 472: ! 473: fread( &e, 1, sizeof(ENODE), trnfdes ); ! 474: ! 475: prtds9(&e); ! 476: printf( "\n" ); ! 477: } ! 478: prtds9(e) ! 479: ENODE *e; ! 480: { ! 481: /* ! 482: * Print one ENODE data structure ! 483: */ ! 484: ENODE f; ! 485: ! 486: switch( (unsigned) e->gnode.exop ) { ! 487: case INT: ! 488: printf( "\n\t\t\tINT %08lx", e->vnode.exvalue ); ! 489: break; ! 490: case DOT: ! 491: printf( "\n\t\t\tDOT ()" ); ! 492: break; ! 493: case NAME: ! 494: printf( "\n\t\t\tNAME (%s)", e->pnnode.symbol ); ! 495: break; ! 496: default: ! 497: printf( "\n\t\t\t%s %04x %04x", OP[(unsigned) e->gnode.exop], ! 498: e->gnode.exleft, e->gnode.exright ); ! 499: if( e->gnode.exleft ) { ! 500: fread( &f, 1, sizeof(ENODE), trnfdes ); ! 501: printf( "\n\t\tLEFT DESENT:" ); ! 502: prtds9(&f); ! 503: } ! 504: if( e->gnode.exright ) { ! 505: fread( &f, 1, sizeof(ENODE), trnfdes ); ! 506: printf( "\n\t\tRIGHT DESENT:" ); ! 507: prtds9(&f); ! 508: } ! 509: } ! 510: ! 511: } ! 512: /*eject*/ ! 513: prtds10() ! 514: { ! 515: /* ! 516: * Read and print one EVEXPR data structure ! 517: */ ! 518: ! 519: ACTITEM a; ! 520: ! 521: fread( &a, 1, sizeof(ACTITEM), trnfdes ); ! 522: ! 523: prtds8(&a, 0); ! 524: } ! 525: prtds11() ! 526: { ! 527: /* ! 528: * Read and print one TVASSIGN data structure ! 529: */ ! 530: ! 531: TVASSIGN tv; ! 532: ! 533: fread( &tv, 1, sizeof(TVASSIGN), trnfdes ); ! 534: ! 535: printf( "\n\t%04x %8.8s %d", ! 536: tv.nxtslot, tv.funname, tv.slot ); ! 537: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.