#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
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
#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
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
#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
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
#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
typedef struct
{
union {
+#ifdef pdp11
int *iptr;
+#endif
char *cptr;
} ptr;
int bno;
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
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));
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;
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':
*/
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).
*/
read(infil, <num, 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);*/
/*
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)
* 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;
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
*/
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)
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;
* 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);
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) {
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)
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) {
* 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);
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;
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
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;
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) +
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);
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)
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 +
#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
}
#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
}
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
+ }
}
}
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) {
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)
#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++;
}
#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++;
}
* 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);
}
/*
* 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);
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];
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;
#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
}
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);
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");
void roundov() {
while (torigin & 077)
{
- outw(0, voutb);
+#ifdef pdp11
+ putw(0, voutb);
+#else
+ putc(0, voutb);
+ putc(0, voutb);
+#endif
torigin += 2;
}
}
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
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"
#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
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
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++;
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");
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) {
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");
#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;
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");
#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;
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");
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;
}
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 +
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;
#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
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++)
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;
return(onp);
}
-#endif
-
void opsetup() {
register struct optab *optp, **ophp;
register char *p;
#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
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
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");
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");
bufp = stdout;
if (strflg)
bufp = sbufp;
- va_start(ap, s);
+ VA_START(ap, s);
for (;;) switch(*s++) {
case 'B':
ni = va_arg(ap, int);
nerror++;
fprintf(stderr, "%d: ", line);
- va_start(ap, s);
+ VA_START(ap, s);
vfprintf(stderr, s, ap);
va_end(ap);
putc('\n', stderr);
#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
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
++exfail;
}
-/* VARARGS1 */
#ifdef __STDC__
void pperror(char *s, ...)
#else
{
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
{
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
int fail = exfail;
exfail = -1;
- va_start(ap, s);
+ VA_START(ap, s);
vpperror(s, ap);
va_end(ap);
exfail = fail;
#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
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
--- /dev/null
+#!/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"
{
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;
#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;
#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;
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
-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
--- /dev/null
+#!/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"
${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
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
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
-#!/bin/sh
+#!/bin/sh -e
ROOT="`pwd`"
# 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
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
#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
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
#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;
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))
{
#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
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
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;
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))
{
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)
{
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;
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;
#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
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
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];
#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");
#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)
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;
#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);
#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
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
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;
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))
{
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)
{
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;
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;
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;
#!/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"
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;
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;
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;
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. */
#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))
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
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();
/* 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';
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);
* 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);
}
#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);
(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;
#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
}
void error(name) char *name; {
- abort();
(void)fprintf(stderr, "ranlib: %s: %s\n", name, strerror(errno));
exit(1);
}
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
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