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

ld: defend against some broken object files

Fixes #1698.
Fixes #1699.

R=ken2
CC=golang-dev
https://golang.org/cl/4419041
This commit is contained in:
Russ Cox 2011-04-14 10:42:48 -04:00
parent 36713a2a53
commit bd43a2d9ff
6 changed files with 18 additions and 7 deletions

View File

@ -581,7 +581,7 @@ loop:
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
errorexit();
}
savedata(s, p);
savedata(s, p, pn);
unmal(p, sizeof *p);
break;

View File

@ -356,6 +356,15 @@ zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[])
return;
}
}
switch(t) {
case D_FILE:
case D_FILE1:
case D_AUTO:
case D_PARAM:
if(s == S)
mangle(pn);
}
u = mal(sizeof(*u));
u->link = curauto;
@ -559,7 +568,7 @@ loop:
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
errorexit();
}
savedata(s, p);
savedata(s, p, pn);
unmal(p, sizeof *p);
goto loop;

View File

@ -600,7 +600,7 @@ loop:
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
errorexit();
}
savedata(s, p);
savedata(s, p, pn);
unmal(p, sizeof *p);
goto loop;

View File

@ -312,7 +312,7 @@ symgrow(Sym *s, int32 siz)
}
void
savedata(Sym *s, Prog *p)
savedata(Sym *s, Prog *p, char *pn)
{
int32 off, siz, i, fl;
uchar *cast;
@ -321,8 +321,10 @@ savedata(Sym *s, Prog *p)
off = p->from.offset;
siz = p->datasize;
if(off < 0 || siz < 0 || off >= 1<<30 || siz >= 100)
mangle(pn);
symgrow(s, off+siz);
switch(p->to.type) {
default:
diag("bad data: %P", p);

View File

@ -438,7 +438,7 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
return;
}
t = smprint("%s %s %s", getgoos(), thestring, getgoversion());
if(strcmp(line+10, t) != 0) {
if(strcmp(line+10, t) != 0 && !debug['f']) {
diag("%s: object is [%s] expected [%s]", pn, line+10, t);
free(t);
return;

View File

@ -173,7 +173,7 @@ void datblk(int32, int32);
Sym* datsort(Sym*);
void reloc(void);
void relocsym(Sym*);
void savedata(Sym*, Prog*);
void savedata(Sym*, Prog*, char*);
void symgrow(Sym*, int32);
vlong addstring(Sym*, char*);
vlong adduint32(Sym*, uint32);