]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: mark auxiliary symbols as containing no pointers
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 23 Jul 2014 13:36:10 +0000 (17:36 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 23 Jul 2014 13:36:10 +0000 (17:36 +0400)
They do not, but pretend that they do.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, dave, josharian, khr, rsc
CC=golang-codereviews, iant, khr, rlh
https://golang.org/cl/116060043

src/cmd/5g/gsubr.c
src/cmd/6g/gsubr.c
src/cmd/8g/gsubr.c
src/cmd/gc/go.h
src/cmd/gc/obj.c
src/cmd/gc/plive.c
src/cmd/gc/reflect.c
src/cmd/gc/walk.c

index b94da96c12069dd052552670d3a039b9cdb8ed4a..1241a23ea653fe892de41c3a96dcf00cab252aed 100644 (file)
@@ -216,7 +216,7 @@ gargsize(int32 size)
 }
 
 void
-ggloblsym(Sym *s, int32 width, int dupok, int rodata)
+ggloblsym(Sym *s, int32 width, int8 flags)
 {
        Prog *p;
 
@@ -227,10 +227,7 @@ ggloblsym(Sym *s, int32 width, int dupok, int rodata)
        p->to.type = D_CONST;
        p->to.name = D_NONE;
        p->to.offset = width;
-       if(dupok)
-               p->reg |= DUPOK;
-       if(rodata)
-               p->reg |= RODATA;
+       p->reg = flags;
 }
 
 void
index d1b1d9beef0bd0a4b5a346754482f103662744fc..f3464b7e1cf4be1e968618d9386a7c860bc55247 100644 (file)
@@ -225,7 +225,7 @@ gargsize(vlong size)
 }
 
 void
-ggloblsym(Sym *s, int32 width, int dupok, int rodata)
+ggloblsym(Sym *s, int32 width, int8 flags)
 {
        Prog *p;
 
@@ -236,10 +236,7 @@ ggloblsym(Sym *s, int32 width, int dupok, int rodata)
        p->to.type = D_CONST;
        p->to.index = D_NONE;
        p->to.offset = width;
-       if(dupok)
-               p->from.scale |= DUPOK;
-       if(rodata)
-               p->from.scale |= RODATA;
+       p->from.scale = flags;
 }
 
 int
index a131874c61d1e0634b2fecb433b426e28fc02529..66d5b8d6963cfc2431ad524e68e0e674f89655d5 100644 (file)
@@ -216,7 +216,7 @@ gargsize(int32 size)
 }
 
 void
-ggloblsym(Sym *s, int32 width, int dupok, int rodata)
+ggloblsym(Sym *s, int32 width, int8 flags)
 {
        Prog *p;
 
@@ -227,10 +227,7 @@ ggloblsym(Sym *s, int32 width, int dupok, int rodata)
        p->to.type = D_CONST;
        p->to.index = D_NONE;
        p->to.offset = width;
-       if(dupok)
-               p->from.scale |= DUPOK;
-       if(rodata)
-               p->from.scale |= RODATA;
+       p->from.scale = flags;
 }
 
 void
index 265037ac5163f6e5714aafdd133e0c70fe722372..aaa22d1b1342f71bbdf265c9ec89bf48a4e646fa 100644 (file)
@@ -1506,7 +1506,7 @@ void      gdata(Node*, Node*, int);
 void   gdatacomplex(Node*, Mpcplx*);
 void   gdatastring(Node*, Strlit*);
 void   ggloblnod(Node *nam);
-void   ggloblsym(Sym *s, int32 width, int dupok, int rodata);
+void   ggloblsym(Sym *s, int32 width, int8 flags);
 void   gvardef(Node*);
 void   gvarkill(Node*);
 Prog*  gjmp(Prog*);
index 4eeb03aa8e4de4072fbd1d8fbd3deab84087ed9a..b752a13ced5cdc8f8b37dd35027fa96e48cb26ea 100644 (file)
@@ -5,6 +5,7 @@
 #include <u.h>
 #include <libc.h>
 #include "go.h"
+#include "../ld/textflag.h"
 
 /*
  * architecture-independent object file output
@@ -84,7 +85,7 @@ dumpobj(void)
        externdcl = tmp;
 
        zero = pkglookup("zerovalue", runtimepkg);
-       ggloblsym(zero, zerosize, 1, 1);
+       ggloblsym(zero, zerosize, DUPOK|RODATA);
 
        dumpdata();
        writeobj(ctxt, bout);
@@ -128,7 +129,7 @@ dumpglobls(void)
        for(l=funcsyms; l; l=l->next) {
                n = l->n;
                dsymptr(n->sym, 0, n->sym->def->shortname->sym, 0);
-               ggloblsym(n->sym, widthptr, 1, 1);
+               ggloblsym(n->sym, widthptr, DUPOK|RODATA);
        }
        
        // Do not reprocess funcsyms on next dumpglobls call.
@@ -249,7 +250,7 @@ stringsym(char *s, int len)
        }
        off = duint8(sym, off, 0);  // terminating NUL for runtime
        off = (off+widthptr-1)&~(widthptr-1);  // round to pointer alignment
-       ggloblsym(sym, off, 1, 1);
+       ggloblsym(sym, off, DUPOK|RODATA);
 
        return sym;     
 }
@@ -272,7 +273,7 @@ slicebytes(Node *nam, char *s, int len)
                        m = len-n;
                off = dsname(sym, off, s+n, m);
        }
-       ggloblsym(sym, off, 0, 0);
+       ggloblsym(sym, off, NOPTR);
        
        if(nam->op != ONAME)
                fatal("slicebytes %N", nam);
index 4c07d6bc511f7aba2110c98db99db4e3617fd7d3..d3f1cfbc6e81e6cc16fcefa9fb5cdb3c7fdcb110 100644 (file)
@@ -17,6 +17,7 @@
 #include <libc.h>
 #include "gg.h"
 #include "opt.h"
+#include "../ld/textflag.h"
 #include "../../pkg/runtime/funcdata.h"
 
 enum { BitsPerPointer = 2 };
@@ -1923,7 +1924,7 @@ twobitwritesymbol(Array *arr, Sym *sym)
                }
        }
        duint32(sym, 0, i); // number of bitmaps
-       ggloblsym(sym, off, 0, 1);
+       ggloblsym(sym, off, RODATA);
 }
 
 static void
index dbb447e4e20e82ffdc986cc2412009258cd8a4cc..fdcd76be06f005f5bdb2791a31ac624b90f1bfae 100644 (file)
@@ -5,6 +5,7 @@
 #include <u.h>
 #include <libc.h>
 #include "go.h"
+#include "../ld/textflag.h"
 #include "../../pkg/runtime/mgc0.h"
 
 /*
@@ -524,7 +525,7 @@ dimportpath(Pkg *p)
        p->pathsym = n->sym;
 
        gdatastring(n, p->path);
-       ggloblsym(n->sym, types[TSTRING]->width, 1, 1);
+       ggloblsym(n->sym, types[TSTRING]->width, DUPOK|RODATA);
 }
 
 static int
@@ -975,7 +976,9 @@ dtypesym(Type *t)
        tbase = t;
        if(isptr[t->etype] && t->sym == S && t->type->sym != S)
                tbase = t->type;
-       dupok = tbase->sym == S;
+       dupok = 0;
+       if(tbase->sym == S)
+               dupok = DUPOK;
 
        if(compiling_runtime &&
                        (tbase == types[tbase->etype] ||
@@ -1150,7 +1153,7 @@ ok:
                break;
        }
        ot = dextratype(s, ot, t, xt);
-       ggloblsym(s, ot, dupok, 1);
+       ggloblsym(s, ot, dupok|RODATA);
 
        // generate typelink.foo pointing at s = type.foo.
        // The linker will leave a table of all the typelinks for
@@ -1164,7 +1167,7 @@ ok:
                case TMAP:
                        slink = typelinksym(t);
                        dsymptr(slink, 0, s, 0);
-                       ggloblsym(slink, widthptr, dupok, 1);
+                       ggloblsym(slink, widthptr, dupok|RODATA);
                }
        }
 
@@ -1267,7 +1270,7 @@ dalgsym(Type *t)
                break;
        }
 
-       ggloblsym(s, ot, 1, 1);
+       ggloblsym(s, ot, DUPOK|RODATA);
        return s;
 }
 
@@ -1489,7 +1492,7 @@ dgcsym(Type *t)
        ot = duintptr(s, ot, t->width);
        ot = dgcsym1(s, ot, t, &off, 0);
        ot = duintptr(s, ot, GC_END);
-       ggloblsym(s, ot, 1, 1);
+       ggloblsym(s, ot, DUPOK|RODATA);
 
        if(t->align > 0)
                off = rnd(off, t->align);
index 1cb25512e5e2868d34711d9e5026aae5806a5b6b..41d49f57b3dab4f09699dc9a901e64a479026f9b 100644 (file)
@@ -5,6 +5,7 @@
 #include       <u.h>
 #include       <libc.h>
 #include       "go.h"
+#include       "../ld/textflag.h"
 
 static Node*   walkprint(Node*, NodeList**, int);
 static Node*   mapfn(char*, Type*);
@@ -865,7 +866,7 @@ walkexpr(Node **np, NodeList **init)
                                l->class = PEXTERN;
                                l->xoffset = 0;
                                sym->def = l;
-                               ggloblsym(sym, widthptr, 1, 0);
+                               ggloblsym(sym, widthptr, DUPOK|NOPTR);
                        }
                        l = nod(OADDR, sym->def, N);
                        l->addable = 1;