From f5099e7d9a598cb7c166a1cbcbfdbc11ac016e6b Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 26 Feb 1987 19:54:57 +0000 Subject: [PATCH] *** empty log message *** --- mach/6500/dl/dl.c | 92 ++++++++++++++++++++++++--------------- mach/6500/libem/LIST | 2 +- mach/m68k2/dl/Makefile | 31 ++++++------- mach/m68k2/dl/dl.c | 90 ++++++++++++++++++++++---------------- mach/m68k4/libem/Makefile | 14 ++---- mach/ns/libcc/Makefile | 5 ++- 6 files changed, 134 insertions(+), 100 deletions(-) diff --git a/mach/6500/dl/dl.c b/mach/6500/dl/dl.c index 0ee9eb2e4..470206f6b 100644 --- a/mach/6500/dl/dl.c +++ b/mach/6500/dl/dl.c @@ -15,11 +15,9 @@ * */ -#include #include #include - -struct sgttyb tty; +#include #define DATTYPE 0 #define EOFTYPE 1 @@ -38,38 +36,63 @@ char *progname; char hex[] = "0123456789ABCDEF"; +struct outhead ohead; +struct outsect sect[MAXSECT]; + main(argc,argv) char **argv; { - register nd,pc,sg,osg,first; + int i,nd,pc,first; register char *s; + progname = argv[0]; if (argc > 3) fatal("usage: %s [object [tty]]\n",argv[0]); s = "a.out"; if (argc >= 2) s = argv[1]; - if (freopen(s,"r",stdin) == NULL) - fatal("can't open %s",s); + if (! rd_open(s)) { + fprintf(stderr,"%s: can't open %s\n",progname,s); + exit(-1); + } + rd_ohead(&ohead); + if (ohead.oh_flags & HF_LINK) { + fprintf(stderr,"%s: %s contains unresolved references\n",progname,s); + exit(-1); + } + rd_sect(sect, ohead.oh_nsect); ttyfd = 1; - first = 1; osg = 0; - for (;;) { - pc = get2c(stdin); - if (feof(stdin)) - break; - sg = get2c(stdin); - nd = get2c(stdin); - if (first) { - first = 0; + first = 1; + for (i = 0; i < ohead.oh_nsect; i++) { + rd_outsect(i); + pc = sect[i].os_base; + while (sect[i].os_size) { + unsigned int sz = 8096, fl; + extern char *calloc(); + register char *buf; + char *pbuf; + + if (sz > sect[i].os_size) sz = sect[i].os_size; + sect[i].os_size -= sz; + pbuf = buf = calloc(sz, 1); + if (fl = sect[i].os_flen) { + if (fl > sz) fl = sz; + sect[i].os_flen -= fl; + + rd_emit(buf, (long) fl); + } + while (sz >= MAXBYTE) { + data(MAXBYTE, (int) pc, buf); + sz -= MAXBYTE; + buf += MAXBYTE; + pc += MAXBYTE; + first = 0; + } + if (sz > 0) { + data(sz, (int) pc, buf); + first = 0; + } + free(pbuf); } - assert(sg == osg); - while (nd > MAXBYTE) { - data(MAXBYTE,pc); - nd -= MAXBYTE; - pc += MAXBYTE; - } - if (nd > 0) - data(nd,pc); - assert(feof(stdin) == 0); } if (first == 0) eof(); @@ -78,11 +101,13 @@ main(argc,argv) char **argv; { reply(); } -data(nd,pc) { +data(nd,pc, buf) + register char *buf; +{ newline(nd,pc,DATTYPE); do - byte(getc(stdin)); + byte(*buf++); while (--nd); endline(); } @@ -132,14 +157,16 @@ b &= 0377; put(hex[b & 017]); } -put(c) { +put(c) + char c; +{ write(ttyfd,&c,1); } reply() { register i; - int c; + char c; if (echo == 0) return; @@ -148,13 +175,6 @@ reply() { write(1,&c,1); } -get2c(f) FILE *f; { - register c; - - c = getc(f); - return((getc(f) << 8) | c); -} - fatal(s,a) { fprintf(stderr,"%s: ",progname); @@ -162,3 +182,5 @@ fatal(s,a) { fprintf(stderr,"\n"); exit(-1); } + +rd_fatal() { fatal("read error"); } diff --git a/mach/6500/libem/LIST b/mach/6500/libem/LIST index e6a56ca47..1858f4d19 100644 --- a/mach/6500/libem/LIST +++ b/mach/6500/libem/LIST @@ -1,4 +1,4 @@ -tail_em.s.a +libem_s.a adi.s adi4.s and.s diff --git a/mach/m68k2/dl/Makefile b/mach/m68k2/dl/Makefile index ea070d4f7..e52176105 100644 --- a/mach/m68k2/dl/Makefile +++ b/mach/m68k2/dl/Makefile @@ -1,21 +1,22 @@ -CFLAGS=-O +EMHOME=../../.. +OBJLIB=$(EMHOME)/modules/lib/libobject.a -cv: cv.o - $(CC) -o cv -n cv.o +head: dl -install: ins_cv -ins_cv: cv - ../../install cv +dl: dl.c + $(CC) -I$(EMHOME)/h -o dl dl.c $(OBJLIB) -cmp: cmp_cv -cmp_cv: cv - -../../compare cv +install: head + @echo Nothing is installed -opr: - make pr | opr - -pr: - @pr `pwd`/cv.c +cmp: head + @echo Nothing is compared clean: - -rm -f *.o *.old cv + rm -f *.o + +pr: + @pr `pwd`/Makefile `pwd`/dl.c + +opr: + make pr | opr diff --git a/mach/m68k2/dl/dl.c b/mach/m68k2/dl/dl.c index 91b44c64c..fb17ef97d 100644 --- a/mach/m68k2/dl/dl.c +++ b/mach/m68k2/dl/dl.c @@ -1,11 +1,14 @@ static char rcsid[] = "$Header$"; #define MAXBYTE 24 #include +#include char hex[] = "0123456789ABCDEF"; FILE *fp, *fopen(); char **s; int bytes, bytcnt, checksum; long pc; +struct outhead ohead; +struct outsect sect[MAXSECT]; main (argc,argv) @@ -13,62 +16,86 @@ int argc; char *argv[]; { if (argc != 2) fatal ("usage: %s filename\n",argv[0]); - if ((fp = fopen (*++argv,"r")) == NULL) + if (! rd_open (*++argv)) fatal ("can't open %s\n",*argv); else { s = argv; convert (); - fclose (fp); } } convert () { - int c; - do - { - pc = getword (); - pc = (pc << 16) | getword (); - bytes = getword (); - while (bytes != 0) - { - bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE; - bytes -= bytcnt; - checksum = 0; - if (pc > 0xffffL) S2record (); else S1record (); + int i; + + rd_ohead(&ohead); + if (ohead.oh_flags & HF_LINK) { + fatal("%s contains unresolved references\n",s); + } + rd_sect(sect, ohead.oh_nsect); + for (i = 0; i < ohead.oh_nsect; i++) { + rd_outsect(i); + pc = sect[i].os_base; + while (sect[i].os_size) { + unsigned int sz = 8096, fl; + extern char *calloc(); + register char *buf; + char *pbuf; + + if (sz > sect[i].os_size) sz = sect[i].os_size; + sect[i].os_size -= sz; + pbuf = buf = calloc(sz, 1); + if (fl = sect[i].os_flen) { + if (fl > sz) fl = sz; + sect[i].os_flen -= fl; + + rd_emit(buf, (long) fl); } - c = getc (fp); - ungetc (c, fp); + while (sz > 0) { + int p = bytcnt = sz < MAXBYTE ? sz : MAXBYTE; + checksum = 0; + sz -= p; + if (pc > 0xffffL) + S2record (buf); + else S1record (buf); + buf += p; + } + free(pbuf); } - while (c != EOF); + } printf ("S9030000FC\n"); } -S2record () +S2record (buf) + char *buf; { printf ("S2"); bytcnt += 4; outbyte (bytcnt); - outbyte (pc); + outbyte ((int) (pc >> 16)); + outbyte ((int) (pc >> 8)); + outbyte ((int) pc); record (); } -S1record () +S1record (buf) + char *buf; { printf ("S1"); bytcnt += 3; outbyte (bytcnt); - record (); + outbyte ((int) (pc >> 8)); + outbyte((int) pc); + record (buf); } -record () +record (buf) + register char *buf; { - outbyte (pc << 8); - outbyte (pc << 16); while (bytcnt != 0) { - outbyte (getbyte ()); + outbyte (*buf++); pc ++; } outbyte (~checksum); @@ -86,19 +113,8 @@ int b; -- bytcnt; } -getword () - { - int c; - c = getbyte (); - return ((getbyte () << 8) | c ); - } +rd_fatal() { fatal("Read error\n"); } -getbyte () - { - int c; - if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s); - return (c); - } fatal (s,a) { printf (s,a); diff --git a/mach/m68k4/libem/Makefile b/mach/m68k4/libem/Makefile index 72404fbdb..85b6d9e49 100644 --- a/mach/m68k4/libem/Makefile +++ b/mach/m68k4/libem/Makefile @@ -1,23 +1,18 @@ # $Header$ MACH=m68k4 +all: libem_o.a end.o + install: all - ../../install head_em.o head_em - ../../install libem_o.a tail_em.rt + ../../install libem_o.a tail_em ../../install end.o end_em cmp: all - -../../compare head_em.o head_em - -../../compare libem_o.a tail_em.rt + -../../compare libem_o.a tail_em -../../compare end.o end_em -all: head_em.o libem_o.a end.o - end.o: end.s $(MACH) -I../../../h -c end.s -head_em.o: head_em.s - $(MACH) -I../../../h -c head_em.s - libem_o.a: libem_s.a ASAR=aal ; export ASAR ;\ march . libem_o.a @@ -28,6 +23,5 @@ opr : make pr | opr pr: - @pr `pwd`/head_em.s @arch pv libem_s.a | pr -h `pwd`/libem_s.a @pr `pwd`/end.s diff --git a/mach/ns/libcc/Makefile b/mach/ns/libcc/Makefile index 848d185f2..5f2cbc8cb 100644 --- a/mach/ns/libcc/Makefile +++ b/mach/ns/libcc/Makefile @@ -1,5 +1,6 @@ +SUF=o MAKEFILE=../../proto/libg/Makefile -MACHDEF="MACH=ns" "SUF=o" "ASAR=aal" +MACHDEF="MACH=ns" "SUF=$(SUF)" "ASAR=aal" STDIO="PREF=cc" "SUB=.1s" "SRC=lang/cem/libcc/stdio" GEN="PREF=cc" "SUB=.2g" "SRC=lang/cem/libcc/gen" MON="PREF=mon" "SRC=lang/cem/libcc/mon" @@ -19,7 +20,7 @@ cplibm: cplibln: make -f $(MAKEFILE) $(LIBLN) $(MACHDEF) tailcp -cmp: cmpstdio cmpgen cmpmon cmplib cmplibln +cmp: cmpstdio cmpgen cmpstdio: make -f $(MAKEFILE) $(STDIO) $(MACHDEF) tail