X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/100d3f3c8f3c9248b5d33a66021cd5e7fbccc807..ec43bca497273be508e7cb7d0be0849639980add:/usr/src/old/as.vax/asmain.c diff --git a/usr/src/old/as.vax/asmain.c b/usr/src/old/as.vax/asmain.c index c869333315..e56de1dad5 100644 --- a/usr/src/old/as.vax/asmain.c +++ b/usr/src/old/as.vax/asmain.c @@ -1,16 +1,21 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char sccsid[] = "@(#)asmain.c 4.5 %G%"; +/* + * Copyright (c) 1982 Regents of the University of California + */ +#ifndef lint +static char sccsid[] = "@(#)asmain.c 4.11 %G%"; +#endif not lint + #include #include #include #include "as.h" #include "assyms.h" -#include "asexpr.h" #include "asscan.h" +#include "asexpr.h" #ifdef UNIX -#define unix_lang_name "VAX/UNIX Assembler V%G% 4.5" +#define unix_lang_name "VAX/UNIX Assembler V%G% 4.11" #endif #ifdef VMS @@ -31,11 +36,16 @@ int silent = 0; /*don't complain about any errors*/ int savelabels = 0; /*write the labels to the a.out file*/ int d124 = 4; /*default allocate 4 bytes for unknown pointers*/ int anyerrs = 0; /*no errors yet*/ +int anywarnings=0; /*no warnings yet*/ int orgwarn = 0; /*Bad origins*/ int passno = 1; /* current pass*/ int jxxxJUMP = 0; /* in jxxxes that branch too far, use jmp instead of brw */ int readonlydata = 0; /* initialzed data -> text space */ +int nGHnumbers = 0; /* GH numbers used */ +int nGHopcodes = 0; /* GH opcodes used */ +int nnewopcodes = 0; /* new opcodes used */ + #ifdef DEBUG int debug = 0; int toktrace = 0; @@ -72,11 +82,19 @@ u_long drsize; /* total data relocation size */ struct exp usedot[NLOC+NLOC]; /* info about all segments */ struct exp *dotp; /* data/text location pointer */ /* - * The inter pass temporary file is opened and closed by stdio, but + * The inter pass temporary token file is opened and closed by stdio, but * is written to using direct read/write, as the temporary file * is composed of buffers exactly BUFSIZ long. */ -FILE *tmpfil; /* interpass communication file */ +FILE *tokfile; /* interpass communication file */ +char tokfilename[TNAMESIZE]; +/* + * The string file is the string table + * cat'ed to the end of the built up a.out file + */ +FILE *strfile; /* interpass string file */ +char strfilename[TNAMESIZE]; +int strfilepos = 0; /* position within the string file */ /* * a.out is created during the second pass. * It is opened by stdio, but is filled with the parallel @@ -161,8 +179,6 @@ char *tmpdirprefix = "/usr/tmp/"; #endif -#define TMP_SUFFIX "asXXXXXX" -char tmpn1[TNAMESIZE]; int delexit(); @@ -170,9 +186,11 @@ main(argc, argv) int argc; char **argv; { + char *sbrk(); - tmpn1[0] = 0; - endcore = (char *)sbrk(0); + tokfilename[0] = 0; + strfilename[0] = 0; + endcore = sbrk(0); argprocess(argc, argv); /* process argument lists */ if (anyerrs) exit(1); @@ -206,6 +224,16 @@ main(argc, argv) if (anyerrs == 0 && orgwarn) yyerror("Caution: absolute origins.\n"); + + if (nGHnumbers) + yywarning("Caution: G or H format floating point numbers"); + if (nGHopcodes) + yywarning("Caution: G or H format floating point operators"); + if (nnewopcodes) + yywarning("Caution: New Opcodes"); + if (nGHnumbers || nGHopcodes || nnewopcodes) + yywarning("These are not defined for all implementations of the VAX architecture.\n"); + exit(anyerrs != 0); } /*end of UNIX main*/ @@ -238,6 +266,9 @@ argprocess(argc, argv) yyerror("Unknown flag: %c", *--cp); cp++; break; + case 'v': + selfwhat(stdout); + exit(1); case 'd': d124 = *cp++ - '0'; if ( (d124 != 1) && (d124 != 2) && @@ -296,6 +327,37 @@ argprocess(argc, argv) } /* innames[ninfiles] = 0; */ } +/* + * poke through the data space and find all sccs identifiers. + * We assume: + * a) that extern char **environ; is the first thing in the bss + * segment (true, if one is using the new version of cmgt.crt0.c) + * b) that the sccsid's have not been put into text space. + */ +selfwhat(place) + FILE *place; +{ + extern char **environ; + register char *ub; + register char *cp; + register char *pat; + char *sbrk(); + + for (cp = (char *)&environ, ub = sbrk(0); cp < ub; cp++){ + if (cp[0] != '@') continue; + if (cp[1] != '(') continue; + if (cp[2] != '#') continue; + if (cp[3] != ')') continue; + fputc('\t', place); + for (cp += 4; cp < ub; cp++){ + if (*cp == 0) break; + if (*cp == '>') break; + if (*cp == '\n') break; + fputc(*cp, place); + } + fputc('\n', place); + } +} initialize() { @@ -324,8 +386,6 @@ zeroorigins() usedot[NLOC + locindex].e_xtype = XDATA; usedot[locindex].e_xvalue = 0; usedot[NLOC + locindex].e_xvalue = 0; - usedot[locindex].e_yvalue = 0; - usedot[NLOC + locindex].e_yvalue = 0; } } @@ -341,21 +401,40 @@ zerolocals() i_pass1() { - if (useVM == 0){ - strcat(tmpn1, tmpdirprefix); - strcat(tmpn1, TMP_SUFFIX); - mktemp(tmpn1); - tmpfil = fopen(tmpn1, "w"); - if (tmpfil==NULL) { - yyerror("Bad pass 1 temporary file for writing %s", tmpn1); - delexit(); - } - } + FILE *tempopen(); + if (useVM == 0) + tokfile = tempopen(tokfilename, "T"); + strfile = tempopen(strfilename, "S"); + /* + * write out the string length. + * This will be overwritten when the + * strings are tacked onto the growing a.out file + */ + strfilepos = sizeof(int); + fwrite(&strfilepos, sizeof(int), 1, strfile); - inittmpfile(); + inittokfile(); initijxxx(); } +FILE *tempopen(tname, part) + char *tname; + char *part; +{ + FILE *file; + sprintf(tname, "%s%sas%s%05d", + tmpdirprefix, + (tmpdirprefix[strlen(tmpdirprefix)-1] != '/') ? "/" : 0, + part, + getpid()); + file = fopen(tname, "w"); + if (file == NULL) { + yyerror("Bad pass 1 temporary file for writing %s", tname); + delexit(); + } + return(file); +} + pass1() { register int i; @@ -384,7 +463,7 @@ pass1() } } - closetmpfile(); /*kick out the last buffered intermediate text*/ + closetokfile(); /*kick out the last buffered intermediate text*/ } testlocals() @@ -505,13 +584,15 @@ build_hdr() i_pass2() { if (useVM == 0) { - fclose(tmpfil); - tmpfil = fopen(tmpn1, "r"); - if (tmpfil==NULL) { - yyerror("Bad pass 2 temporary file for reading %s", tmpn1); + fclose(tokfile); + tokfile = fopen(tokfilename, "r"); + if (tokfile==NULL) { + yyerror("Bad pass 2 temporary file for reading %s", tokfilename); delexit(); } } + fclose(strfile); + strfile = fopen(strfilename, "r"); } pass2() @@ -527,11 +608,11 @@ pass2() relfil = 0; /* outrel takes care of the rest */ initoutrel(); - inittmpfile(); + inittokfile(); yyparse(); - closetmpfile(); + closetokfile(); } fillsegments() @@ -573,13 +654,18 @@ reloc_syms() /* * Output the symbol table * and if FLEXNAMES is set, the string pool + * + * We must first rewind the string pool file to its beginning, + * in case it was seek'ed into for fetching ascii and asciz + * strings. */ + fseek(strfile, 0, 0); symwrite(relocfile); } fix_a_out() { - if (lseek(a_out_file->_file, 0L, 0) < 0) + if (lseek(a_out_file->_file, 0L, 0) < 0L) yyerror("Reposition for header rewrite fails"); if (write(a_out_file->_file, (char *)&hdr, sizeof (struct exec)) < 0) yyerror("Rewrite of header fails"); @@ -596,8 +682,10 @@ delexit() delete() { - if (useVM == 0 || tmpn1[0]) - unlink(tmpn1); + if (useVM == 0 || tokfilename[0]) + unlink(tokfilename); + if (strfilename[0]) + unlink(strfilename); } sawabort()