1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:34:41 -07:00

change gotype in symbol table from

character string to machine address.
not filled in, just carved out.

R=austin
DELTA=77  (11 added, 34 deleted, 32 changed)
OCL=33122
CL=33124
This commit is contained in:
Russ Cox 2009-08-12 16:14:53 -07:00
parent 3e98a40793
commit 57a9bd0ee3
9 changed files with 40 additions and 63 deletions

View File

@ -84,7 +84,7 @@ struct Sym
uint sig; uint sig;
char type; char type;
char *name; char *name;
char *gotype; vlong gotype;
int sequence; // order in file int sequence; // order in file
}; };
/* /*

View File

@ -402,7 +402,7 @@ void follow(void);
void addstachmark(void); void addstachmark(void);
void gethunk(void); void gethunk(void);
void gotypestrings(void); void gotypestrings(void);
char* gotypefor(char*); vlong gotypefor(char*);
void histtoauto(void); void histtoauto(void);
double ieeedtod(Ieee*); double ieeedtod(Ieee*);
int32 ieeedtof(Ieee*); int32 ieeedtof(Ieee*);

View File

@ -150,9 +150,9 @@ xdefine(char *p, int t, vlong v)
} }
void void
putsymb(char *s, int t, vlong v, int ver, char *go) putsymb(char *s, int t, vlong v, int ver, vlong go)
{ {
int i, j, f, l; int i, f, l;
if(t == 'f') if(t == 'f')
s++; s++;
@ -181,13 +181,10 @@ putsymb(char *s, int t, vlong v, int ver, char *go)
cput(s[i]); cput(s[i]);
cput(0); cput(0);
} }
j = 0; if(l == 8)
if(go) { lputb(go>>32);
for(j=0; go[j]; j++) lputb(go);
cput(go[j]); symsize += l + 1 + i + 1 + l;
}
cput(0);
symsize += l + 1 + i + 1 + j + 1;
if(debug['n']) { if(debug['n']) {
if(t == 'z' || t == 'Z') { if(t == 'z' || t == 'Z') {

View File

@ -391,7 +391,7 @@ void whatsys(void);
* go.c * go.c
*/ */
void deadcode(void); void deadcode(void);
char* gotypefor(char *name); vlong gotypefor(char *name);
void ldpkg(Biobuf *f, int64 len, char *filename); void ldpkg(Biobuf *f, int64 len, char *filename);

View File

@ -146,9 +146,9 @@ xdefine(char *p, int t, int32 v)
} }
void void
putsymb(char *s, int t, int32 v, int ver, char *go) putsymb(char *s, int t, int32 v, int ver, vlong go)
{ {
int i, j, f; int i, f;
if(t == 'f') if(t == 'f')
s++; s++;
@ -172,14 +172,9 @@ putsymb(char *s, int t, int32 v, int ver, char *go)
cput(s[i]); cput(s[i]);
cput(0); cput(0);
} }
j = 0; lput(go);
if(go) {
for(j=0; go[j]; j++)
cput(go[j]);
}
cput(0);
symsize += 4 + 1 + i + 1 + j + 1; symsize += 4 + 1 + i + 1 + 4;
if(debug['n']) { if(debug['n']) {
if(t == 'z' || t == 'Z') { if(t == 'z' || t == 'Z') {
@ -208,7 +203,7 @@ asmsym(void)
s = lookup("etext", 0); s = lookup("etext", 0);
if(s->type == STEXT) if(s->type == STEXT)
putsymb(s->name, 'T', s->value, s->version, nil); putsymb(s->name, 'T', s->value, s->version, 0);
for(h=0; h<NHASH; h++) for(h=0; h<NHASH; h++)
for(s=hash[h]; s!=S; s=s->link) for(s=hash[h]; s!=S; s=s->link)
@ -226,7 +221,7 @@ asmsym(void)
continue; continue;
case SFILE: case SFILE:
putsymb(s->name, 'f', s->value, s->version, nil); putsymb(s->name, 'f', s->value, s->version, 0);
continue; continue;
} }
@ -238,22 +233,22 @@ asmsym(void)
/* filenames first */ /* filenames first */
for(a=p->to.autom; a; a=a->link) for(a=p->to.autom; a; a=a->link)
if(a->type == D_FILE) if(a->type == D_FILE)
putsymb(a->asym->name, 'z', a->aoffset, 0, nil); putsymb(a->asym->name, 'z', a->aoffset, 0, 0);
else else
if(a->type == D_FILE1) if(a->type == D_FILE1)
putsymb(a->asym->name, 'Z', a->aoffset, 0, nil); putsymb(a->asym->name, 'Z', a->aoffset, 0, 0);
putsymb(s->name, 'T', s->value, s->version, gotypefor(s->name)); putsymb(s->name, 'T', s->value, s->version, gotypefor(s->name));
/* frame, auto and param after */ /* frame, auto and param after */
putsymb(".frame", 'm', p->to.offset+4, 0, nil); putsymb(".frame", 'm', p->to.offset+4, 0, 0);
for(a=p->to.autom; a; a=a->link) for(a=p->to.autom; a; a=a->link)
if(a->type == D_AUTO) if(a->type == D_AUTO)
putsymb(a->asym->name, 'a', -a->aoffset, 0, nil); putsymb(a->asym->name, 'a', -a->aoffset, 0, 0);
else else
if(a->type == D_PARAM) if(a->type == D_PARAM)
putsymb(a->asym->name, 'p', a->aoffset, 0, nil); putsymb(a->asym->name, 'p', a->aoffset, 0, 0);
} }
if(debug['v'] || debug['n']) if(debug['v'] || debug['n'])
Bprint(&bso, "symsize = %lud\n", symsize); Bprint(&bso, "symsize = %lud\n", symsize);

View File

@ -62,9 +62,10 @@ ilookup(char *name)
return x; return x;
} }
char* vlong
gotypefor(char *name) gotypefor(char *name)
{ {
/*
Import *x; Import *x;
char *s, *p; char *s, *p;
@ -81,6 +82,8 @@ gotypefor(char *name)
if(strcmp(x->prefix, "var") != 0 && strcmp(x->prefix, "func") != 0) if(strcmp(x->prefix, "var") != 0 && strcmp(x->prefix, "func") != 0)
return nil; return nil;
return x->def; return x->def;
*/
return 0;
} }
static void loadpkgdata(char*, char*, int); static void loadpkgdata(char*, char*, int);

View File

@ -326,8 +326,8 @@ printsyms(Sym **symptr, long nsym)
else else
Bprint(&bout, "%*s ", wid, ""); Bprint(&bout, "%*s ", wid, "");
Bprint(&bout, "%c %s", s->type, cp); Bprint(&bout, "%c %s", s->type, cp);
if(tflag && s->gotype && s->gotype[0]) if(tflag && s->gotype)
Bprint(&bout, " %s", s->gotype); Bprint(&bout, " %*llux", wid, s->gotype);
Bprint(&bout, "\n"); Bprint(&bout, "\n");
} }
} }

View File

@ -87,7 +87,6 @@ static uvlong firstinstr; /* as found from symtab; needed for amd64 */
static void cleansyms(void); static void cleansyms(void);
static int32 decodename(Biobuf*, Sym*); static int32 decodename(Biobuf*, Sym*);
static int32 decodegotype(Biobuf*, Sym*);
static short *encfname(char*); static short *encfname(char*);
static int fline(char*, int, int32, Hist*, Hist**); static int fline(char*, int, int32, Hist*, Hist**);
static void fillsym(Sym*, Symbol*); static void fillsym(Sym*, Symbol*);
@ -152,10 +151,18 @@ syminit(int fd, Fhdr *fp)
if(i < 0) if(i < 0)
return -1; return -1;
size += i+svalsz+sizeof(p->type); size += i+svalsz+sizeof(p->type);
i = decodegotype(&b, p);
if(i < 0) if(svalsz == 8){
return -1; if(Bread(&b, &vl, 8) != 8)
size += i; return symerrmsg(8, "symbol");
p->gotype = beswav(vl);
}
else{
if(Bread(&b, &l, 4) != 4)
return symerrmsg(4, "symbol");
p->gotype = (u32int)beswal(l);
}
size += svalsz;
/* count global & auto vars, text symbols, and file names */ /* count global & auto vars, text symbols, and file names */
switch (p->type) { switch (p->type) {
@ -298,27 +305,6 @@ decodename(Biobuf *bp, Sym *p)
return n; return n;
} }
static int32
decodegotype(Biobuf *bp, Sym *p)
{
char *cp;
int32 n;
cp = Brdline(bp, '\0');
if(cp == 0) {
werrstr("can't read go type");
return -1;
}
n = Blinelen(bp);
p->gotype = malloc(n);
if(p->gotype == 0) {
werrstr("can't malloc %ld bytes", n);
return -1;
}
strcpy(p->gotype, cp);
return n;
}
/* /*
* free any previously loaded symbol tables * free any previously loaded symbol tables
*/ */

View File

@ -55,7 +55,7 @@ struct Sym
uintptr value; uintptr value;
byte symtype; byte symtype;
byte *name; byte *name;
byte *gotype; // byte *gotype;
}; };
// Walk over symtab, calling fn(&s) for each symbol. // Walk over symtab, calling fn(&s) for each symbol.
@ -96,11 +96,7 @@ walksymtab(void (*fn)(Sym*))
break; break;
p = q+1; p = q+1;
} }
q = mchr(p, '\0', ep); p += 4; // go type
if(q == nil)
break;
s.gotype = p;
p = q+1;
fn(&s); fn(&s);
} }
} }