Tidy up the manipulation of on-disk a.out, nlist and ranlib structures, getting rid...
authorNick Downing <downing.nick@gmail.com>
Thu, 5 Jan 2017 08:14:57 +0000 (19:14 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 5 Jan 2017 08:14:57 +0000 (19:14 +1100)
52 files changed:
bin/ar/krcompat.h
bin/ar/n.sh
bin/as/krcompat.h
bin/as/n.sh
bin/cc/krcompat.h
bin/cc/n.sh
bin/ld/krcompat.h
bin/ld/ld.c
bin/ld/n.sh
bin/n.sh
bin/nm/krcompat.h
bin/nm/n.sh
bin/nm/nm.c
bin/size.c
lib/c2/c20.c
lib/c2/krcompat.h
lib/c2/n.sh
lib/ccom/c01.c
lib/ccom/c04.c
lib/ccom/c11.c
lib/ccom/krcompat.h
lib/ccom/n.sh
lib/cpp/cpp.c
lib/cpp/krcompat.h
lib/cpp/n.sh
lib/libc/gen/n.sh [new file with mode: 0755]
lib/libc/gen/nlist.c
lib/libc/n.sh
lib/libc/pdp/Makefile
lib/libc/pdp/csu/n.sh [new file with mode: 0755]
lib/libkern/Makefile
lib/libkern/n.sh
n.sh
sys/GENERIC/Makefile
ucb/strcompact/krcompat.h
ucb/strcompact/n.sh
ucb/strcompact/strcompact.c
ucb/symcompact/krcompat.h
ucb/symcompact/n.sh
ucb/symcompact/symcompact.c
ucb/symdump/krcompat.h
ucb/symdump/n.sh
ucb/symdump/symdump.c
ucb/symorder/krcompat.h
ucb/symorder/n.sh
ucb/symorder/symorder.c
usr.bin/n.sh
usr.bin/ranlib/build.c
usr.bin/ranlib/krcompat.h
usr.bin/ranlib/misc.c
usr.bin/ranlib/n.sh
usr.lib/libvmf/n.sh

index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 9feff61..3b48e38 100755 (executable)
@@ -4,5 +4,5 @@ CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-fo
 mkdir --parents "$ROOT/cross/bin"
 mkdir --parents "$ROOT/cross/usr/man/cat1"
 mkdir --parents "$ROOT/cross/usr/man/cat5"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 8604ded..fa1fd80 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/bin\/as$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index c242419..bc05bc0 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/bin\/cc$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
-make CC="$CC" CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" SEPFLAG=
+make CC="$CC" CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index cd2f8fb..7af8f9e 100644 (file)
@@ -169,7 +169,9 @@ typedef struct {
        typedef struct
                {
                union   {
+#ifdef pdp11
                        int     *iptr;
+#endif
                        char    *cptr;
                        } ptr;
                int     bno;
@@ -179,7 +181,9 @@ typedef struct {
                int     bsize;          /* MUST be a power of 2 */
                int     *buff;
                } STREAM;
+#ifdef pdp11
 #define        Iptr    ptr.iptr
+#endif
 #define        Cptr    ptr.cptr
 
 #define        TEXT            0
@@ -327,7 +331,7 @@ void load2td PARAMS((struct local *lp, u_int creloc, FILE *b1, FILE *b2));
 void finishout PARAMS((void));
 long rnd8k PARAMS((u_int siz));
 void mkfsym PARAMS((char *s));
-void mget PARAMS((register int *loc, int an, int which));
+void mget PARAMS((register char *loc, int an, int which));
 void dseek PARAMS((int which, OFF_T aloc, int s));
 int get PARAMS((int which));
 int getfile PARAMS((char *acp, int flag, int phase));
@@ -348,15 +352,6 @@ OFF_T skip PARAMS((void));
 void inistr PARAMS((int which));
 
 static void hreset PARAMS((void));
-#ifdef pdp11
-#define outw(n, fp) putw(n, fp)
-#define outd(n, fp) fwrite(&n, sizeof (OFF_T), 1, fp)
-/* dget not used as we usually read a whole structure at a time */
-#else
-static void outw PARAMS((int n, FILE *fp));
-static void outd PARAMS((OFF_T n, FILE *fp));
-static OFF_T dget(int which);
-#endif
 
 int main(argc, argv) int argc; char **argv; {
        register int c, i;
@@ -586,9 +581,20 @@ void endload(argc, argv) int argc; char **argv; {
 
                case 'D':
                        for (dnum = atoi(*p);dorigin < dnum; dorigin += 2) {
-                               outw(0, doutb);
-                               if (rflag)
-                                       outw(0, droutb);
+#ifdef pdp11
+                               putw(0, doutb);
+#else
+                               putc(0, doutb);
+                               putc(0, doutb);
+#endif
+                               if (rflag) {
+#ifdef pdp11
+                                       putw(0, droutb);
+#else
+                                       putc(0, droutb);
+                                       putc(0, droutb);
+#endif
+                               }
                        }
                        /* fall into ... */
                case 'u':
@@ -686,7 +692,7 @@ void load1arg(cp, flag) register char *cp; int flag; {
         */
        case 2:
                nloc = SARMAG + sizeof (struct ar_hdr) + chdr.lname;
-               lseek(infil, nloc, L_SET);
+               lseek(infil, (off_t)nloc, L_SET);
 /*
  * Read the size of the ranlib structures (a long).
 */
@@ -694,10 +700,8 @@ void load1arg(cp, flag) register char *cp; int flag; {
                read(infil, &ltnum, sizeof (OFF_T));
 #else
                read(infil, temp, sizeof (OFF_T));
-               ltnum = ((temp[0] & 0377L) << 16) |
-                       ((temp[1] & 0377L) << 24) |
-                       (temp[2] & 0377L) |
-                       ((temp[3] & 0377L) << 8);
+               ltnum = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
  /*fprintf(stderr, "ltnum=%08lx\n", ltnum);*/
 /*
@@ -709,15 +713,13 @@ void load1arg(cp, flag) register char *cp; int flag; {
                tnum = ltnum / sizeof (struct ranlib);
 
                rstrtab = NULL;
-               lseek(infil, nloc, L_SET);
+               lseek(infil, (off_t)nloc, L_SET);
 #ifdef pdp11
                read(infil, &strsize, sizeof (OFF_T));
 #else
                read(infil, temp, sizeof (OFF_T));
-               strsize = ((temp[0] & 0377L) << 16) |
-                       ((temp[1] & 0377L) << 24) |
-                       (temp[2] & 0377L) |
-                       ((temp[3] & 0377L) << 8);
+               strsize = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
  /*fprintf(stderr, "strsize=%08lx\n", strsize);*/
                if      (strsize <= 8192L)
@@ -768,7 +770,7 @@ void load1arg(cp, flag) register char *cp; int flag; {
  * for use in pass2.  Mark the end of the archive in libilst with a -1.
  */
 int step(nloc) OFF_T nloc; {
-       lseek(infil, nloc, L_SET);
+       lseek(infil, (off_t)nloc, L_SET);
        if      (get_arobj(infil) <= 0)
                {
                libp->loc = -1;
@@ -793,7 +795,7 @@ int ldrand(totnum, sloc) int totnum; OFF_T sloc; {
        LIBLIST *oldp = libp;
        int amt, tnum = totnum;
        OFF_T   loc;
- /*fprintf(stderr, "sloc=%08lx tnum=%d\n", sloc, tnum);*/
+ /*fprintf(stderr, "totnum=%d sloc=%08lx\n", tnum, sloc);*/
 /*
  * 'ar' header + member header + SYMDEF table.of.contents + long filename
 */
@@ -815,7 +817,7 @@ int ldrand(totnum, sloc) int totnum; OFF_T sloc; {
                        ntab = tnum;
  /*fprintf(stderr, "ntab=%d opos=%08lx\n", ntab, opos);*/
                tplast = &tab[ntab - 1];
-               (void)lseek(infil, opos, L_SET);
+               (void)lseek(infil, (off_t)opos, L_SET);
                amt = ntab * sizeof (struct ranlib);
 #ifdef pdp11
                if      (read(infil, tab, amt) != amt)
@@ -826,15 +828,11 @@ int ldrand(totnum, sloc) int totnum; OFF_T sloc; {
                temp = buf;
                for     (tp = tab; tp <= tplast; tp++)
                        {
-                       tp->ran_un.ran_strx = ((temp[0] & 0377L) << 16) |
-                                       ((temp[1] & 0377L) << 24) |
-                                       (temp[2] & 0377L) |
-                                       ((temp[3] & 0377L) << 8);
-                       tp->ran_off = ((temp[4] & 0377L) << 16) |
-                                       ((temp[5] & 0377L) << 24) |
-                                       (temp[6] & 0377L) |
-                                       ((temp[7] & 0377L) << 8);
-                       temp += sizeof (struct ranlib); /* must be 8 */
+                       tp->ran_un.ran_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+                       tp->ran_off = ((temp[4] & 0xffL) << 16) | ((temp[5] & 0xffL) << 24) |
+                           (temp[6] & 0xffL) | ((temp[7] & 0xffL) << 8);
+                       temp += sizeof (struct ranlib);
                        }
 #endif
                tnum -= ntab;
@@ -847,6 +845,7 @@ int ldrand(totnum, sloc) int totnum; OFF_T sloc; {
  * possible to hold the entire string table in memory.  Need to add
  * an extra increment to skip over the string table size longword.
 */
+ /*fprintf(stderr, "ran_strx=%ld\n", tp->ran_un.ran_strx);*/
                        if      (rstrtab)
                                strncpy(localname, (int)tp->ran_un.ran_strx +
                                                rstrtab, NNAMESIZE);
@@ -900,14 +899,15 @@ int load1(libflg, loc) int libflg; OFF_T loc; {
        int ndef, type, mtype;
        long nlocal;
        VADDR   vsym;
+#ifndef pdp11
+       /* note: must be at least as large as OFF_T */
+       char    temp[sizeof (struct nlist)];
+#endif
        struct  nlist objsym;
        OFF_T   strloc;
        OFF_T   strsize;
        char    *strtab;
        register struct vseg *seg;
-#ifndef pdp11
-       char temp[sizeof (OFF_T)];
-#endif
 
        readhdr(loc);
        if (filhdr.e.a_syms == 0) {
@@ -927,13 +927,13 @@ int load1(libflg, loc) int libflg; OFF_T loc; {
        dseek(SYMBOLS, loc + N_SYMOFF(filhdr), filhdr.e.a_syms);
 
        strloc = loc + N_STROFF(filhdr);
-       lseek(infil, strloc, L_SET);
+       lseek(infil, (off_t)strloc, L_SET);
 #ifdef pdp11
        read(infil, &strsize, sizeof (OFF_T));
 #else
        read(infil, temp, sizeof (OFF_T));
-       strsize = ((temp[0] & 0377L) << 16) | ((temp[1] & 0377L) << 24) |
-                       (temp[2] & 0377L) | ((temp[3] & 0377L) << 8);
+       strsize = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
        strtab = NULL;
        if      (strsize <= 8192L)
@@ -947,16 +947,16 @@ int load1(libflg, loc) int libflg; OFF_T loc; {
 
        while (Input[SYMBOLS].nsize > 0) {
 #ifdef pdp11
-               mget((int *)&objsym, sizeof objsym, SYMBOLS);
-               type = objsym.n_type;
+               mget((char *)&objsym, sizeof objsym, SYMBOLS);
 #else
-               objsym.n_un.n_strx = dget(SYMBOLS);
-               type = get(SYMBOLS);
-               objsym.n_ovly = (type >> 8) & 0377;
-               type &= 0377;
-               objsym.n_type = type;
-               objsym.n_value = get(SYMBOLS);
+               mget(temp, sizeof objsym, SYMBOLS);
+               objsym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               objsym.n_type = temp[4] & 0xff;
+               objsym.n_ovly = temp[5] & 0xff;
+               objsym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
+               type = objsym.n_type;
                if (Sflag) {
                        mtype = type&037;
                        if (mtype==1 || mtype>4) {
@@ -972,6 +972,7 @@ int load1(libflg, loc) int libflg; OFF_T loc; {
  * to place the strings in the same order as the symbols - so effectively
  * we are doing a sequential read of the string table.
 */
+ /*fprintf(stderr, "n_strx=%ld\n", objsym.n_un.n_strx);*/
                if      (strtab)
                        strncpy(cursym.n_name, (int)objsym.n_un.n_strx + 
                                strtab - sizeof (OFF_T), NNAMESIZE);
@@ -980,6 +981,7 @@ int load1(libflg, loc) int libflg; OFF_T loc; {
                        dseek(STRINGS, objsym.n_un.n_strx + strloc, 077777);
                        mgets(cursym.n_name, NNAMESIZE, STRINGS);
                        }
+ /*fprintf(stderr, "n_name=%s\n", cursym.n_name);*/
                cursym.n_type = objsym.n_type;
                cursym.n_value = objsym.n_value;
                cursym.n_ovly = objsym.n_ovly;
@@ -1273,6 +1275,8 @@ void setupout() {
        VADDR   vsym;
        register SYMBOL *sp;
 #ifndef pdp11
+       /* note: must be at least as large as struct exec */
+       char    temp[sizeof (struct ovlhdr)];
        int i;
 #endif
 
@@ -1319,38 +1323,40 @@ void setupout() {
        filhdr.e.a_flag = (rflag==0);
 #ifdef pdp11
        fwrite(&filhdr.e, sizeof (filhdr.e), 1, toutb);
-       if (numov)
-               fwrite(&filhdr.o, sizeof (filhdr.o), 1, toutb);
 #else
-       outw(filhdr.e.a_magic, toutb);
-       outw(filhdr.e.a_text, toutb);
-       outw(filhdr.e.a_data, toutb);
-       outw(filhdr.e.a_bss, toutb);
-       outw(filhdr.e.a_syms, toutb);
-       outw(filhdr.e.a_entry, toutb);
-       outw(0, toutb); /* filhdr.e.a_unused */
-       outw(filhdr.e.a_flag, toutb);
+       temp[0] = filhdr.e.a_magic & 0xff;
+       temp[1] = (filhdr.e.a_magic >> 8) & 0xff;
+       temp[2] = filhdr.e.a_text & 0xff;
+       temp[3] = (filhdr.e.a_text >> 8) & 0xff;
+       temp[4] = filhdr.e.a_data & 0xff;
+       temp[5] = (filhdr.e.a_data >> 8) & 0xff;
+       temp[6] = filhdr.e.a_bss & 0xff;
+       temp[7] = (filhdr.e.a_bss >> 8) & 0xff;
+       temp[8] = filhdr.e.a_syms & 0xff;
+       temp[9] = (filhdr.e.a_syms >> 8) & 0xff;
+       temp[10] = filhdr.e.a_entry & 0xff;
+       temp[11] = (filhdr.e.a_entry >> 8) & 0xff;
+       temp[12] = filhdr.e.a_unused & 0xff;
+       temp[13] = (filhdr.e.a_unused >> 8) & 0xff;
+       temp[14] = filhdr.e.a_flag & 0xff;
+       temp[15] = (filhdr.e.a_flag >> 8) & 0xff;
+       fwrite(temp, sizeof (filhdr.e), 1, toutb);
+#endif
        if (numov) {
-               outw(filhdr.o.max_ovl, toutb);
-               for (i = 0; i < NOVL; i++)
-                       outw(filhdr.o.ov_siz[i], toutb);
-       }
+#ifdef pdp11
+               fwrite(&filhdr.o, sizeof (filhdr.o), 1, toutb);
+#else
+               temp[0] = filhdr.o.max_ovl & 0xff;
+               temp[1] = (filhdr.o.max_ovl >> 8) & 0xff;
+               for (i = 0; i < NOVL; ++i) {
+                       temp[i * 2 + 2] = filhdr.o.ov_siz[i] & 0xff;
+                       temp[i * 2 + 3] = (filhdr.o.ov_siz[i] >> 8) & 0xff;
+               }
+               fwrite(temp, sizeof (filhdr.o), 1, toutb);
 #endif
+       }
 }
 
-#ifndef pdp11
-static void outw(n, fp) int n; FILE *fp; {
-       putc(n & 0377, fp);
-       putc((n >> 8) & 0377, fp);
-}
-
-static void outd(n, fp) OFF_T n; FILE *fp; {
-       /* note weirdness as files are stored in pdp11's native layout */
-       outw((int)(n >> 16) & 0177777, fp);
-       outw((int)n & 0177777, fp);
-}
-#endif
-
 void load2arg(acp, flag) char *acp; int flag; {
        register char *cp;
        register LIBLIST *lp;
@@ -1370,7 +1376,7 @@ void load2arg(acp, flag) char *acp; int flag; {
                        return;
                default:        /* scan archive members referenced */
                        for (lp = libp; lp->loc != -1; lp++) {
-                               lseek(infil, lp->loc, L_SET);
+                               lseek(infil, (off_t)lp->loc, L_SET);
                                get_arobj(infil);
                                mkfsym(chdr.name);
                                load2(lp->loc + sizeof (struct ar_hdr) + 
@@ -1394,7 +1400,8 @@ void load2(loc) long loc; {
        char    *strtab;
        OFF_T   strsize;
 #ifndef pdp11
-       char temp[sizeof (OFF_T)];
+       /* note: must be at least as large as OFF_T */
+       char    temp[sizeof (struct nlist)];
 #endif
 
        readhdr(loc);
@@ -1410,13 +1417,13 @@ void load2(loc) long loc; {
        dseek(SYMBOLS, loc + N_SYMOFF(filhdr), filhdr.e.a_syms);
        stroff = loc + N_STROFF(filhdr);
 
-       lseek(infil, stroff, L_SET);
+       lseek(infil, (off_t)stroff, L_SET);
 #ifdef pdp11
        read(infil, &strsize, sizeof (OFF_T));
 #else
        read(infil, temp, sizeof (OFF_T));
-       strsize = ((temp[0] & 0377L) << 16) | ((temp[1] & 0377L) << 24) |
-                       (temp[2] & 0377L) | ((temp[3] & 0377L) << 8);
+       strsize = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
        strtab = NULL;
        if      (strsize <= 8192L)
@@ -1431,14 +1438,14 @@ void load2(loc) long loc; {
        while (Input[SYMBOLS].nsize > 0) {
                symno++;
 #ifdef pdp11
-               mget((int *)&objsym, sizeof objsym, SYMBOLS);
+               mget((char *)&objsym, sizeof objsym, SYMBOLS);
 #else
-               objsym.n_un.n_strx = dget(SYMBOLS);
-               type = get(SYMBOLS);
-               objsym.n_ovly = (type >> 8) & 0377;
-               type &= 0377;
-               objsym.n_type = type;
-               objsym.n_value = get(SYMBOLS);
+               mget(temp, sizeof objsym, SYMBOLS);
+               objsym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               objsym.n_type = temp[4] & 0xff;
+               objsym.n_ovly = temp[5] & 0xff;
+               objsym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                if      (strtab)
                        strncpy(cursym.n_name, (int)objsym.n_un.n_strx +
@@ -1566,8 +1573,8 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1, *b2;
 #ifdef pdp11
                        t = *Input[TEXT].Iptr++;
 #else
-                       t = *Input[TEXT].Cptr++ & 0377;
-                       t |= (*Input[TEXT].Cptr++ & 0377) << 8; 
+                       t = *Input[TEXT].Cptr++ & 0xff;
+                       t |= (*Input[TEXT].Cptr++ & 0xff) << 8; 
 #endif
                }
 
@@ -1585,8 +1592,8 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1, *b2;
 #ifdef pdp11
                        r = *Input[RELOC].Iptr++;
 #else
-                       r = *Input[RELOC].Cptr++ & 0377;
-                       r |= (*Input[RELOC].Cptr++ & 0377) << 8;        
+                       r = *Input[RELOC].Cptr++ & 0xff;
+                       r |= (*Input[RELOC].Cptr++ & 0xff) << 8;        
 #endif
                }
 #if 0
@@ -1623,9 +1630,20 @@ void load2td(lp, creloc, b1, b2) struct local *lp; u_int creloc; FILE *b1, *b2;
                }
                if (r&01)
                        t -= creloc;
-               outw(t, b1);
-               if (rflag)
-                       outw(r, b2);
+#ifdef pdp11
+               putw(t, b1);
+#else
+               putc(t & 0xff, b1);
+               putc((t >> 8) & 0xff, b1);
+#endif
+               if (rflag) {
+#ifdef pdp11
+                       putw(r, b2);
+#else
+                       putc(r & 0xff, b2);
+                       putc((r >> 8) & 0xff, b2);
+#endif
+               }
        }
 }
 
@@ -1639,7 +1657,8 @@ void finishout() {
        long dtotal, ovrnd;
        INT     thunk[THUNKSIZ / sizeof (INT)];
 #ifndef pdp11
-       unsigned char temp[THUNKSIZ];
+       /* note: must be at least as large as struct nlist, THUNKSIZ, OFF_T */
+       char    temp[sizeof (struct exec)];
 #endif
  
        if (numov) {
@@ -1679,9 +1698,20 @@ void finishout() {
                n = torigin;
                while (n&077) {
                        n += 2;
-                       outw(0, toutb);
-                       if (rflag)
-                               outw(0, troutb);
+#ifdef pdp11
+                       putw(0, toutb);
+#else
+                       putc(0, toutb);
+                       putc(0, toutb);
+#endif
+                       if (rflag) {
+#ifdef pdp11
+                               putw(0, troutb);
+#else
+                               putc(0, troutb);
+                               putc(0, troutb);
+#endif
+                       }
                }
        }
        if (numov)
@@ -1731,10 +1761,15 @@ void finishout() {
 #ifdef pdp11
                                fwrite(&objsym, sizeof (objsym), 1, toutb);
 #else
-                               outd(objsym.n_un.n_strx, toutb);
-                               putc(objsym.n_type, toutb);
-                               putc(objsym.n_ovly, toutb);
-                               outw(objsym.n_value, toutb);
+                               temp[0] = (objsym.n_un.n_strx >> 16) & 0xff;
+                               temp[1] = (objsym.n_un.n_strx >> 24) & 0xff;
+                               temp[2] = objsym.n_un.n_strx & 0xff;
+                               temp[3] = (objsym.n_un.n_strx >> 8) & 0xff;
+                               temp[4] = objsym.n_type & 0xff;
+                               temp[5] = objsym.n_ovly & 0xff;
+                               temp[6] = objsym.n_value & 0xff;
+                               temp[7] = (objsym.n_value >> 8) & 0xff;
+                               fwrite(temp, sizeof (objsym), 1, toutb);
 #endif
                                nsym++;
                                }
@@ -1762,10 +1797,15 @@ void finishout() {
 #ifdef pdp11
                        fwrite(&objsym, sizeof (objsym), 1, toutb);
 #else
-                       outd(objsym.n_un.n_strx, toutb);
-                       putc(objsym.n_type, toutb);
-                       putc(objsym.n_ovly, toutb);
-                       outw(objsym.n_value, toutb);
+                       temp[0] = (objsym.n_un.n_strx >> 16) & 0xff;
+                       temp[1] = (objsym.n_un.n_strx >> 24) & 0xff;
+                       temp[2] = objsym.n_un.n_strx & 0xff;
+                       temp[3] = (objsym.n_un.n_strx >> 8) & 0xff;
+                       temp[4] = objsym.n_type & 0xff;
+                       temp[5] = objsym.n_ovly & 0xff;
+                       temp[6] = objsym.n_value & 0xff;
+                       temp[7] = (objsym.n_value >> 8) & 0xff;
+                       fwrite(temp, sizeof (objsym), 1, toutb);
 #endif
                        nsym++;
                        }
@@ -1780,7 +1820,15 @@ void finishout() {
  * Now write the length of the string table out.  Then copy the temp
  * file containing the strings to the image being built.
 */
-               outd(stroff, toutb);
+#ifdef pdp11
+               fwrite(&stroff, sizeof (OFF_T), 1, toutb);
+#else
+               temp[0] = (stroff >> 16) & 0xff;
+               temp[1] = (stroff >> 24) & 0xff;
+               temp[2] = stroff & 0xff;
+               temp[3] = (stroff >> 8) & 0xff;
+               fwrite(temp, sizeof (OFF_T), 1, toutb);
+#endif
                copy(doutb);
                }
 /*
@@ -1789,15 +1837,42 @@ void finishout() {
  * used earlier was only an estimate
 */
        fflush(toutb);
-#if 0 /*def pdp11*/
        rewind(toutb);
+#ifdef pdp11
        fread(&filhdr.e, sizeof (filhdr.e), 1, toutb);
+#else
+       fread(temp, sizeof (filhdr.e), 1, toutb);
+       /*filhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       filhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       filhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       filhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       filhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       filhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       filhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       filhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);*/
+#endif
        filhdr.e.a_syms = nsym * sizeof (objsym);
        rewind(toutb);
+#ifdef pdp11
        fwrite(&filhdr.e, sizeof (filhdr.e), 1, toutb);
 #else
-       fseek(toutb, (OFF_T)(4 * 2), SEEK_SET);
-       outw(nsym * sizeof (struct nlist), toutb);
+       /*temp[0] = filhdr.e.a_magic & 0xff;
+       temp[1] = (filhdr.e.a_magic >> 8) & 0xff;
+       temp[2] = filhdr.e.a_text & 0xff;
+       temp[3] = (filhdr.e.a_text >> 8) & 0xff;
+       temp[4] = filhdr.e.a_data & 0xff;
+       temp[5] = (filhdr.e.a_data >> 8) & 0xff;
+       temp[6] = filhdr.e.a_bss & 0xff;
+       temp[7] = (filhdr.e.a_bss >> 8) & 0xff;*/
+       temp[8] = filhdr.e.a_syms & 0xff;
+       temp[9] = (filhdr.e.a_syms >> 8) & 0xff;
+       /*temp[10] = filhdr.e.a_entry & 0xff;
+       temp[11] = (filhdr.e.a_entry >> 8) & 0xff;
+       temp[12] = filhdr.e.a_unused & 0xff;
+       temp[13] = (filhdr.e.a_unused >> 8) & 0xff;
+       temp[14] = filhdr.e.a_flag & 0xff;
+       temp[15] = (filhdr.e.a_flag >> 8) & 0xff;*/
+       fwrite(temp, sizeof (filhdr.e), 1, toutb);
 #endif
        fclose(toutb);
 
@@ -1852,7 +1927,9 @@ void mkfsym(s) char *s; {
        fwrite(&cursym, sizeof (cursym), 1, soutb);
 }
 
-void mget(loc, an, which) register int *loc; int an; int which; {
+/* I changed "int *loc;" to "char *loc;" for all architectures, */
+/* because I didn't want to hack it up with stuff like int16_t */
+void mget(loc, an, which) register char *loc; int an; int which; {
        register int n;
        register STREAM *tp = &Input[which];
 
@@ -1861,41 +1938,34 @@ void mget(loc, an, which) register int *loc; int an; int which; {
        if ((tp->nsize -= n) < 0)
                error(1, "premature EOF#1");
        while (tp->nibuf < n) {
-               bcopy(tp->Iptr, loc, tp->nibuf * 2);
-               tp->Iptr += tp->nibuf;
-               loc += tp->nibuf;
+               bcopy(tp->Cptr, loc, tp->nibuf * 2);
+               tp->Cptr += tp->nibuf * 2;
+               loc += tp->nibuf * 2;
                n -= tp->nibuf;
                dseek(which, (OFF_T)(tp->bno + 1) * tp->bsize, -1);
        }
-       bcopy(tp->Iptr, loc, n * 2);
-       tp->Iptr += n;
+       bcopy(tp->Cptr, loc, n * 2);
+       tp->Cptr += n * 2;
        tp->nibuf -= n;
 #else
        if ((tp->nibuf -= n) >= 0) {
                if ((tp->nsize -= n) > 0) {
-                       bcopy(tp->ptr, loc, an);
-                       tp->Iptr += n;
+                       bcopy(tp->Cptr, loc, an);
+                       tp->Cptr += an;
                        return;
                }
                tp->nsize += n;
        }
        tp->nibuf += n;
-       do
-               *loc++ = get(which); /* no good for big-endian cross-compile */
-       while (--n);
+       do {
+               /* pdp11 ver before prototype change: *loc++ = get(which); */
+               temp = get(which);
+               *loc++ = temp & 0xff;
+               *loc++ = (temp >> 8) & 0xff;
+       } while (--n);
 #endif
 }
 
-#ifndef pdp11
-static OFF_T dget(which) int which; {
-       OFF_T temp;
-
-       /* note weirdness as files are stored in pdp11 native layout */
-       temp = get(which) & 0177777L;
-       return (get(which) & 0177777L) | (temp << 16);
-}
-#endif
-
 void dseek(which, aloc, s) int which; OFF_T aloc; int s; {
        register STREAM *sp = &Input[which];
        register u_int b, o;
@@ -1938,8 +2008,8 @@ int get(which) int which; {
 #ifdef pdp11
        return(*sp->Iptr++);
 #else
-       temp = *sp->Cptr++ & 0377;
-       return temp | ((*sp->Cptr++ & 0377) << 8);      
+       temp = *sp->Cptr++ & 0xff;
+       return temp | ((*sp->Cptr++ & 0xff) << 8);      
 #endif
 }
 
@@ -1963,10 +2033,10 @@ int getfile(acp, flag, phase) char *acp; int flag; int phase; { /* flag: 1 = fat
        Input[RELOC].bno = -1;
        Input[SYMBOLS].bno = -1;
        Input[STRINGS].bno = -1;
-       dseek(TEXT, 0L, SARMAG);
+       dseek(TEXT, (OFF_T)0L, SARMAG);
        if (Input[TEXT].nsize <= 0)
                error(1, "premature EOF#2");
-       mget((int *)arcmag, SARMAG, TEXT);
+       mget(arcmag, SARMAG, TEXT);
        arcmag[SARMAG] = 0;
        if (strcmp(arcmag, ARMAG))
                return(0);
@@ -2104,18 +2174,23 @@ void error(n, s) int n; char *s; {
 
 void readhdr(loc) OFF_T loc; {
  /*fprintf(stderr, "loc=%08lx\n", loc);*/
+#ifndef pdp11
+       char temp[sizeof (struct exec)];
+#endif
+
        dseek(TEXT, loc, sizeof filhdr);
 #ifdef pdp11
-       mget((int *)&filhdr.e, sizeof filhdr.e, TEXT);
+       mget((char *)&filhdr.e, sizeof filhdr.e, TEXT);
 #else
-       filhdr.e.a_magic = get(TEXT);
-       filhdr.e.a_text = get(TEXT);
-       filhdr.e.a_data = get(TEXT);
-       filhdr.e.a_bss = get(TEXT);
-       filhdr.e.a_syms = get(TEXT);
-       filhdr.e.a_entry = get(TEXT);
-       get(TEXT); /* filhdr.e.a_unused */
-       filhdr.e.a_flag = get(TEXT);
+       mget(temp, sizeof filhdr.e, TEXT);
+       filhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       filhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       filhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       filhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       filhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       filhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       filhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       filhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
 #endif
        if (filhdr.e.a_magic != A_MAGIC1)
                error(1, "bad magic number");
@@ -2205,7 +2280,12 @@ short *lookloc(alp, r) struct local *alp; int r; {
 void roundov() {
        while   (torigin & 077)
                {
-               outw(0, voutb);
+#ifdef pdp11
+               putw(0, voutb);
+#else
+               putc(0, voutb);
+               putc(0, voutb);
+#endif
                torigin += 2;
                }
 }
index 15407bb..9952878 100755 (executable)
@@ -3,5 +3,5 @@ ROOT="`pwd |sed -e 's/\/bin\/ld$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
 mkdir --parents "$ROOT/cross/usr/man/cat1"
-make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib"
+make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib" && \
 make DESTDIR="$ROOT/cross" install
index b3eeda5..d5298db 100755 (executable)
--- a/bin/n.sh
+++ b/bin/n.sh
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/bin$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
-make CC="$CC" SEPFLAG= size
+make CC="$CC" SEPFLAG= size && \
 install -s size -m 755 "$ROOT/cross/bin"
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 8047b83..316176f 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/bin\/nm$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 342e3f3..905f89f 100755 (executable)
@@ -54,11 +54,6 @@ int nextel PARAMS((FILE *af));
 void error PARAMS((int n, char *s));
 int _get_arobj PARAMS((FILE *fp));
 
-#ifndef pdp11
-static int get PARAMS((FILE *fp));
-static OFF_T dget PARAMS((FILE *fp));
-#endif
-
 int main(argc, argv) int argc; char **argv; {
        if (--argc>0 && argv[1][0]=='-' && argv[1][1]!=0) {
                argv++;
@@ -108,6 +103,10 @@ int main(argc, argv) int argc; char **argv; {
 void namelist() {
        char    ibuf[BUFSIZ];
        register FILE   *fi;
+#ifndef pdp11
+       /* note: must be at least as large as SARMAG+1, struct nlist, OFF_T */
+       char    temp[sizeof(struct xexec)];
+#endif
 
        archive = 0;
        fi = fopen(*xargv, "r");
@@ -120,29 +119,24 @@ void namelist() {
        off = 0;
 #ifdef pdp11
        fread((char *)&mag_un, 1, sizeof(mag_un), fi);
-       if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0) {
-               archive++;
-               off = SARMAG;
-       }
-       else if (N_BADMAG(mag_un.mag_exp.e)) {
-               error(0, "bad format");
-               goto out;
-       }
+       if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0)
 #else
-       fread((char *)&mag_un, 1, sizeof(mag_un.mag_armag), fi);
-       if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0) {
+       fread(temp, 1, sizeof(mag_un), fi);
+       if (strncmp(temp, ARMAG, SARMAG)==0)
+#endif
+       {
                archive++;
                off = SARMAG;
        }
        else {
-               rewind(fi);
-               mag_un.mag_exp.e.a_magic = get(fi);
+#ifndef pdp11
+               mag_un.mag_exp.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+#endif
                if (N_BADMAG(mag_un.mag_exp.e)) {
                        error(0, "bad format");
                        goto out;
                }
        }
-#endif
        rewind(fi);
 
        if (archive) {
@@ -156,28 +150,29 @@ void namelist() {
                register int i, n;
                struct nlist *symp = NULL;
                struct  nlist sym;
-#ifndef pdp11
-               int type;
-#endif
 
                curpos = ftell(fi);
 #ifdef pdp11
                fread((char *)&mag_un.mag_exp, 1, sizeof(struct xexec), fi);
 #else
-               mag_un.mag_exp.e.a_magic = get(fi);
-               mag_un.mag_exp.e.a_text = get(fi);
-               mag_un.mag_exp.e.a_data = get(fi);
-               mag_un.mag_exp.e.a_bss = get(fi);
-               mag_un.mag_exp.e.a_syms = get(fi);
-               mag_un.mag_exp.e.a_entry = get(fi);
-               get(fi); /* mag_un.mag_exp.e.a_unused */
-               mag_un.mag_exp.e.a_flag = get(fi);
+               fread(temp, 1, sizeof(struct xexec), fi);
+               mag_un.mag_exp.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+               mag_un.mag_exp.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+               mag_un.mag_exp.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+               mag_un.mag_exp.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+               mag_un.mag_exp.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+               mag_un.mag_exp.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+               mag_un.mag_exp.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+               mag_un.mag_exp.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+               mag_un.mag_exp.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
+               for (i = 0; i < NOVL; ++i)
+                       mag_un.mag_exp.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
 #endif
                if (N_BADMAG(mag_un.mag_exp.e))
                        continue;
 
                o = N_SYMOFF(mag_un.mag_exp);
-               fseek(fi, curpos + o, L_SET);
+               fseek(fi, (off_t)(curpos + o), L_SET);
                n = mag_un.mag_exp.e.a_syms / sizeof(struct nlist);
                if (n == 0) {
                        error(0, "no name list");
@@ -191,12 +186,12 @@ void namelist() {
 #ifdef pdp11
                        fread((char *)&sym, 1, sizeof(sym), fi);
 #else
-                       sym.n_un.n_strx = dget(fi);
-                       type = get(fi);
-                       sym.n_ovly = (type >> 8) & 0377;
-                       type &= 0377;
-                       sym.n_type = type;
-                       sym.n_value = get(fi);
+                       fread(temp, 1, sizeof(sym), fi);
+                       sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+                       sym.n_type = temp[4] & 0xff;
+                       sym.n_ovly = temp[5] & 0xff;
+                       sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                        if (sym.n_un.n_strx == 0)
                                continue;
@@ -207,7 +202,7 @@ void namelist() {
                        i++;
                }
 
-               fseek(fi, curpos + o, L_SET);
+               fseek(fi, (off_t)(curpos + o), L_SET);
                symp = (struct nlist *)malloc(i * sizeof (struct nlist));
                if (symp == 0)
                        error(1, "out of memory");
@@ -217,12 +212,12 @@ void namelist() {
 #ifdef pdp11
                        fread((char *)&sym, 1, sizeof(sym), fi);
 #else
-                       sym.n_un.n_strx = dget(fi);
-                       type = get(fi);
-                       sym.n_ovly = (type >> 8) & 0377;
-                       type &= 0377;
-                       sym.n_type = type;
-                       sym.n_value = get(fi);
+                       fread(temp, 1, sizeof(sym), fi);
+                       sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+                       sym.n_type = temp[4] & 0xff;
+                       sym.n_ovly = temp[5] & 0xff;
+                       sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                        if (sym.n_un.n_strx == 0)
                                continue;
@@ -233,14 +228,18 @@ void namelist() {
                        symp[i++] = sym;
                }
                stroff = curpos + N_STROFF(mag_un.mag_exp);
-               fseek(fi, stroff, L_SET);
+               fseek(fi, (off_t)stroff, L_SET);
 #ifdef pdp11
-               if (fread(&strsiz, sizeof (long), 1, fi) != 1)
+               if (fread(&strsiz, sizeof (OFF_T), 1, fi) != 1)
 #else
-               strsiz = dget(fi);
-               if (ferror(fi) || feof(fi))
+               if (fread(temp, sizeof (OFF_T), 1, fi) != 1)
 #endif
+
                        error(1, "no string table");
+#ifndef pdp11
+               strsiz = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+#endif
                strp = (char *)malloc((int)strsiz);
                if (strp == NULL || strsiz > 48 * 1024L)
                        error(1, "ran out of memory");
@@ -266,23 +265,6 @@ out:
        fclose(fi);
 }
 
-#ifndef pdp11
-static int get(fp) FILE *fp; {
-       register int temp;
-
-       temp = getc(fp) & 0377;
-       return temp | ((getc(fp) & 0377) << 8); 
-}
-
-static OFF_T dget(fp) FILE *fp; {
-       OFF_T temp;
-
-       /* note weirdness as fples are stored in pdp11 native layout */
-       temp = get(fp) & 0177777L;
-       return (get(fp) & 0177777L) | (temp << 16);
-}
-#endif
-
 void psyms(symp, nsyms) register struct nlist *symp; int nsyms; {
        register int n, c;
 
@@ -351,7 +333,7 @@ int compare(p1, p2) register struct nlist *p1; register struct nlist *p2; {
 }
 
 int nextel(af) FILE *af; {
-       fseek(af, off, L_SET);
+       fseek(af, (off_t)off, L_SET);
        if (_get_arobj(af) < 0)
                return(0);
        off += (sizeof (struct ar_hdr) + chdr.size + 
index 20ec704..fe4efab 100644 (file)
@@ -22,8 +22,8 @@ int   header;
 
 int main(argc, argv) int argc; char **argv; {
 #ifndef pdp11
-       /* note: this has to be at least as large as struct exec */
-       unsigned char temp[sizeof(struct ovlhdr)];
+       /* note: must be at least as large as struct exec */
+       char temp[sizeof(struct ovlhdr)];
 #endif
        struct exec buf;
        OFF_T sum;
@@ -55,14 +55,14 @@ int main(argc, argv) int argc; char **argv; {
 #else
                if (fread(temp, sizeof(buf), 1, f) != 1)
                        goto bad_read;
-               buf.a_magic = temp[0] | (temp[1] << 8);
-               buf.a_text = temp[2] | (temp[3] << 8);
-               buf.a_data = temp[4] | (temp[5] << 8);
-               buf.a_bss = temp[6] | (temp[7] << 8);
-               buf.a_syms = temp[8] | (temp[9] << 8);
-               buf.a_entry = temp[10] | (temp[11] << 8);
-               buf.a_unused = temp[12] | (temp[13] << 8);
-               buf.a_flag = temp[14] | (temp[15] << 8);
+               buf.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+               buf.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+               buf.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+               buf.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+               buf.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+               buf.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+               buf.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+               buf.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
                if (N_BADMAG(buf)) {
                bad_read:
 #endif
@@ -93,9 +93,9 @@ int main(argc, argv) int argc; char **argv; {
                                continue;
                        }
 #ifndef pdp11
-                       ovlbuf.max_ovl = temp[0] | (temp[1] << 8);
+                       ovlbuf.max_ovl = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
                        for (i = 0; i < NOVL; ++i)
-                               ovlbuf.ov_siz[i] = temp[2 + i * 2] | (temp[3 + i * 2] << 8);
+                               ovlbuf.ov_siz[i] = (temp[i * 2 + 2] & 0xff) | ((temp[i * 2 + 3] & 0xff) << 8);
 #endif
                        coresize = buf.a_text;
                        for (i = 0; i < NOVL; i++)
index f36c4a1..38c729b 100644 (file)
@@ -396,45 +396,19 @@ void reducelit(at) struct node *at; {
        nlit++;
 }
 
-#ifdef PDP11
-/* VARARGS1 */
-char *copy(na, ap) int na; int ap; {
-       register char *p, *np;
-       char *onp;
-       register int n;
-
-       p = ap;
-       n = 0;
-       if (*p==0)
-               return(0);
-       do
-               n++;
-       while (*p++);
-       if (na>1) {
-               p = (&ap)[1];
-               while (*p++)
-                       n++;
-       }
-       onp = np = alloc(n);
-       p = ap;
-       while (*np++ = *p++)
-               ;
-       if (na>1) {
-               p = (&ap)[1];
-               np--;
-               while (*np++ = *p++);
-       }
-       return(onp);
-}
+#ifdef __STDC__
+char *copy(int na, ...)
 #else
-char *copy(int na, ...) {
+char *copy(na, va_alist) int na; va_dcl 
+#endif
+{
        va_list ap;
        char *a0, *a1;
        register char *p, *np;
        char *onp;
        register int n;
 
-       va_start(ap, na);
+       VA_START(ap, na);
        a0 = va_arg(ap, char *);
        p = a0;
        n = 0;
@@ -461,8 +435,6 @@ char *copy(int na, ...) {
        return(onp);
 }
 
-#endif
-
 void opsetup() {
        register struct optab *optp, **ophp;
        register char *p;
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 85fb700..3599cba 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/lib\/c2$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/lib"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index ee5dedf..ff10e7b 100644 (file)
@@ -544,7 +544,7 @@ void werror(s, va_alist) char *s; va_dcl
        if (filename[0])
                fprintf(stderr, "%s:", filename);
        fprintf(stderr, "%d: warning: ", line);
-       va_start(ap, s);
+       VA_START(ap, s);
        vfprintf(stderr, s, ap);
        va_end(ap);
        fprintf(stderr, "\n");
@@ -562,7 +562,7 @@ void error(s, va_alist) char *s; va_dcl
        if (filename[0])
                fprintf(stderr, "%s:", filename);
        fprintf(stderr, "%d: ", line);
-       va_start(ap, s);
+       VA_START(ap, s);
        vfprintf(stderr, s, ap);
        va_end(ap);
        fprintf(stderr, "\n");
index 47ef77e..99818f0 100644 (file)
@@ -349,7 +349,7 @@ void outcode(s, va_alist) char *s; va_dcl
        bufp = stdout;
        if (strflg)
                bufp = sbufp;
-       va_start(ap, s);
+       VA_START(ap, s);
        for (;;) switch(*s++) {
        case 'B':
                ni = va_arg(ap, int);
index a332266..c017d5c 100644 (file)
@@ -772,7 +772,7 @@ void error(s, va_alist) char *s; va_dcl
 
        nerror++;
        fprintf(stderr, "%d: ", line);
-       va_start(ap, s);
+       VA_START(ap, s);
        vfprintf(stderr, s, ap);
        va_end(ap);
        putc('\n', stderr);
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 07191fa..f923d8b 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/lib\/ccom$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/lib"
-make CC="$CC" LDC0FLAGS= LDC1FLAGS= PURFLAG=
+make CC="$CC" LDC0FLAGS= LDC1FLAGS= PURFLAG= && \
 make DESTDIR="$ROOT/cross" install
index c64db1d..cd70da2 100644 (file)
@@ -746,7 +746,6 @@ void vpperror(s, ap) char *s; va_list ap; {
        ++exfail;
 }
 
-/* VARARGS1 */
 #ifdef __STDC__
 void pperror(char *s, ...)
 #else
@@ -755,12 +754,11 @@ void pperror(s, va_alist) char *s; va_dcl
 {
        va_list ap;
 
-       va_start(ap, s);
+       VA_START(ap, s);
        vpperror(s, ap);
        va_end(ap);
 }
 
-/* VARARGS1 */
 #ifdef __STDC__
 void yyerror(char *s, ...)
 #else
@@ -769,12 +767,11 @@ void yyerror(s, va_alist) char *s; va_dcl
 {
        va_list ap;
 
-       va_start(ap, s);
+       VA_START(ap, s);
        vpperror(s, ap);
        va_end(ap);
 }
 
-/* VARARGS1 */
 #ifdef __STDC__
 void ppwarn(char *s, ...)
 #else
@@ -785,7 +782,7 @@ void ppwarn(s, va_alist) char *s; va_dcl
 
        int fail = exfail;
        exfail = -1;
-       va_start(ap, s);
+       VA_START(ap, s);
        vpperror(s, ap);
        va_end(ap);
        exfail = fail;
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 7d0fe3d..41a1255 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/lib\/cpp$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/lib"
-make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG=
+make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
diff --git a/lib/libc/gen/n.sh b/lib/libc/gen/n.sh
new file mode 100755 (executable)
index 0000000..2d785cf
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+ROOT="`pwd |sed -e 's/\/lib\/libc\/gen$//'`"
+AR="$ROOT/cross/bin/ar"
+AS="$ROOT/cross/bin/as"
+CC="$ROOT/cross/bin/cc"
+CPP="$ROOT/cross/lib/cpp"
+LD="$ROOT/cross/bin/ld"
+LORDER="$ROOT/cross/usr/bin/lorder"
+MKDEP="$ROOT/cross/usr/bin/mkdep"
+RANLIB="$ROOT/cross/usr/bin/ranlib"
+make CC="$CC" MKDEP="$MKDEP" depend && \
+make AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER" LOCALE="LC_ALL=C"
index e8e9302..a4443f0 100644 (file)
@@ -51,8 +51,8 @@ int nlist(name, list, strtab) char *name; struct nlist *list; char *strtab;
 {
        register struct nlist *p, *s;
 #ifndef pdp11
-       /* note: this has to be at least as large as struct nlist */
-       unsigned char temp[sizeof(struct xexec)];
+       /* note: must be at least as large as struct nlist */
+       char temp[sizeof(struct xexec)];
        int i;
 #endif
        struct xexec ebuf;
@@ -73,17 +73,17 @@ int nlist(name, list, strtab) char *name; struct nlist *list; char *strtab;
 #endif
                goto done1;
 #ifndef pdp11
-       ebuf.e.a_magic = temp[0] | (temp[1] << 8);
-       ebuf.e.a_text = temp[2] | (temp[3] << 8);
-       ebuf.e.a_data = temp[4] | (temp[5] << 8);
-       ebuf.e.a_bss = temp[6] | (temp[7] << 8);
-       ebuf.e.a_syms = temp[8] | (temp[9] << 8);
-       ebuf.e.a_entry = temp[10] | (temp[11] << 8);
-       ebuf.e.a_unused = temp[12] | (temp[13] << 8);
-       ebuf.e.a_flag = temp[14] | (temp[15] << 8);
-       ebuf.o.max_ovl = temp[16] | (temp[17] << 8);
+       ebuf.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       ebuf.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       ebuf.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       ebuf.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       ebuf.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       ebuf.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       ebuf.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       ebuf.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+       ebuf.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
        for (i = 0; i < NOVL; ++i)
-               ebuf.o.ov_siz[i] = temp[18 + i * 2] | (temp[19 + i * 2] << 8);
+               ebuf.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
 #endif
        if (N_BADMAG(ebuf.e))
                goto done1;
@@ -125,10 +125,11 @@ int nlist(name, list, strtab) char *name; struct nlist *list; char *strtab;
 #endif
                        goto done2;
 #ifndef pdp11
-               s->n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               s->n_type = temp[4];
-               s->n_ovly = temp[5];
-               s->n_value = temp[6] | (temp[7] << 8);
+               s->n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               s->n_type = temp[4] & 0xff;
+               s->n_ovly = temp[5] & 0xff;
+               s->n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                if (!s->n_un.n_strx)
                        continue;
index 3d95df1..da35593 100755 (executable)
@@ -10,6 +10,6 @@ MKDEP="$ROOT/cross/usr/bin/mkdep"
 RANLIB="$ROOT/cross/usr/bin/ranlib"
 mkdir --parents "$ROOT/stage/lib"
 mkdir --parents "$ROOT/stage/usr/lib"
-make CC="$CC" MKDEP="$MKDEP" depend
-make AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER"
+make CC="$CC" MKDEP="$MKDEP" depend && \
+make AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER" LOCALE="LC_ALL=C" && \
 make RANLIB="$RANLIB" DESTDIR="$ROOT/stage" install
index f3f0ad1..3234a33 100644 (file)
@@ -15,11 +15,11 @@ pdplib pdplib_p: ${ALL}
        -mkdir tmp
        for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
 #      ${AR} cr pdplib `ls tmp/*.o | sort -t/ +1`
-       ${AR} cr pdplib `ls tmp/*.o | sort -t/`
+       ${AR} cr pdplib `ls tmp/*.o | ${LOCALE} sort -t/`
        rm -f tmp/*
        for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
 #      ${AR} cr pdplib_p `ls tmp/*.o | sort -t/ +1`
-       ${AR} cr pdplib_p `ls tmp/*.o | sort -t/`
+       ${AR} cr pdplib_p `ls tmp/*.o | ${LOCALE} sort -t/`
        rm -rf tmp
 
 ${ALL}:        FRC
diff --git a/lib/libc/pdp/csu/n.sh b/lib/libc/pdp/csu/n.sh
new file mode 100755 (executable)
index 0000000..1294e06
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+ROOT="`pwd |sed -e 's/\/lib\/libc\/pdp\/csu$//'`"
+mkdir --parents "$ROOT/stage/lib"
+#make CC="$ROOT/cross/bin/cc" MKDEP="$ROOT/cross/usr/bin/mkdep" depend
+make AR="$ROOT/cross/bin/ar" AS="$ROOT/cross/bin/as" CC="$ROOT/cross/bin/cc" CPP="$ROOT/cross/lib/cpp" LD="$ROOT/cross/bin/ld" LORDER="$ROOT/cross/usr/bin/lorder" RANLIB="$ROOT/cross/usr/bin/ranlib" DESTDIR="$ROOT/stage"
index 60cbd38..b287471 100644 (file)
@@ -31,7 +31,8 @@ OBJS= bcmp.o bcopy.o bzero.o ffs.o htonl.o htons.o insque.o \
        ${LD} -X -r $*.o
        mv a.out $*.o
 
-all: FRC libkern.a
+#all: FRC libkern.a
+all: libkern.a
 
 libkern.a: ${OBJS}
        rm -f libkern.a
@@ -43,12 +44,14 @@ clean:
 depend: ${SRCS}
        ${MKDEP} ${CFLAGS} ${SRCS}
 
-install: FRC libkern.a
+#install: FRC libkern.a
+install: libkern.a
 #      install -o root -g bin -m 644 libkern.a ${DESTDIR}/usr/lib/libkern.a
        install -m 644 libkern.a ${DESTDIR}/usr/lib/libkern.a
        ${RANLIB} ${DESTDIR}/usr/lib/libkern.a
 
-FRC:
+#FRC:
+${SRCS}:
        rm -f ${SRCS}
        ln -s ${PREFIX}/gen/bcmp.s bcmp.s 
        ln -s ${PREFIX}/gen/bcopy.s bcopy.s
index bc7b6fc..87c46ab 100755 (executable)
@@ -9,6 +9,6 @@ LORDER="$ROOT/cross/usr/bin/lorder"
 MKDEP="$ROOT/cross/usr/bin/mkdep"
 RANLIB="$ROOT/cross/usr/bin/ranlib"
 mkdir --parents "$ROOT/stage/usr/lib"
-make CC="$CC" MKDEP="$MKDEP" depend
+make CC="$CC" MKDEP="$MKDEP" depend && \
 make AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER"
 make RANLIB="$RANLIB" DESTDIR="$ROOT/stage" install
diff --git a/n.sh b/n.sh
index 606e1c1..c596376 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -e
 
 ROOT="`pwd`"
 
@@ -83,7 +83,7 @@ make -C include SHARED=copies SYSDIR="$ROOT/sys" DESTDIR="$ROOT/stage" install
 
 # do /lib/libc.a next, since everything needs it
 make -C lib/libc CC="$CC" MKDEP="$MKDEP" depend
-make -C lib/libc AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER"
+make -C lib/libc AR="$AR" AS="$AS" CC="$CC" CPP="$CPP" LD="$LD" LORDER="$LORDER" LOCALE="LC_ALL=C"
 make -C lib/libc RANLIB="$RANLIB" DESTDIR="$ROOT/stage" install
 
 # now we can build a test program, see test/hello.c
index c6667e2..e6ae679 100644 (file)
@@ -191,7 +191,7 @@ checksys.o: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
 checksys.o: /home/nick/src/211bsd.git/stage/usr/include/unistd.h
 checksys.o: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
 checksys.o: /home/nick/src/211bsd.git/stage/usr/include/machine/machparam.h
-checksys.o: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h csym.h
+checksys.o: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
 checksys.o: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
 checksys.o: /home/nick/src/211bsd.git/stage/usr/include/varargs.h
 
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index e5803b4..fc1b2fd 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/ucb\/strcompact$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/ucb"
-make CC="$CC" SEPFLAG= CROSSDIR="$ROOT/cross" LOCALE="LC_ALL=C "
+make CC="$CC" SEPFLAG= CROSSDIR="$ROOT/cross" LOCALE="LC_ALL=C " && \
 make DESTDIR="$ROOT/cross" install
index a6d31cf..4bd89e1 100644 (file)
@@ -66,8 +66,8 @@ int main(argc, argv) int argc; char **argv; {
 #endif
        char    symname[64], savedname[64];
 #ifndef pdp11
-       /* note: this has to be at least as large as struct(nlist) and OFF_T */
-       unsigned char temp[sizeof(struct xexec)];
+       /* note: must be at least as large as struct(nlist), OFF_T */
+       char    temp[sizeof(struct xexec)];
        int     i;
 #endif
        struct  xexec   xhdr;
@@ -106,17 +106,17 @@ register FILE     *fpin;
                exit(EX_DATAERR);
                }
 #ifndef pdp11
-       xhdr.e.a_magic = temp[0] | (temp[1] << 8);
-       xhdr.e.a_text = temp[2] | (temp[3] << 8);
-       xhdr.e.a_data = temp[4] | (temp[5] << 8);
-       xhdr.e.a_bss = temp[6] | (temp[7] << 8);
-       xhdr.e.a_syms = temp[8] | (temp[9] << 8);
-       xhdr.e.a_entry = temp[10] | (temp[11] << 8);
-       xhdr.e.a_unused = temp[12] | (temp[13] << 8);
-       xhdr.e.a_flag = temp[14] | (temp[15] << 8);
-       xhdr.o.max_ovl = temp[16] | (temp[17] << 8);
+       xhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       xhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       xhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       xhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       xhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       xhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       xhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       xhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+       xhdr.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
        for (i = 0; i < NOVL; ++i)
-               xhdr.o.ov_siz[i] = temp[18 + i * 2] | (temp[19 + i * 2] << 8);
+               xhdr.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
 #endif
        if      (N_BADMAG(xhdr.e))
                {
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 84028da..a477ec6 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/ucb\/symcompact$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/ucb"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 7c6a7f4..0ca2866 100644 (file)
@@ -79,8 +79,8 @@ int main(argc, argv) int argc; char **argv; {
        register struct nlist   *sp, *sp2;
        struct  nlist   *symtab, *symtabend, syment;
 #ifndef pdp11
-       /* note: this has to be at least as large as struct(nlist) and OFF_T */
-       unsigned char temp[sizeof(struct xexec)];
+       /* note: must be at least as large as struct(nlist), OFF_T */
+       char    temp[sizeof(struct xexec)];
 #endif
        struct  xexec   xhdr;
 
@@ -113,17 +113,17 @@ int main(argc, argv) int argc; char **argv; {
                exit(EX_DATAERR);
                }
 #ifndef pdp11
-       xhdr.e.a_magic = temp[0] | (temp[1] << 8);
-       xhdr.e.a_text = temp[2] | (temp[3] << 8);
-       xhdr.e.a_data = temp[4] | (temp[5] << 8);
-       xhdr.e.a_bss = temp[6] | (temp[7] << 8);
-       xhdr.e.a_syms = temp[8] | (temp[9] << 8);
-       xhdr.e.a_entry = temp[10] | (temp[11] << 8);
-       xhdr.e.a_unused = temp[12] | (temp[13] << 8);
-       xhdr.e.a_flag = temp[14] | (temp[15] << 8);
-       xhdr.o.max_ovl = temp[16] | (temp[17] << 8);
+       xhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       xhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       xhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       xhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       xhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       xhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       xhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       xhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+       xhdr.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
        for (i = 0; i < NOVL; ++i)
-               xhdr.o.ov_siz[i] = temp[18 + i * 2] | (temp[19 + i * 2] << 8);
+               xhdr.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
 #endif
        if      (N_BADMAG(xhdr.e))
                {
@@ -148,7 +148,8 @@ int main(argc, argv) int argc; char **argv; {
        fread(&strsiz, sizeof (OFF_T), 1, fp);
 #else
        fread(temp, sizeof (OFF_T), 1, fp);
-       strsiz = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
+       strsiz = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
        if      (strsiz > 48 * 1024L)
                {
@@ -185,10 +186,11 @@ int main(argc, argv) int argc; char **argv; {
                fread(&syment, sizeof (syment), 1, fp);
 #else
                fread(temp, sizeof (syment), 1, fp);
-               syment.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               syment.n_type = temp[4];
-               syment.n_ovly = temp[5];
-               syment.n_value = temp[6] | (temp[7] << 8);
+               syment.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               syment.n_type = temp[4] & 0xff;
+               syment.n_ovly = temp[5] & 0xff;
+               syment.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                if      (exclude(&syment))
                        continue;
@@ -218,10 +220,11 @@ int main(argc, argv) int argc; char **argv; {
                fread(&syment, sizeof (syment), 1, fp);
 #else
                fread(temp, sizeof (syment), 1, fp);
-               syment.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               syment.n_type = temp[4];
-               syment.n_ovly = temp[5];
-               syment.n_value = temp[6] | (temp[7] << 8);
+               syment.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               syment.n_type = temp[4] & 0xff;
+               syment.n_ovly = temp[5] & 0xff;
+               syment.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                if      (exclude(&syment))
                        continue;
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 0b0291c..d414b9d 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/ucb\/symdump$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/ucb"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 7fa5caa..5126a33 100644 (file)
@@ -63,8 +63,8 @@ int main(argc, argv) int argc; char **argv; {
 
 void namelist() {
 #ifndef pdp11
-       /* note: this has to be at least as large as OFF_T */
-       unsigned char temp[sizeof(struct xexec)];
+       /* note: must be at least as large as OFF_T */
+       char    temp[sizeof(struct xexec)];
        int     i;
 #endif
        char    ibuf[BUFSIZ];
@@ -85,17 +85,17 @@ void namelist() {
 #endif
                error("error reading header");
 #ifndef pdp11
-       xhdr.e.a_magic = temp[0] | (temp[1] << 8);
-       xhdr.e.a_text = temp[2] | (temp[3] << 8);
-       xhdr.e.a_data = temp[4] | (temp[5] << 8);
-       xhdr.e.a_bss = temp[6] | (temp[7] << 8);
-       xhdr.e.a_syms = temp[8] | (temp[9] << 8);
-       xhdr.e.a_entry = temp[10] | (temp[11] << 8);
-       xhdr.e.a_unused = temp[12] | (temp[13] << 8);
-       xhdr.e.a_flag = temp[14] | (temp[15] << 8);
-       xhdr.o.max_ovl = temp[16] | (temp[17] << 8);
+       xhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       xhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       xhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       xhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       xhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       xhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       xhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       xhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+       xhdr.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
        for (i = 0; i < NOVL; ++i)
-               xhdr.o.ov_siz[i] = temp[18 + i * 2] | (temp[19 + i * 2] << 8);
+               xhdr.o.ov_siz[i] = (temp[18 + i * 2] & 0xff) | ((temp[19 + i * 2] & 0xff) << 8);
 #endif
        if      (N_BADMAG(xhdr.e))
                error("bad format");
@@ -116,7 +116,8 @@ void namelist() {
 #endif
                error("no string table");
 #ifndef pdp11
-       strsiz = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
+       strsiz = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
        strp = (char *)malloc((int)strsiz);
        if      (strp == NULL || strsiz > 48 * 1024L)
@@ -133,7 +134,7 @@ void namelist() {
 void dumpsyms(fi, nsyms) register FILE *fi; int nsyms; {
        register int n;
 #ifndef pdp11
-       unsigned char temp[sizeof(struct nlist)];
+       char    temp[sizeof(struct nlist)];
 #endif
        struct  nlist sym;
        register struct nlist *sp;
@@ -148,10 +149,11 @@ void dumpsyms(fi, nsyms) register FILE *fi; int nsyms; {
 #endif
                        error("error reading sym");
 #ifndef pdp11
-               sym.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               sym.n_type = temp[4];
-               sym.n_ovly = temp[5];
-               sym.n_value = temp[6] | (temp[7] << 8);
+               sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               sym.n_type = temp[4] & 0xff;
+               sym.n_ovly = temp[5] & 0xff;
+               sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                printf("%s %u %u %u\n", strp + (int)sp->n_un.n_strx, sp->n_type,
                        sp->n_ovly, sp->n_value);
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index 7cc2a3c..3bca54f 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/ucb\/symorder$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/ucb"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 72e292b..dfddf39 100644 (file)
@@ -61,8 +61,8 @@ int main(argc, argv) int argc; char **argv; {
        OFF_T   strsiz;
        struct  nlist   sym;
 #ifndef pdp11
-       /* note: this has to be at least as large as struct(nlist) and OFF_T */
-       unsigned char temp[sizeof(struct xexec)];
+       /* note: must be at least as large as struct(nlist), OFF_T */
+       char    temp[sizeof(struct xexec)];
        int     i;
 #endif
        struct  xexec   xhdr;
@@ -97,17 +97,17 @@ int main(argc, argv) int argc; char **argv; {
                exit(EX_DATAERR);
                }
 #ifndef pdp11
-       xhdr.e.a_magic = temp[0] | (temp[1] << 8);
-       xhdr.e.a_text = temp[2] | (temp[3] << 8);
-       xhdr.e.a_data = temp[4] | (temp[5] << 8);
-       xhdr.e.a_bss = temp[6] | (temp[7] << 8);
-       xhdr.e.a_syms = temp[8] | (temp[9] << 8);
-       xhdr.e.a_entry = temp[10] | (temp[11] << 8);
-       xhdr.e.a_unused = temp[12] | (temp[13] << 8);
-       xhdr.e.a_flag = temp[14] | (temp[15] << 8);
-       xhdr.o.max_ovl = temp[16] | (temp[17] << 8);
+       xhdr.e.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       xhdr.e.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       xhdr.e.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       xhdr.e.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       xhdr.e.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       xhdr.e.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       xhdr.e.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       xhdr.e.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
+       xhdr.o.max_ovl = (temp[16] & 0xff) | ((temp[17] & 0xff) << 8);
        for (i = 0; i < NOVL; ++i)
-               xhdr.o.ov_siz[i] = temp[18 + i * 2] | (temp[19 + i * 2] << 8);
+               xhdr.o.ov_siz[i] = (temp[i * 2 + 18] & 0xff) | ((temp[i * 2 + 19] & 0xff) << 8);
 #endif
        if      (N_BADMAG(xhdr.e))
                {
@@ -132,7 +132,8 @@ int main(argc, argv) int argc; char **argv; {
        fread(&strsiz, sizeof (OFF_T), 1, fp);
 #else
        fread(temp, sizeof (OFF_T), 1, fp);
-       strsiz = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
+       strsiz = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+           (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
 #endif
        if      (strsiz > 48 * 1024L)
                {
@@ -218,10 +219,11 @@ int main(argc, argv) int argc; char **argv; {
                fread(&sym, sizeof (sym), 1, fp);
 #else
                fread(temp, sizeof (sym), 1, fp);
-               sym.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               sym.n_type = temp[4];
-               sym.n_ovly = temp[5];
-               sym.n_value = temp[6] | (temp[7] << 8);
+               sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               sym.n_type = temp[4] & 0xff;
+               sym.n_ovly = temp[5] & 0xff;
+               sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                if      (sym.n_type == N_REG)
                        continue;
@@ -265,10 +267,10 @@ int main(argc, argv) int argc; char **argv; {
                if      (ferror(sym1fp) || feof(sym1fp))
                        break;
 #ifndef pdp11
-               sym.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               sym.n_type = temp[4];
-               sym.n_ovly = temp[5];
-               sym.n_value = temp[6] | (temp[7] << 8);
+               sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) | (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               sym.n_type = temp[4] & 0xff;
+               sym.n_ovly = temp[5] & 0xff;
+               sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                oldname = strtab + (int)sym.n_un.n_strx;
                sym.n_un.n_strx = ltmp;
@@ -300,10 +302,11 @@ int main(argc, argv) int argc; char **argv; {
                if      (ferror(sym2fp) || feof(sym2fp))
                        break;
 #ifndef pdp11
-               sym.n_un.n_strx = (temp[0] << 16) | (temp[1] << 24) | temp[2] | (temp[3] << 8);
-               sym.n_type = temp[4];
-               sym.n_ovly = temp[5];
-               sym.n_value = temp[6] | (temp[7] << 8);
+               sym.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               sym.n_type = temp[4] & 0xff;
+               sym.n_ovly = temp[5] & 0xff;
+               sym.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
 #endif
                oldname = strtab + (int)sym.n_un.n_strx;
                sym.n_un.n_strx = ltmp;
index 890f78b..2543e0e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 ROOT="`pwd |sed -e 's/\/usr\.bin$//'`"
 mkdir --parents "$ROOT/cross/usr/bin"
-make CC="$ROOT/cross/bin/cc" NM="$ROOT/cross/bin/nm" lorder mkdep
+make CC="$ROOT/cross/bin/cc" NM="$ROOT/cross/bin/nm" lorder mkdep && \
 install lorder -m 755 "$ROOT/cross/usr/bin"
 install mkdep -m 755 "$ROOT/cross/usr/bin"
index 20e4313..d6a13bd 100755 (executable)
@@ -75,19 +75,12 @@ typedef struct _rlib {
 RLIB *rhead, **pnext;
 
 FILE *fp;
-long symcnt;                           /* symbol count */
-long tsymlen;                          /* total string length */
+OFF_T symcnt;                          /* symbol count */
+OFF_T tsymlen;                         /* total string length */
 
 static void rexec PARAMS((int rfd, int wfd));
 static void symobj PARAMS((void));
 
-#ifndef pdp11
-static void outw PARAMS((int n, FILE *fp));
-static void outd PARAMS((OFF_T n, FILE *fp));
-static int get PARAMS((FILE *fp));
-static OFF_T dget PARAMS((FILE *fp));
-#endif
-
 int build() {
        CF cf;
        int afd, tfd;
@@ -103,6 +96,7 @@ int build() {
        pnext = &rhead;
        symcnt = tsymlen = 0;
        while(get_arobj(afd)) {
+ /*fprintf(stderr, "member: %s\n", chdr.name);*/
                if (!strcmp(chdr.name, RANLIBMAG)) {
                        skip_arobj(afd);
                        continue;
@@ -138,15 +132,12 @@ static void rexec(rfd, wfd) int rfd; int wfd; {
        register RLIB *rp;
        RLIB **savnext;
        long nsyms;
-#if 1
-#ifndef pdp11
-       register int type;
-#endif
-       register int symlen;
-#else
        register int nr, symlen;
-#endif
        char sym[512];          /* XXX - more than enough (we hope) */
+#ifndef pdp11
+       /* note: must be at least as large as struct nlist */
+       char temp[sizeof(struct exec)];
+#endif
        struct exec ebuf;
        struct nlist nl;
        OFF_T r_off, w_off, sympos;
@@ -157,28 +148,22 @@ static void rexec(rfd, wfd) int rfd; int wfd; {
        w_off = lseek(wfd, (off_t)0, L_INCR);
 
        /* Read in exec structure. */
-#if 1
-       if (fseek(fp, (off_t)r_off, L_SET) == (off_t)-1)
-               goto bad1;
 #ifdef pdp11
-       if (fread((char *)&ebuf, sizeof(struct exec), 1, fp) != 1)
-               goto bad1;
+       nr = read(rfd, (char *)&ebuf, sizeof(struct exec));
 #else
-       ebuf.a_magic = get(fp);
-       ebuf.a_text = get(fp);
-       ebuf.a_data = get(fp);
-       ebuf.a_bss = get(fp);
-       ebuf.a_syms = get(fp);
-       ebuf.a_entry = get(fp);
-       get(fp); /* ebuf.a_unused */
-       ebuf.a_flag = get(fp);
-       if (ferror(fp) || feof(fp))
-               goto bad1;
+       nr = read(rfd, temp, sizeof(struct exec));
 #endif
-#else
-       nr = read(rfd, (char *)&ebuf, sizeof(struct exec));
        if (nr != sizeof(struct exec))
                goto bad1;
+#ifndef pdp11
+       ebuf.a_magic = (temp[0] & 0xff) | ((temp[1] & 0xff) << 8);
+       ebuf.a_text = (temp[2] & 0xff) | ((temp[3] & 0xff) << 8);
+       ebuf.a_data = (temp[4] & 0xff) | ((temp[5] & 0xff) << 8);
+       ebuf.a_bss = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+       ebuf.a_syms = (temp[8] & 0xff) | ((temp[9] & 0xff) << 8);
+       ebuf.a_entry = (temp[10] & 0xff) | ((temp[11] & 0xff) << 8);
+       ebuf.a_unused = (temp[12] & 0xff) | ((temp[13] & 0xff) << 8);
+       ebuf.a_flag = (temp[14] & 0xff) | ((temp[15] & 0xff) << 8);
 #endif
 
        /* Check magic number and symbol count. */
@@ -201,19 +186,20 @@ static void rexec(rfd, wfd) int rfd; int wfd; {
 #ifdef pdp11
                if (!fread((char *)&nl, sizeof(struct nlist), 1, fp))
 #else
-               nl.n_un.n_strx = dget(fp);
-               type = get(fp);
-               nl.n_ovly = (type >> 8) & 0377;
-               type &= 0377;
-               nl.n_type = type;
-               nl.n_value = get(fp);
-               if (ferror(fp) || feof(fp))
+               if (!fread(temp, sizeof(struct nlist), 1, fp))
 #endif
                {
                        if (feof(fp))
                                badfmt();
                        error(archive);
                }
+#ifndef pdp11
+               nl.n_un.n_strx = ((temp[0] & 0xffL) << 16) | ((temp[1] & 0xffL) << 24) |
+                   (temp[2] & 0xffL) | ((temp[3] & 0xffL) << 8);
+               nl.n_type = temp[4] & 0xff;
+               nl.n_ovly = temp[5] & 0xff;
+               nl.n_value = (temp[6] & 0xff) | ((temp[7] & 0xff) << 8);
+#endif
 
                /* Ignore if no name or local. */
                if (!nl.n_un.n_strx || !(nl.n_type & N_EXT))
@@ -247,23 +233,6 @@ static void rexec(rfd, wfd) int rfd; int wfd; {
 bad1:  (void)lseek(rfd, (off_t)r_off, L_SET);
 }
 
-#ifndef pdp11
-static int get(fp) FILE *fp; {
-       register int temp;
-
-       temp = getc(fp) & 0377;
-       return temp | ((getc(fp) & 0377) << 8); 
-}
-
-static OFF_T dget(fp) FILE *fp; {
-       OFF_T temp;
-
-       /* note weirdness as fples are stored in pdp11 native layout */
-       temp = get(fp) & 0177777L;
-       return (get(fp) & 0177777L) | (temp << 16);
-}
-#endif
-
 /*
  * symobj --
  *     Write the symbol table into the archive, computing offsets as
@@ -274,6 +243,10 @@ static void symobj() {
        struct ranlib rn;
        char hb[sizeof(struct ar_hdr) + 1], pad;
        OFF_T ransize, size, stroff;
+#ifndef pdp11
+       /* note: must be at least as large as OFF_T */
+       char temp[sizeof(struct ranlib)];
+#endif
        gid_t getgid();
        uid_t getuid();
 
@@ -283,7 +256,8 @@ static void symobj() {
 
        /* Size of the ranlib archive file, pad if necessary. */
        ransize = sizeof(OFF_T) +
-           (OFF_T)symcnt * sizeof(struct ranlib) + sizeof(OFF_T) + tsymlen;
+           symcnt * sizeof(struct ranlib) + sizeof(OFF_T) + tsymlen;
+ /*(fprintf(stderr, "symcnt=%ld tsymlen=%ld ransize=%ld\n", symcnt, tsymlen, ransize);*/
        if (ransize & 01) {
                ++ransize;
                pad = '\n';
@@ -297,12 +271,16 @@ static void symobj() {
                error(tname);
 
        /* First long is the size of the ranlib structure section. */
-       size = (OFF_T)symcnt * sizeof(struct ranlib);
+       size = symcnt * sizeof(struct ranlib);
+ /*fprintf(stderr, "size=%ld\n", size);*/
 #ifdef pdp11
        if (!fwrite((char *)&size, sizeof(size), 1, fp))
 #else
-       outd(size, fp);
-       if (ferror(fp))
+       temp[0] = (size >> 16) & 0xff;
+       temp[1] = (size >> 24) & 0xff;
+       temp[2] = size & 0xff;
+       temp[3] = (size >> 8) & 0xff;
+       if (!fwrite(temp, sizeof(size), 1, fp))
 #endif
                error(tname);
 
@@ -315,15 +293,22 @@ static void symobj() {
         * set in rexec() plus the offset to the first archive file.
         */
        for (rp = rhead, stroff = 0; rp; rp = rp->next) {
+ /*fprintf(stderr, "symbol: %s\n", rp->sym);*/
                rn.ran_un.ran_strx = stroff;
                stroff += rp->symlen;
                rn.ran_off = size + rp->pos;
 #ifdef pdp11
                if (!fwrite((char *)&rn, sizeof(struct ranlib), 1, fp))
 #else
-               outd(rn.ran_un.ran_strx, fp);
-               outd(rn.ran_off, fp);
-               if (ferror(fp))
+               temp[0] = (rn.ran_un.ran_strx >> 16) & 0xff;
+               temp[1] = (rn.ran_un.ran_strx >> 24) & 0xff;
+               temp[2] = rn.ran_un.ran_strx & 0xff;
+               temp[3] = (rn.ran_un.ran_strx >> 8) & 0xff;
+               temp[4] = (rn.ran_off >> 16) & 0xff;
+               temp[5] = (rn.ran_off >> 24) & 0xff;
+               temp[6] = rn.ran_off & 0xff;
+               temp[7] = (rn.ran_off >> 8) & 0xff;
+               if (!fwrite(temp, sizeof(struct ranlib), 1, fp))
 #endif
                        error(archive);
        }
@@ -332,8 +317,11 @@ static void symobj() {
 #ifdef pdp11
        if (!fwrite((char *)&tsymlen, sizeof(tsymlen), 1, fp))
 #else
-       outd(tsymlen, fp);
-       if (ferror(fp))
+       temp[0] = (tsymlen >> 16) & 0xff;
+       temp[1] = (tsymlen >> 24) & 0xff;
+       temp[2] = tsymlen & 0xff;
+       temp[3] = (tsymlen >> 8) & 0xff;
+       if (!fwrite(temp, sizeof(tsymlen), 1, fp))
 #endif
                error(tname);
 
@@ -353,19 +341,6 @@ static void symobj() {
        (void)fflush(fp);
 }
 
-#ifndef pdp11
-static void outw(n, fp) int n; FILE *fp; {
-       putc(n & 0377, fp);
-       putc((n >> 8) & 0377, fp);
-}
-
-static void outd(n, fp) OFF_T n; FILE *fp; {
-       /* note weirdness as files are stored in pdp11's native layout */
-       outw((int)(n >> 16) & 0177777, fp);
-       outw((int)n & 0177777, fp);
-}
-#endif
-
 int sgets(buf, n, fp) char *buf; int n; register FILE *fp; {
        register int i, c;
 
index 62f9848..b5c0b7d 100644 (file)
@@ -4,9 +4,11 @@
 #undef PARAMS
 #ifdef __STDC__
 #include <stdarg.h>
+#define VA_START(ap, arg) va_start(ap, arg)
 #define PARAMS(args) args
 #else
 #include <varargs.h>
+#define VA_START(ap, arg) va_start(ap)
 #define PARAMS(args) ()
 #endif
 
index ca7e7dd..8121938 100644 (file)
@@ -87,7 +87,6 @@ void badfmt() {
 }
 
 void error(name) char *name; {
- abort();
        (void)fprintf(stderr, "ranlib: %s: %s\n", name, strerror(errno));
        exit(1);
 }
index a373c4f..6485b0e 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/usr\.bin\/ranlib$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/bin"
-make CC="$CC" SEPFLAG=
+make CC="$CC" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index dabebcc..77a519a 100755 (executable)
@@ -3,5 +3,5 @@ ROOT="`pwd |sed -e 's/\/usr\.lib\/libvmf$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/lib"
 mkdir --parents "$ROOT/cross/usr/man/cat3"
-make CC="$CC"
+make CC="$CC" && \
 make DESTDIR="$ROOT/cross" install