Commit 8b20e7bb authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

cmd/gc: mark auxiliary symbols as containing no pointers

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
parent b1a3b61f
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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*);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment