*** empty log message ***
authorceriel <none@none>
Thu, 26 Feb 1987 19:54:57 +0000 (19:54 +0000)
committerceriel <none@none>
Thu, 26 Feb 1987 19:54:57 +0000 (19:54 +0000)
mach/6500/dl/dl.c
mach/6500/libem/LIST
mach/m68k2/dl/Makefile
mach/m68k2/dl/dl.c
mach/m68k4/libem/Makefile
mach/ns/libcc/Makefile

index 0ee9eb2..470206f 100644 (file)
  *
  */
 
-#include       <sgtty.h>
 #include       <stdio.h>
 #include       <assert.h>
-
-struct sgttyb  tty;
+#include       <out.h>
 
 #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"); }
index e6a56ca..1858f4d 100644 (file)
@@ -1,4 +1,4 @@
-tail_em.s.a
+libem_s.a
 adi.s
 adi4.s
 and.s
index ea070d4..e521761 100644 (file)
@@ -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
+cmp:   head
+       @echo Nothing is compared
+
+clean:
+       rm -f *.o
 
 pr:
-               @pr `pwd`/cv.c
+       @pr `pwd`/Makefile `pwd`/dl.c
 
-clean:
-               -rm -f *.o *.old cv
+opr:
+       make pr | opr
index 91b44c6..fb17ef9 100644 (file)
@@ -1,11 +1,14 @@
 static char rcsid[] = "$Header$";
 #define MAXBYTE        24
 #include <stdio.h>
+#include <out.h>
 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);
+                       }
+                       while (sz > 0) {
+                               int p = bytcnt = sz < MAXBYTE ? sz : MAXBYTE;
+                               checksum = 0;
+                               sz -= p;
+                               if (pc > 0xffffL) 
+                                       S2record (buf);
+                               else S1record (buf);
+                               buf += p;
                        }
-               c = getc (fp);
-               ungetc (c, fp);
+                       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);
index 72404fb..85b6d9e 100644 (file)
@@ -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
index 848d185..5f2cbc8 100644 (file)
@@ -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