1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:10:22 -07:00

add symbol tables and line/pc information to 6.outs

SVN=122699
This commit is contained in:
Rob Pike 2008-06-13 12:54:21 -07:00
parent a432e09b44
commit e9c9c9ace5
2 changed files with 89 additions and 54 deletions

View File

@ -124,6 +124,9 @@ asmb(void)
int a; int a;
uchar *op1; uchar *op1;
vlong vl, va, fo, w; vlong vl, va, fo, w;
int strtabsize;
strtabsize = 0;
if(debug['v']) if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime()); Bprint(&bso, "%5.2f asmb\n", cputime());
@ -187,6 +190,10 @@ asmb(void)
break; break;
case 7: case 7:
debug['8'] = 1; /* 64-bit addresses */
seek(cout, rnd(HEADR+textsize, INITRND)+datsize, 0);
strtabsize = linuxstrtable();
cflush();
v = rnd(HEADR+textsize, INITRND); v = rnd(HEADR+textsize, INITRND);
myseek(cout, v); myseek(cout, v);
break; break;
@ -221,17 +228,15 @@ asmb(void)
default: default:
case 2: case 2:
case 5: case 5:
debug['s'] = 1; debug['s'] = 1;
seek(cout, HEADR+textsize+datsize, 0); seek(cout, HEADR+textsize+datsize, 0);
break; break;
case 7:
debug['s'] = 1;
seek(cout, rnd(HEADR+textsize, INITRND)+datsize, 0);
linuxstrtable();
break;
case 6: case 6:
debug['s'] = 1; debug['s'] = 1;
break; break;
case 7:
seek(cout, rnd(HEADR+textsize, INITRND)+datsize+strtabsize, 0);
break;
} }
if(!debug['s']) if(!debug['s'])
asmsym(); asmsym();
@ -402,13 +407,15 @@ debug['s'] = 1;
wputl(56); /* Phdr size */ wputl(56); /* Phdr size */
wputl(3); /* # of Phdrs */ wputl(3); /* # of Phdrs */
wputl(64); /* Shdr size */ wputl(64); /* Shdr size */
wputl(5); /* # of Shdrs */ if (!debug['s'])
wputl(7); /* # of Shdrs */
else
wputl(5); /* # of Shdrs */
wputl(4); /* Shdr with strings */ wputl(4); /* Shdr with strings */
fo = 0; fo = 0;
va = INITRND; va = INITRND;
w = HEADR+textsize; w = HEADR+textsize;
linuxphdr(1, /* text - type = PT_LOAD */ linuxphdr(1, /* text - type = PT_LOAD */
1L+4L, /* text - flags = PF_X+PF_R */ 1L+4L, /* text - flags = PF_X+PF_R */
@ -419,9 +426,9 @@ w = HEADR+textsize;
w, /* memory size */ w, /* memory size */
INITRND); /* alignment */ INITRND); /* alignment */
fo = rnd(fo+w, INITRND); fo = rnd(fo+w, INITRND);
va = rnd(va+w, INITRND); va = rnd(va+w, INITRND);
w = datsize; w = datsize;
linuxphdr(1, /* data - type = PT_LOAD */ linuxphdr(1, /* data - type = PT_LOAD */
2L+4L, /* data - flags = PF_W+PF_R */ 2L+4L, /* data - flags = PF_W+PF_R */
@ -452,10 +459,10 @@ w = datsize;
0, /* align */ 0, /* align */
0); /* entsize */ 0); /* entsize */
stroffset = 1; stroffset = 1; /* 0 means no name, so start at 1 */
fo = 0; fo = 0;
va = INITRND; va = INITRND;
w = HEADR+textsize; w = HEADR+textsize;
linuxshdr(".text", /* name */ linuxshdr(".text", /* name */
1, /* type */ 1, /* type */
@ -468,9 +475,9 @@ w = HEADR+textsize;
8, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
fo = rnd(fo+w, INITRND); fo = rnd(fo+w, INITRND);
va = rnd(va+w, INITRND); va = rnd(va+w, INITRND);
w = datsize; w = datsize;
linuxshdr(".data", /* name */ linuxshdr(".data", /* name */
1, /* type */ 1, /* type */
@ -483,9 +490,9 @@ w = datsize;
8, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
fo += w; fo += w;
va += w; va += w;
w = bsssize; w = bsssize;
linuxshdr(".bss", /* name */ linuxshdr(".bss", /* name */
8, /* type */ 8, /* type */
@ -498,9 +505,7 @@ w = bsssize;
8, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
w = stroffset + w = strtabsize;
strlen(".shstrtab")+1;
// strlen(".gosymtab")+1;
linuxshdr(".shstrtab", /* name */ linuxshdr(".shstrtab", /* name */
3, /* type */ 3, /* type */
@ -513,18 +518,36 @@ w = stroffset +
8, /* align */ 8, /* align */
0); /* entsize */ 0); /* entsize */
//fo += w; if (debug['s'])
// break;
// linuxshdr(".gosymtab", /* name */
// 2, /* type */ fo += w;
// 0, /* flags */ w = symsize;
// 0, /* addr */
// fo, /* off */ linuxshdr(".gosymtab", /* name */
// 0, /* size */ 2, /* type */
// 0, /* link */ 0, /* flags */
// 0, /* info */ 0, /* addr */
// 8, /* align */ fo, /* off */
// 0); /* entsize */ w, /* size */
0, /* link */
0, /* info */
8, /* align */
24); /* entsize */
fo += w;
w = lcsize;
linuxshdr(".gopclntab", /* name */
2, /* type */
0, /* flags */
0, /* addr */
fo, /* off */
w, /* size */
0, /* link */
0, /* info */
8, /* align */
24); /* entsize */
break; break;
} }
cflush(); cflush();
@ -796,7 +819,10 @@ linuxheadr(void)
a += 64; /* .data seg */ a += 64; /* .data seg */
a += 64; /* .bss sect */ a += 64; /* .bss sect */
a += 64; /* .shstrtab sect - strings for headers */ a += 64; /* .shstrtab sect - strings for headers */
// a += 64; /* .gosymtab sect */ if (!debug['s']) {
a += 64; /* .gosymtab sect */
a += 64; /* .gopclntab sect */
}
return a; return a;
} }
@ -837,21 +863,30 @@ linuxshdr(char *name, ulong type, vlong flags, vlong addr, vlong off,
stroffset += strlen(name)+1; stroffset += strlen(name)+1;
} }
void int
putstrtab(char* name) {
int w;
w = strlen(name)+1;
strnput(name, w);
return w;
}
int
linuxstrtable(void) linuxstrtable(void)
{ {
char *name; char *name;
int size;
name = ""; size = 0;
strnput(name, strlen(name)+1); size += putstrtab("");
name = ".text"; size += putstrtab(".text");
strnput(name, strlen(name)+1); size += putstrtab(".data");
name = ".data"; size += putstrtab(".bss");
strnput(name, strlen(name)+1); size += putstrtab(".shstrtab");
name = ".bss"; if (!debug['s']) {
strnput(name, strlen(name)+1); size += putstrtab(".gosymtab");
name = ".shstrtab"; size += putstrtab(".gopclntab");
strnput(name, strlen(name)+1); }
// name = ".gosymtab"; return size;
// strnput(name, strlen(name)+1);
} }

View File

@ -431,7 +431,7 @@ void linuxphdr(int type, int flags, vlong foff,
vlong filesize, vlong memsize, vlong align); vlong filesize, vlong memsize, vlong align);
void linuxshdr(char *name, ulong type, vlong flags, vlong addr, vlong off, void linuxshdr(char *name, ulong type, vlong flags, vlong addr, vlong off,
vlong size, ulong link, ulong info, vlong align, vlong entsize); vlong size, ulong link, ulong info, vlong align, vlong entsize);
void linuxstrtable(void); int linuxstrtable(void);
#pragma varargck type "D" Adr* #pragma varargck type "D" Adr*