do not emit unreachable data symbols.
R=austin
DELTA=103 (71 added, 4 deleted, 28 changed)
OCL=33325
CL=33622
if(n->type != T) {
a->etype = simtype[n->type->etype];
a->width = n->type->width;
- if(n->sym != S && strncmp(n->sym->name, "autotmp_", 8) != 0)
- if(n->type->etype != TFUNC || n->type->thistuple == 0)
- a->gotype = typename(n->type)->left->sym;
+ a->gotype = ngotype(n);
}
a->offset = n->xoffset;
a->sym = n->sym;
a->offset = v->offset;
a->etype = v->etype;
a->type = v->name;
+ a->gotype = v->gotype;
// need to clean this up with wptr and
// some of the defaults
v->sym = s;
v->offset = o;
v->name = n;
+ v->gotype = a->gotype;
v->etype = et;
v->width = w;
if(debug['R'])
memset(buf.dbuf, 0, n+Dbufslop);
for(p = datap; p != P; p = p->link) {
curp = p;
+ if(!p->from.sym->reachable)
+ sysfatal("unreachable symbol in datblk - %s", p->from.sym->name);
l = p->from.sym->value + p->from.offset - s;
c = p->from.scale;
i = 0;
strcat(str, s);
}
conv:
- return fmtstrcpy(fp, str);
+ fmtstrcpy(fp, str);
+ if(a->gotype)
+ fmtprint(fp, "«%s»", a->gotype->name);
+ return 0;
+
}
char* regstr[] =
*/
Bseek(f, off, 0);
cnt = esym - off;
- start = malloc(cnt + 10);
+ start = mal(cnt + 10);
cnt = Bread(f, start, cnt);
if(cnt <= 0){
Bterm(f);
return;
}
- p = malloc(strlen(name) + 1);
+ p = mal(strlen(name) + 1);
strcpy(p, name);
library[libraryp] = p;
- p = malloc(strlen(obj) + 1);
+ p = mal(strlen(obj) + 1);
strcpy(p, obj);
libraryobj[libraryp] = p;
libraryp++;
Sym *s;
int i, j, k;
- u = malloc(sizeof(Auto));
- s = malloc(sizeof(Sym));
- s->name = malloc(2*(histfrogp+1) + 1);
+ u = mal(sizeof(Auto));
+ s = mal(sizeof(Sym));
+ s->name = mal(2*(histfrogp+1) + 1);
u->asym = s;
u->type = type;
if(debug['v'] > 1)
Bprint(&bso, "lookup %s\n", symb);
- s->name = malloc(l + 1);
+ s->name = mal(l + 1);
memmove(s->name, symb, l);
s->link = hash[h];
datsize = 0;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SDATA)
if(s->type != SBSS)
continue;
/* allocate the rest of the data */
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SDATA) {
if(s->type == SDATA1)
s->type = SDATA;
u -= datsize;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SBSS)
continue;
t = s->value;
bsssize = 0;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SBSS)
continue;
t = s->value;
s->type != SUNDEF &&
(nexports == 0 || s->subtype == SEXPORT))
n++;
- esyms = malloc(n*sizeof(Sym*));
+ esyms = mal(n*sizeof(Sym*));
ne = n;
n = 0;
for(i = 0; i < NHASH; i++)
cput(0);
}
gv = 0;
- if(go)
+ if(go) {
+ if(!go->reachable)
+ sysfatal("unreachable type %s", go->name);
gv = go->value+INITDAT;
+ }
if(l == 8)
lputb(gv>>32);
lputb(gv);
if(s->type == STEXT)
putsymb(s->name, 'T', s->value, s->version, 0);
- for(h=0; h<NHASH; h++)
- for(s=hash[h]; s!=S; s=s->link)
+ for(h=0; h<NHASH; h++) {
+ for(s=hash[h]; s!=S; s=s->link) {
switch(s->type) {
case SCONST:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'D', s->value, s->version, s->gotype);
continue;
case SDATA:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'D', s->value+INITDAT, s->version, s->gotype);
continue;
case SBSS:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'B', s->value+INITDAT, s->version, s->gotype);
continue;
putsymb(s->name, 'f', s->value, s->version, 0);
continue;
}
+ }
+ }
for(p = textp; p != P; p = p->pcond) {
s = p->from.sym;
ckoff(s, v);
case STEXT:
case SCONST:
+ if(!s->reachable)
+ sysfatal("unreachable symbol in vaddr - %s", s->name);
if((uvlong)s->value < (uvlong)INITTEXT)
v += INITTEXT; /* TO DO */
v += s->value;
break;
default:
+ if(!s->reachable)
+ sysfatal("unreachable symbol in vaddr - %s", s->name);
v += INITDAT + s->value;
}
}
r->t += 64;
m = r->m;
a = r->a;
- r->m = nm = malloc(r->t*sizeof(uchar));
- r->a = na = malloc(r->t*sizeof(uint32));
+ r->m = nm = mal(r->t*sizeof(uchar));
+ r->a = na = mal(r->t*sizeof(uint32));
memmove(nm, m, t*sizeof(uchar));
memmove(na, a, t*sizeof(uint32));
free(m);
a->etype = 0;
if(n->type != T) {
a->etype = simtype[n->type->etype];
- if(n->sym != S && strncmp(n->sym->name, "autotmp_", 8) != 0)
- if(n->type->etype != TFUNC || n->type->thistuple == 0)
- a->gotype = typename(n->type)->left->sym;
+ a->gotype = ngotype(n);
}
a->offset = n->xoffset;
a->sym = n->sym;
memset(buf.dbuf, 0, n+Dbufslop);
for(p = datap; p != P; p = p->link) {
curp = p;
+ if(!p->from.sym->reachable)
+ sysfatal("unreachable symbol in datblk - %s", p->from.sym->name);
l = p->from.sym->value + p->from.offset - s;
c = p->from.scale;
i = 0;
strcat(str, s);
}
conv:
- return fmtstrcpy(fp, str);
+ fmtstrcpy(fp, str);
+ if(a->gotype)
+ fmtprint(fp, "«%s»", a->gotype->name);
+ return 0;
}
char* regstr[] =
*/
Bseek(f, off, 0);
cnt = esym - off;
- start = malloc(cnt + 10);
+ start = mal(cnt + 10);
cnt = Bread(f, start, cnt);
if(cnt <= 0){
Bterm(f);
return;
}
- p = malloc(strlen(name) + 1);
+ p = mal(strlen(name) + 1);
strcpy(p, name);
library[libraryp] = p;
- p = malloc(strlen(obj) + 1);
+ p = mal(strlen(obj) + 1);
strcpy(p, obj);
libraryobj[libraryp] = p;
libraryp++;
Sym *s;
int i, j, k;
- u = malloc(sizeof(Auto));
- s = malloc(sizeof(Sym));
- s->name = malloc(2*(histfrogp+1) + 1);
+ u = mal(sizeof(Auto));
+ s = mal(sizeof(Sym));
+ s->name = mal(2*(histfrogp+1) + 1);
u->asym = s;
u->type = type;
return s;
s = mal(sizeof(Sym));
- s->name = malloc(l + 1);
+ s->name = mal(l + 1);
memmove(s->name, symb, l);
s->link = hash[h];
datsize = 0;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SDATA)
if(s->type != SBSS)
continue;
u -= datsize;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SBSS)
continue;
t = s->value;
bsssize = 0;
for(i=0; i<NHASH; i++)
for(s = hash[i]; s != S; s = s->link) {
+ if(!s->reachable)
+ continue;
if(s->type != SBSS)
continue;
t = s->value;
for(s = hash[i]; s != S; s = s->link)
if(s->sig != 0 && s->type != SXREF && s->type != SUNDEF && (nexports == 0 || s->subtype == SEXPORT))
n++;
- esyms = malloc(n*sizeof(Sym*));
+ esyms = mal(n*sizeof(Sym*));
ne = n;
n = 0;
for(i = 0; i < NHASH; i++)
cput(0);
}
gv = 0;
- if(go)
+ if(go) {
+ if(!go->reachable)
+ sysfatal("unreachable type %s", go->name);
gv = go->value+INITDAT;
+ }
lput(gv);
symsize += 4 + 1 + i+1 + 4;
for(s=hash[h]; s!=S; s=s->link)
switch(s->type) {
case SCONST:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'D', s->value, s->version, s->gotype);
continue;
case SDATA:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'D', s->value+INITDAT, s->version, s->gotype);
continue;
case SBSS:
+ if(!s->reachable)
+ continue;
putsymb(s->name, 'B', s->value+INITDAT, s->version, s->gotype);
continue;
ckoff(s, v);
case STEXT:
case SCONST:
+ if(!s->reachable)
+ sysfatal("unreachable symbol in vaddr - %s", s->name);
v += s->value;
break;
default:
+ if(!s->reachable)
+ sysfatal("unreachable symbol in vaddr - %s", s->name);
v += INITDAT + s->value;
}
}
r->t += 64;
m = r->m;
a = r->a;
- r->m = nm = malloc(r->t*sizeof(uchar));
- r->a = na = malloc(r->t*sizeof(uint32));
+ r->m = nm = mal(r->t*sizeof(uchar));
+ r->a = na = mal(r->t*sizeof(uint32));
memmove(nm, m, t*sizeof(uchar));
memmove(na, a, t*sizeof(uint32));
free(m);
{
vlong offset;
Sym* sym;
+ Sym* gotype;
int width;
char name;
char etype;
void umagic(Magic*);
void redeclare(Sym*, char*);
+Sym* ngotype(Node*);
/*
* dcl.c
m->um = q2+1;
m->s = p-m->w;
}
+
+Sym*
+ngotype(Node *n)
+{
+ if(n->sym != S && strncmp(n->sym->name, "autotmp_", 8) != 0)
+ if(n->type->etype != TFUNC || n->type->thistuple == 0)
+ if(n->type->etype != TSTRUCT || n->type->funarg == 0)
+ return typename(n->type)->left->sym;
+ return S;
+}
static void
marktext(Prog *p)
{
+ Auto *a;
+
if(p == P)
return;
if(p->as != ATEXT) {
diag("marktext: %P", p);
return;
}
+ for(a=p->to.autom; a; a=a->link)
+ mark(a->gotype);
markdepth++;
if(debug['v'] > 1)
Bprint(&bso, "%d marktext %s\n", markdepth, p->from.sym->name);