]> Cypherpunks repositories - gostls13.git/commitdiff
8l fixes, cut and paste from 6l.
authorRuss Cox <rsc@golang.org>
Wed, 3 Jun 2009 05:33:21 +0000 (22:33 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 3 Jun 2009 05:33:21 +0000 (22:33 -0700)
move PtrSize value into 6l/8l files.

R=r
DELTA=78  (47 added, 15 deleted, 16 changed)
OCL=29729
CL=29798

src/cmd/6l/go.c
src/cmd/6l/obj.c
src/cmd/8l/asm.c
src/cmd/8l/go.c [new file with mode: 0644]
src/cmd/8l/l.h
src/cmd/8l/obj.c
src/cmd/ld/go.c

index 82a216520fcc96eee989fff096cf7659ab32dd49..08c3c8c36e7298c5c12fd7ba5e7a6a0e7b53db9c 100644 (file)
@@ -3,4 +3,8 @@
 // license that can be found in the LICENSE file.
 
 #include "l.h"
+enum
+{
+       PtrSize = 8
+};
 #include "../ld/go.c"
index 31fb978e165eab6409bc39533b355ece850d7fbd..5ab1c561c97295b00909504833e2dd8f75c704f6 100644 (file)
@@ -137,10 +137,8 @@ main(int argc, char *argv[])
                break;
        } ARGEND
        USED(argc);
-       if(*argv == 0) {
-               diag("usage: 6l [-options] objects");
-               errorexit();
-       }
+       if(*argv == 0)
+               usage();
 
        mywhatsys();    // get goroot, goarch, goos
        if(strcmp(goarch, thestring) != 0)
index 8dd444afa5cfa70605adf9ba5edb81d02676d1de..e65d48def6d599db4b03f9c86eb54aca70a4681b 100644 (file)
@@ -416,7 +416,7 @@ asmb(void)
                wputl(0x003E);                  /* reloc table offset */
                wputl(0x0000);                  /* overlay number */
                break;
-       
+
        case 6:
                /* apple MACH */
                va = 4096;
@@ -766,6 +766,20 @@ datblk(int32 s, int32 n)
                                l++;
                        }
                        break;
+
+               case D_SBIG:
+                       if(debug['a'] && i == 0) {
+                               Bprint(&bso, pcstr, l+s+INITDAT);
+                               for(j=0; j<c; j++)
+                                       Bprint(&bso, "%.2ux", p->to.scon[j] & 0xff);
+                               Bprint(&bso, "\t%P\n", curp);
+                       }
+                       for(; i<c; i++) {
+                               buf.dbuf[l] = p->to.sbig[i];
+                               l++;
+                       }
+                       break;
+
                default:
                        fl = p->to.offset;
                        if(p->to.type == D_ADDR) {
diff --git a/src/cmd/8l/go.c b/src/cmd/8l/go.c
new file mode 100644 (file)
index 0000000..a295fa5
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "l.h"
+enum
+{
+       PtrSize = 4
+};
+#include "../ld/go.c"
index 9afd78faa2a19e8bf981e8b24b915e7ede6826c8..d06d050de3b30dacf914dfdf1aa05309c778e192 100644 (file)
@@ -248,6 +248,7 @@ EXTERN      int32   INITDAT;
 EXTERN int32   INITRND;
 EXTERN int32   INITTEXT;
 EXTERN char*   INITENTRY;              /* entry point */
+EXTERN char*   LIBDIR;
 EXTERN Biobuf  bso;
 EXTERN int32   bsssize;
 EXTERN int32   casepc;
index a14f52d6f7256f72b620811d7d77f04f121f2319..14dba3e159ee6b131341a6b04d54db7ba3c961c1 100644 (file)
@@ -71,6 +71,13 @@ isobjfile(char *f)
        return v;
 }
 
+void
+usage(void)
+{
+       fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] files...\n");
+       exits("usage");
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -95,32 +102,26 @@ main(int argc, char *argv[])
                        debug[c]++;
                break;
        case 'o': /* output to (next arg) */
-               outfile = ARGF();
+               outfile = EARGF(usage());
                break;
        case 'E':
-               a = ARGF();
-               if(a)
-                       INITENTRY = a;
+               INITENTRY = EARGF(usage());
                break;
        case 'H':
-               a = ARGF();
-               if(a)
-                       HEADTYPE = atolwhex(a);
+               HEADTYPE = atolwhex(EARGF(usage()));
+               break;
+       case 'L':
+               LIBDIR = EARGF(usage());
                break;
        case 'T':
-               a = ARGF();
-               if(a)
-                       INITTEXT = atolwhex(a);
+               INITTEXT = atolwhex(EARGF(usage()));
                break;
        case 'D':
-               a = ARGF();
-               if(a)
-                       INITDAT = atolwhex(a);
+               INITDAT = atolwhex(EARGF(usage()));
                break;
        case 'R':
-               a = ARGF();
-               if(a)
-                       INITRND = atolwhex(a);
+               INITRND = atolwhex(EARGF(usage()));
+               break;
                break;
        case 'x':       /* produce export table */
                doexp = 1;
@@ -135,10 +136,8 @@ main(int argc, char *argv[])
                break;
        } ARGEND
        USED(argc);
-       if(*argv == 0) {
-               diag("usage: 8l [-options] objects");
-               errorexit();
-       }
+       if(*argv == 0)
+               usage();
 
        whatsys();      // get goroot, goarch, goos
        if(strcmp(goarch, thestring) != 0)
@@ -602,12 +601,13 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
 void
 addlib(char *src, char *obj)
 {
-       char name[1024], comp[256], *p, *q;
-       int i;
+       char name[1024], pname[1024], comp[256], *p, *q;
+       int i, search;
 
        if(histfrogp <= 0)
                return;
 
+       search = 0;
        if(histfrog[0]->name[1] == '/') {
                sprint(name, "");
                i = 1;
@@ -616,11 +616,9 @@ addlib(char *src, char *obj)
                sprint(name, ".");
                i = 0;
        } else {
-               if(debug['9'])
-                       sprint(name, "/%s/lib", thestring);
-               else
-                       sprint(name, "/usr/%clib", thechar);
+               sprint(name, "");
                i = 0;
+               search = 1;
        }
 
        for(; i<histfrogp; i++) {
@@ -650,6 +648,16 @@ addlib(char *src, char *obj)
                strcat(name, "/");
                strcat(name, comp);
        }
+
+       if(search) {
+               // try dot, -L "libdir", and then goroot.
+               snprint(pname, sizeof pname, "./%s", name);
+               if(access(pname, AEXIST) < 0 && LIBDIR != nil)
+                       snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
+               if(access(pname, AEXIST) < 0)
+                       snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name);
+               strcpy(name, pname);
+       }
        if(debug['v'])
                Bprint(&bso, "%5.2f addlib: %s %s pulls in %s\n", cputime(), obj, src, name);
 
@@ -976,6 +984,8 @@ loop:
                }
                if(p->to.offset > s->value)
                        s->value = p->to.offset;
+               if(p->from.scale & DUPOK)
+                       s->dupok = 1;
                goto loop;
 
        case ADYNT:
index d10d89b1228a1f24f2bc123c3cb0de839043fc5a..8ba7d12ce34f9578d1aba4d12f4c66d7f4d7c32f 100644 (file)
@@ -465,7 +465,6 @@ definetypesigs(void)
        qsort(all, n, sizeof all[0], symcmp);
 
        // emit array as sequence of references.
-       enum { PtrSize = 8 };
        for(i=0; i<n; i++) {
                prog = newdata(s, PtrSize*i, PtrSize, D_EXTERN);
                prog->to.type = D_ADDR;