1
0
mirror of https://github.com/golang/go synced 2024-11-17 23:04:56 -07:00

cmd/ld: correct pe section number in symbol table

Update #7899

LGTM=iant
R=golang-codereviews, rsc, iant
CC=golang-codereviews
https://golang.org/cl/97920044
This commit is contained in:
Alex Brainman 2014-05-06 11:40:43 +10:00
parent 0462d091e2
commit cf78f96244

View File

@ -84,6 +84,7 @@ struct COFFSym
LSym* sym;
int strtbloff;
int sect;
vlong value;
};
static COFFSym* coffsym;
@ -476,6 +477,7 @@ newPEDWARFSection(char *name, vlong size)
static void
addsym(LSym *s, char *name, int type, vlong addr, vlong size, int ver, LSym *gotype)
{
COFFSym *cs;
USED(name);
USED(addr);
USED(size);
@ -498,28 +500,25 @@ addsym(LSym *s, char *name, int type, vlong addr, vlong size, int ver, LSym *got
}
if(coffsym) {
coffsym[ncoffsym].sym = s;
cs = &coffsym[ncoffsym];
cs->sym = s;
if(strlen(s->name) > 8)
coffsym[ncoffsym].strtbloff = strtbladd(s->name);
if(type == 'T')
coffsym[ncoffsym].sect = textsect;
else
coffsym[ncoffsym].sect = datasect;
cs->strtbloff = strtbladd(s->name);
if(s->value >= segdata.vaddr) {
cs->value = s->value - segdata.vaddr;
cs->sect = datasect;
} else if(s->value >= segtext.vaddr) {
cs->value = s->value - segtext.vaddr;
cs->sect = textsect;
} else {
cs->value = 0;
cs->sect = 0;
diag("addsym %#llx", addr);
}
}
ncoffsym++;
}
static vlong
datoffsect(vlong addr)
{
if(addr >= segdata.vaddr)
return addr - segdata.vaddr;
if(addr >= segtext.vaddr)
return addr - segtext.vaddr;
diag("datoff %#llx", addr);
return 0;
}
static void
addsymtable(void)
{
@ -551,7 +550,7 @@ addsymtable(void)
lputl(0);
lputl(s->strtbloff);
}
lputl(datoffsect(s->sym->value));
lputl(s->value);
wputl(s->sect);
wputl(0x0308); // "array of structs"
cput(2); // storage class: external