1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:24:45 -07:00

[68]l: expose genasmsym.

R=rsc
CC=golang-dev
https://golang.org/cl/2512042
This commit is contained in:
Luuk van Dijk 2010-10-19 18:09:18 +02:00
parent e64280ecfa
commit 54aba2e6dd
3 changed files with 26 additions and 16 deletions

View File

@ -397,6 +397,7 @@ void doprof2(void);
void dostkoff(void); void dostkoff(void);
vlong entryvalue(void); vlong entryvalue(void);
void follow(void); void follow(void);
void genasmsym(void (*put)(char*, int, vlong, vlong, int, Sym*));
void gethunk(void); void gethunk(void);
void gotypestrings(void); void gotypestrings(void);
void listinit(void); void listinit(void);

View File

@ -346,6 +346,7 @@ void doprof2(void);
void dostkoff(void); void dostkoff(void);
int32 entryvalue(void); int32 entryvalue(void);
void follow(void); void follow(void);
void genasmsym(void (*put)(char*, int, vlong, vlong, int, Sym*));
void instinit(void); void instinit(void);
void listinit(void); void listinit(void);
Sym* lookup(char*, int); Sym* lookup(char*, int);

View File

@ -34,7 +34,7 @@
#include "../ld/lib.h" #include "../ld/lib.h"
void void
putsymb(char *s, int t, int32 v, int ver, Sym *go) putsymb(char *s, int t, vlong v, vlong size, int ver, Sym *go)
{ {
int i, f; int i, f;
vlong gv; vlong gv;
@ -89,7 +89,7 @@ putsymb(char *s, int t, int32 v, int ver, Sym *go)
} }
void void
asmsym(void) genasmsym(void (*put)(char*, int, vlong, vlong, int, Sym*))
{ {
Auto *a; Auto *a;
Sym *s; Sym *s;
@ -97,10 +97,10 @@ 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, 0); put(s->name, 'T', s->value, s->size, s->version, 0);
for(h=0; h<NHASH; h++) for(h=0; h<NHASH; h++) {
for(s=hash[h]; s!=S; s=s->hash) for(s=hash[h]; s!=S; s=s->hash) {
switch(s->type) { switch(s->type) {
case SCONST: case SCONST:
case SRODATA: case SRODATA:
@ -108,52 +108,60 @@ asmsym(void)
case SELFDATA: case SELFDATA:
if(!s->reachable) if(!s->reachable)
continue; continue;
putsymb(s->name, 'D', symaddr(s), s->version, s->gotype); put(s->name, 'D', symaddr(s), s->size, s->version, s->gotype);
continue; continue;
case SMACHO: case SMACHO:
if(!s->reachable) if(!s->reachable)
continue; continue;
putsymb(s->name, 'D', s->value+INITDAT+segdata.filelen-dynptrsize, s->version, s->gotype); put(s->name, 'D', s->value+INITDAT+segdata.filelen-dynptrsize, s->size, s->version, s->gotype);
continue; continue;
case SBSS: case SBSS:
if(!s->reachable) if(!s->reachable)
continue; continue;
putsymb(s->name, 'B', s->value+INITDAT, s->version, s->gotype); put(s->name, 'B', s->value+INITDAT, s->size, s->version, s->gotype);
continue; continue;
case SFIXED: case SFIXED:
putsymb(s->name, 'B', s->value, s->version, s->gotype); put(s->name, 'B', s->value, s->size, s->version, s->gotype);
continue; continue;
case SFILE: case SFILE:
putsymb(s->name, 'f', s->value, s->version, 0); put(s->name, 'f', s->value, 0, s->version, 0);
continue; continue;
} }
}
}
for(s = textp; s != nil; s = s->next) { for(s = textp; s != nil; s = s->next) {
/* filenames first */ /* filenames first */
for(a=s->autom; a; a=a->link) for(a=s->autom; a; a=a->link)
if(a->type == D_FILE) if(a->type == D_FILE)
putsymb(a->asym->name, 'z', a->aoffset, 0, 0); put(a->asym->name, 'z', a->aoffset, 0, 0, 0);
else else
if(a->type == D_FILE1) if(a->type == D_FILE1)
putsymb(a->asym->name, 'Z', a->aoffset, 0, 0); put(a->asym->name, 'Z', a->aoffset, 0, 0, 0);
putsymb(s->name, 'T', s->value, s->version, s->gotype); put(s->name, 'T', s->value, s->size, s->version, s->gotype);
/* frame, auto and param after */ /* frame, auto and param after */
putsymb(".frame", 'm', s->text->to.offset+4, 0, 0); put(".frame", 'm', s->text->to.offset+4, 0, 0, 0);
for(a=s->autom; a; a=a->link) for(a=s->autom; a; a=a->link)
if(a->type == D_AUTO) if(a->type == D_AUTO)
putsymb(a->asym->name, 'a', -a->aoffset, 0, a->gotype); put(a->asym->name, 'a', -a->aoffset, 0, 0, a->gotype);
else else
if(a->type == D_PARAM) if(a->type == D_PARAM)
putsymb(a->asym->name, 'p', a->aoffset, 0, a->gotype); put(a->asym->name, 'p', a->aoffset, 0, 0, a->gotype);
} }
if(debug['v'] || debug['n']) if(debug['v'] || debug['n'])
Bprint(&bso, "symsize = %ud\n", symsize); Bprint(&bso, "symsize = %ud\n", symsize);
Bflush(&bso); Bflush(&bso);
} }
void
asmsym(void)
{
genasmsym(putsymb);
}