lib/libc/string/stringlib
lib/libc/string/stringlib_p
stage
+test/hello
+test/hello.i
+test/hello.s
usr.lib/libvmf/genlib
usr.lib/libvmf/genlib_p
usr.bin/lorder
#
SEPFLAG=-i
-CPPFLAGS=-DDESTDIR=\"${DESTDIR}\" -DSTAGEDIR=\"${STAGEDIR}\"
+CPPFLAGS=-DCROSSDIR=\"${CROSSDIR}\" -DSTAGEDIR=\"${STAGEDIR}\"
all: cc
#include <unistd.h>
#include "krcompat.h"
-char *cpp = DESTDIR "/lib/cpp";
-char *ccom = DESTDIR "/lib/c0";
-char *ccom1 = DESTDIR "/lib/c1";
-char *c2 = DESTDIR "/lib/c2";
-char *as = DESTDIR "/bin/as";
-char *ld = DESTDIR "/bin/ld";
-char *crt0 = DESTDIR "/lib/crt0.o";
+char *cpp = CROSSDIR "/lib/cpp";
+char *ccom = CROSSDIR "/lib/c0";
+char *ccom1 = CROSSDIR "/lib/c1";
+char *c2 = CROSSDIR "/lib/c2";
+char *as = CROSSDIR "/bin/as";
+char *ld = CROSSDIR "/bin/ld";
+char *crt0 = STAGEDIR "/lib/crt0.o";
char tmp0[30]; /* big enough for /tmp/ctm%05.5d */
char *tmp1, *tmp2, *tmp3, *tmp4, *tmp5;
ROOT="`pwd |sed -e 's/\/bin\/cc$//'`"
CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses"
mkdir --parents "$ROOT/cross/bin"
-make SEPFLAG= DESTDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" install
+make SEPFLAG= CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" DESTDIR="$ROOT/cross" install
install: all
# install -c -s -o bin -g bin -m 755 ld ${DESTDIR}/bin/ld
# install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat1
- install -c -m 755 ld ${DESTDIR}/bin/ld
-#-s FIX THIS
+ install -c -s -m 755 ld ${DESTDIR}/bin/ld
install -c -m 444 ${MAN} ${DESTDIR}/usr/man/cat1
lint:
(temp[2] & 0377L) |
((temp[3] & 0377L) << 8);
#endif
+ /*fprintf(stderr, "ltnum=%08lx\n", ltnum);*/
/*
* calculate string table position. Add in the ranlib size (4 bytes),
* the size of the ranlib structures (ltnum) from above.
*/
nloc += (sizeof (ltnum) + ltnum);
+ /*fprintf(stderr, "nloc=%08lx\n", nloc);*/
tnum = ltnum / sizeof (struct ranlib);
rstrtab = NULL;
(temp[2] & 0377L) |
((temp[3] & 0377L) << 8);
#endif
+ /*fprintf(stderr, "strsize=%08lx\n", strsize);*/
if (strsize <= 8192L)
{
rstrtab = (char *)malloc((int)strsize);
LIBLIST *oldp = libp;
int amt, tnum = totnum;
OFF_T loc;
+ /*fprintf(stderr, "sloc=%08lx tnum=%d\n", sloc, tnum);*/
/*
* 'ar' header + member header + SYMDEF table.of.contents + long filename
*/
ntab = TABSZ;
else
ntab = tnum;
+ /*fprintf(stderr, "ntab=%d opos=%08lx\n", ntab, opos);*/
tplast = &tab[ntab - 1];
(void)lseek(infil, opos, L_SET);
amt = ntab * sizeof (struct ranlib);
sizeof (OFF_T), 07777);
mgets(localname, NNAMESIZE, STRINGS2);
}
+ /*fprintf(stderr, "localname=%s\n", localname);*/
hp = slookup(localname);
if (*hp == -1)
continue;
fwrite(&cursym, sizeof (cursym), 1, soutb);
}
-/* THIS STUFF NEEDS TO BE REWRITTEN TO HANDLE BLOCK BOUNDARIES INTELLIGENTLY */
void mget(loc, an, which) register int *loc; int an; int which; {
register int n;
register STREAM *tp = &Input[which];
-#ifndef pdp11
- int temp;
-#endif
n = an >> 1;
+#if 1
+ 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;
+ n -= tp->nibuf;
+ dseek(which, (OFF_T)(tp->bno + 1) * tp->bsize, -1);
+ }
+ bcopy(tp->Iptr, loc, n * 2);
+ tp->Iptr += n;
+ tp->nibuf -= n;
+#else
if ((tp->nibuf -= n) >= 0) {
if ((tp->nsize -= n) > 0) {
-#ifdef pdp11
bcopy(tp->ptr, loc, an);
tp->Iptr += n;
-#else
- bcopy(tp->Cptr, loc, an);
- tp->Cptr += n << 1;
-#endif
return;
}
tp->nsize += n;
}
tp->nibuf += n;
- do {
-#ifdef pdp11
- *loc++ = get(which);
-#else
- /* kludgey, as we are converting to host byte order in temp, */
- /* then back to target byte order for caller to convert again */
- /* (luckily it only occurs if request crosses block boundary) */
- temp = get(which);
- ((char *)loc)[0] = temp & 0377;
- ((char *)loc++)[1] = (temp >> 8) & 0377;
+ do
+ *loc++ = get(which); /* no good for big-endian cross-compile */
+ while (--n);
#endif
- } while (--n);
}
#ifndef pdp11
}
void readhdr(loc) OFF_T loc; {
+ /*fprintf(stderr, "loc=%08lx\n", loc);*/
dseek(TEXT, loc, sizeof filhdr);
#ifdef pdp11
mget((int *)&filhdr.e, sizeof filhdr.e, TEXT);
#!/bin/sh
ROOT="`pwd |sed -e 's/\/bin\/ld$//'`"
-CFLAGS="-g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses"
+CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses"
mkdir --parents "$ROOT/cross/bin"
mkdir --parents "$ROOT/cross/usr/man/cat1"
make SEPFLAG= DESTDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" LDFLAGS="-L$ROOT/cross/usr/lib" install
struct ranlib {
union {
OFF_T ran_strx; /* string table index */
+/* we do not support ran_name when cross compiling, it breaks on 64-bit hosts */
+#ifdef pdp11
char *ran_name; /* in memory symbol name */
+#endif
} ran_un;
OFF_T ran_off; /* archive file offset */
};
make clean
make -C bin/ar SEPFLAG= DESTDIR="$ROOT/cross" CFLAGS="$CFLAGS" install
make -C bin/as SEPFLAG= DESTDIR="$ROOT/cross" CFLAGS="$CFLAGS" install
-make -C bin/cc SEPFLAG= DESTDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" install
+make -C bin/cc SEPFLAG= CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" DESTDIR="$ROOT/cross" install
make -C bin/ld SEPFLAG= DESTDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" CFLAGS="$CFLAGS" LDFLAGS="-L$ROOT/cross/usr/lib" install
make -C bin/nm SEPFLAG= DESTDIR="$ROOT/cross" CFLAGS="$CFLAGS" install
make -C include SHARED=copies DESTDIR="$ROOT/stage" SYSDIR="$ROOT/sys" install
--- /dev/null
+#!/usr/bin/env python3
+
+import sys
+
+a = sys.stdin.buffer.read()
+i = 0
+while i < len(a):
+ l = min(0x400, len(a) - i)
+ sys.stderr.write('{0:08x} {1:08x} {2:08x}\n'.format(i, len(a), l))
+ sys.stdout.buffer.write(l.to_bytes(4, byteorder = 'little'))
+ sys.stdout.buffer.write(a[i:i + l])
+ i += l
+ sys.stdout.buffer.write(l.to_bytes(4, byteorder = 'little'))
+l = 0
+sys.stdout.buffer.write(l.to_bytes(4, byteorder = 'little'))
+sys.stdout.buffer.write(l.to_bytes(4, byteorder = 'little'))
--- /dev/null
+#include <stdio.h>
+
+int main() {
+ printf("hello, world\n");
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env python3
+
+import sys
+
+a = sys.stdin.buffer.read()
+i = 0
+while i < len(a):
+ l = int.from_bytes(a[i:i + 4], byteorder = 'little')
+ sys.stderr.write('{0:08x} {1:08x} {2:08x}\n'.format(i, len(a), l))
+ i += 4
+ b = a[i:i + l]
+ sys.stdout.buffer.write(b)
+ i += l
+ assert l == int.from_bytes(a[i:i + 4], byteorder = 'little')
+ i += 4
+ if l == 0:
+ break
--- /dev/null
+#!/bin/sh
+../cross/bin/cc -E hello.c >hello.i
+../cross/bin/cc -S hello.c
+../cross/bin/cc -c hello.c
+../cross/bin/cc -o hello hello.o
#!/bin/sh
ROOT="`pwd |sed -e 's/\/usr\.bin\/ranlib$//'`"
-CFLAGS="-g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses"
+CFLAGS="-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-parentheses"
mkdir --parents "$ROOT/cross/usr/bin"
make SEPFLAG= DESTDIR="$ROOT/cross" CFLAGS="$CFLAGS" install