took out 't misfeature on ^^ when Bill agreed.
[unix-history] / usr / src / old / as.vax / asmain.c
index 8747263..548a491 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1980 Regents of the University of California */
 /* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asmain.c 4.3 %G%";
+static char sccsid[] = "@(#)asmain.c 4.6 %G%";
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
@@ -10,7 +10,7 @@ static        char sccsid[] = "@(#)asmain.c 4.3 %G%";
 #include "asscan.h"
 
 #ifdef UNIX
 #include "asscan.h"
 
 #ifdef UNIX
-#define        unix_lang_name "VAX/UNIX Assembler Vasmain.c"
+#define        unix_lang_name "VAX/UNIX Assembler V%G% 4.6"
 #endif
 
 #ifdef VMS
 #endif
 
 #ifdef VMS
@@ -22,7 +22,7 @@ static        char sccsid[] = "@(#)asmain.c 4.3 %G%";
  */
 char   *dotsname;      /*the current file name; managed by the parser*/
 int    lineno;         /*current line number; managed by the parser*/
  */
 char   *dotsname;      /*the current file name; managed by the parser*/
 int    lineno;         /*current line number; managed by the parser*/
-char   *innames[32];   /*names of the files being assembled*/
+char   **innames;      /*names of the files being assembled*/
 int    ninfiles;       /*how many interesting files there are*/
 /*
  *     Flags settable from the argv process argument list
 int    ninfiles;       /*how many interesting files there are*/
 /*
  *     Flags settable from the argv process argument list
@@ -34,6 +34,7 @@ int   anyerrs = 0;    /*no errors 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    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 */
 
 #ifdef DEBUG
 int    debug = 0;
 
 #ifdef DEBUG
 int    debug = 0;
@@ -54,7 +55,7 @@ char  *endcore;       /*where to get more symbol space*/
  *     Managers of the a.out file.
  */
 struct exec    hdr;
  *     Managers of the a.out file.
  */
 struct exec    hdr;
-#define        MAGIC   0410
+#define        MAGIC   0407
 u_long tsize;          /* total text size */
 u_long dsize;          /* total data size */
 u_long datbase;        /* base of the data segment */
 u_long tsize;          /* total text size */
 u_long dsize;          /* total data size */
 u_long datbase;        /* base of the data segment */
@@ -219,9 +220,12 @@ argprocess(argc, argv)
 #ifdef DEBUG
        debug = 0;
 #endif
 #ifdef DEBUG
        debug = 0;
 #endif
+       innames = (char **)ClearCalloc(argc+1, sizeof (innames[0]));
        dotsname = "<argv error>";
        while (argc > 1) {
        dotsname = "<argv error>";
        while (argc > 1) {
-               if (argv[1][0] == '-'){
+               if (argv[1][0] != '-')
+                       innames[ninfiles++] = argv[1];
+               else {
                        cp = argv[1] + 1;
                        /*
                         *      We can throw away single minus signs, so
                        cp = argv[1] + 1;
                        /*
                         *      We can throw away single minus signs, so
@@ -281,19 +285,16 @@ argprocess(argc, argv)
                                        toktrace = 1;
                                        break;
 #endif
                                        toktrace = 1;
                                        break;
 #endif
+                                case 'R':
+                                       readonlydata = 1;
+                                       break;
                                }       /*end of the switch*/
                        }       /*end of pulling out all arguments*/
                }       /*end of a flag argument*/
                                }       /*end of the switch*/
                        }       /*end of pulling out all arguments*/
                }       /*end of a flag argument*/
-               else {  /*file name*/
-                       if (ninfiles > 32){
-                               yyerror("More than 32 file names");
-                               exit(3);
-                       }
-                       innames[ninfiles++] = argv[1];
-               }
                --argc; ++argv;
           nextarg:;
        }
                --argc; ++argv;
           nextarg:;
        }
+       /* innames[ninfiles] = 0; */
 }
 
 initialize()
 }
 
 initialize()
@@ -342,6 +343,8 @@ i_pass1()
 {
        if (useVM == 0){
                strcat(tmpn1, tmpdirprefix);
 {
        if (useVM == 0){
                strcat(tmpn1, tmpdirprefix);
+               if (tmpdirprefix[strlen(tmpdirprefix)-1] != '/')
+                       strcat(tmpn1, "/");
                strcat(tmpn1, TMP_SUFFIX);
                mktemp(tmpn1);
                tmpfil = fopen(tmpn1, "w");
                strcat(tmpn1, TMP_SUFFIX);
                mktemp(tmpn1);
                tmpfil = fopen(tmpn1, "w");
@@ -451,7 +454,7 @@ roundsegments()
        /*
         *              Round and assign data segment origins.
         */
        /*
         *              Round and assign data segment origins.
         */
-       datbase = round(tsize, PAGRND);
+       datbase = round(tsize, FW);
        for (locindex=0; locindex<NLOC; locindex++) {
                v = round(usedot[NLOC+locindex].e_xvalue, FW);
                usedot[NLOC+locindex].e_xvalue = datbase + dsize;
        for (locindex=0; locindex<NLOC; locindex++) {
                v = round(usedot[NLOC+locindex].e_xvalue, FW);
                usedot[NLOC+locindex].e_xvalue = datbase + dsize;
@@ -563,6 +566,12 @@ reloc_syms()
 
        hdr.a_trsize = trsize;
        hdr.a_drsize = drsize;
 
        hdr.a_trsize = trsize;
        hdr.a_drsize = drsize;
+       if (readonlydata) {
+               hdr.a_text += hdr.a_data;
+               hdr.a_data = 0;
+               hdr.a_trsize += hdr.a_drsize;
+               hdr.a_drsize = 0;
+       }
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool