static void zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[]) { int i, c; int32 l; Sym *s; Auto *u; a->type = BGETC(f); a->reg = BGETC(f); c = BGETC(f); if(c < 0 || c > NSYM){ print("sym out of range: %d\n", c); BPUTC(f, ALAST+1); return; } a->sym = h[c]; a->name = BGETC(f); adrgotype = zsym(pn, f, h); if((schar)a->reg < 0 || a->reg > NREG) { print("register out of range %d\n", a->reg); BPUTC(f, ALAST+1); return; /* force real diagnostic */ } if(a->type == D_CONST || a->type == D_OCONST) { if(a->name == D_EXTERN || a->name == D_STATIC) { s = a->sym; if(s != S && (s->type == STEXT || s->type == SCONST || s->type == SXREF)) { if(0 && !s->fnptr && s->name[0] != '.') print("%s used as function pointer\n", s->name); s->fnptr = 1; // over the top cos of SXREF } } } switch(a->type) { default: print("unknown type %d\n", a->type); BPUTC(f, ALAST+1); return; /* force real diagnostic */ case D_NONE: case D_REG: case D_FREG: case D_PSR: case D_FPCR: break; case D_REGREG: case D_REGREG2: a->offset = BGETC(f); break; case D_CONST2: a->offset2 = BGETLE4(f); // fall through case D_BRANCH: case D_OREG: case D_CONST: case D_OCONST: case D_SHIFT: a->offset = BGETLE4(f); break; case D_SCONST: a->sval = mal(NSNAME); Bread(f, a->sval, NSNAME); break; case D_FCONST: a->ieee.l = BGETLE4(f); a->ieee.h = BGETLE4(f); break; } s = a->sym; if(s == S) return; i = a->name; if(i != D_AUTO && i != D_PARAM) { if(s && adrgotype) s->gotype = adrgotype; return; } l = a->offset; for(u=curauto; u; u=u->link) if(u->asym == s) if(u->type == i) { if(u->aoffset > l) u->aoffset = l; if(adrgotype) u->gotype = adrgotype; return; } u = mal(sizeof(Auto)); u->link = curauto; curauto = u; u->asym = s; u->aoffset = l; u->type = i; u->gotype = adrgotype; }
static void zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[]) { int t; int32 l; Sym *s; Auto *u; t = Bgetc(f); a->index = D_NONE; a->scale = 0; if(t & T_INDEX) { a->index = Bgetc(f); a->scale = Bgetc(f); } a->type = D_NONE; a->offset = 0; if(t & T_OFFSET) a->offset = Bget4(f); a->offset2 = 0; if(t & T_OFFSET2) { a->offset2 = Bget4(f); a->type = D_CONST2; } a->sym = S; if(t & T_SYM) a->sym = zsym(pn, f, h); if(t & T_FCONST) { a->ieee.l = Bget4(f); a->ieee.h = Bget4(f); a->type = D_FCONST; } else if(t & T_SCONST) { Bread(f, a->scon, NSNAME); a->type = D_SCONST; } if(t & T_TYPE) a->type = Bgetc(f); adrgotype = S; if(t & T_GOTYPE) adrgotype = zsym(pn, f, h); t = a->type; if(t == D_INDIR+D_GS) a->offset += tlsoffset; s = a->sym; if(s == S) return; if(t != D_AUTO && t != D_PARAM) { if(adrgotype) s->gotype = adrgotype; return; } l = a->offset; for(u=curauto; u; u=u->link) { if(u->asym == s) if(u->type == t) { if(u->aoffset > l) u->aoffset = l; if(adrgotype) u->gotype = adrgotype; return; } } u = mal(sizeof(*u)); u->link = curauto; curauto = u; u->asym = s; u->aoffset = l; u->type = t; u->gotype = adrgotype; }
static void zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[]) { int t; int32 l; Sym *s; Auto *u; t = BGETC(f); a->index = D_NONE; a->scale = 0; if(t & T_INDEX) { a->index = BGETC(f); a->scale = BGETC(f); } a->offset = 0; if(t & T_OFFSET) { a->offset = Bget4(f); if(t & T_64) { a->offset &= 0xFFFFFFFFULL; a->offset |= (vlong)Bget4(f) << 32; } } a->sym = S; if(t & T_SYM) a->sym = zsym(pn, f, h); a->type = D_NONE; if(t & T_FCONST) { a->ieee.l = Bget4(f); a->ieee.h = Bget4(f); a->type = D_FCONST; } else if(t & T_SCONST) { Bread(f, a->scon, NSNAME); a->type = D_SCONST; } if(t & T_TYPE) a->type = BGETC(f); if(a->type < 0 || a->type >= D_SIZE) mangle(pn); adrgotype = S; if(t & T_GOTYPE) adrgotype = zsym(pn, f, h); s = a->sym; t = a->type; if(t == D_INDIR+D_GS) a->offset += tlsoffset; if(t != D_AUTO && t != D_PARAM) { if(s && adrgotype) s->gotype = adrgotype; return; } l = a->offset; for(u=curauto; u; u=u->link) { if(u->asym == s) if(u->type == t) { if(u->aoffset > l) u->aoffset = l; if(adrgotype) u->gotype = adrgotype; return; } } switch(t) { case D_FILE: case D_FILE1: case D_AUTO: case D_PARAM: if(s == S) mangle(pn); } u = mal(sizeof(*u)); u->link = curauto; curauto = u; u->asym = s; u->aoffset = l; u->type = t; u->gotype = adrgotype; }