1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:54:43 -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;
char type;
char *name;
char *gotype;
vlong gotype;
int sequence; // order in file
};
/*

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -87,7 +87,6 @@ static uvlong firstinstr; /* as found from symtab; needed for amd64 */
static void cleansyms(void);
static int32 decodename(Biobuf*, Sym*);
static int32 decodegotype(Biobuf*, Sym*);
static short *encfname(char*);
static int fline(char*, int, int32, Hist*, Hist**);
static void fillsym(Sym*, Symbol*);
@ -152,10 +151,18 @@ syminit(int fd, Fhdr *fp)
if(i < 0)
return -1;
size += i+svalsz+sizeof(p->type);
i = decodegotype(&b, p);
if(i < 0)
return -1;
size += i;
if(svalsz == 8){
if(Bread(&b, &vl, 8) != 8)
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 */
switch (p->type) {
@ -298,27 +305,6 @@ decodename(Biobuf *bp, Sym *p)
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
*/

View File

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