mirror of
https://github.com/golang/go
synced 2024-11-21 18:24:46 -07:00
ld: do not load the same object file multiple times.
eliminates spurious multiple initialization errors. give more information in the multiple init errors that remain. Fixes #87. R=r CC=golang-dev https://golang.org/cl/194052
This commit is contained in:
parent
34191d943b
commit
69e244a104
@ -659,6 +659,12 @@ loop:
|
||||
if(s != S) {
|
||||
p->dlink = s->data;
|
||||
s->data = p;
|
||||
if(s->file == nil)
|
||||
s->file = pn;
|
||||
else if(s->file != pn) {
|
||||
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
|
||||
errorexit();
|
||||
}
|
||||
}
|
||||
if(edatap == P)
|
||||
datap = p;
|
||||
|
@ -692,6 +692,12 @@ loop:
|
||||
if(s != S) {
|
||||
p->dlink = s->data;
|
||||
s->data = p;
|
||||
if(s->file == nil)
|
||||
s->file = pn;
|
||||
else if(s->file != pn) {
|
||||
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
|
||||
errorexit();
|
||||
}
|
||||
}
|
||||
if(edatap == P)
|
||||
datap = p;
|
||||
|
@ -729,6 +729,12 @@ loop:
|
||||
if(s != S) {
|
||||
p->dlink = s->data;
|
||||
s->data = p;
|
||||
if(s->file == nil)
|
||||
s->file = pn;
|
||||
else if(s->file != pn) {
|
||||
diag("multiple initialization for %s: in both %s and %s", s->name, s->file, pn);
|
||||
errorexit();
|
||||
}
|
||||
}
|
||||
if(edatap == P)
|
||||
datap = p;
|
||||
|
@ -338,13 +338,21 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn)
|
||||
static int files;
|
||||
static char **filen;
|
||||
char **nfilen, *line;
|
||||
int n, c1, c2, c3;
|
||||
int i, n, c1, c2, c3;
|
||||
vlong import0, import1, eof;
|
||||
char src[1024];
|
||||
|
||||
eof = Boffset(f) + len;
|
||||
src[0] = '\0';
|
||||
|
||||
// don't load individual object more than once.
|
||||
// happens with import of .6 files because of loop in xresolv.
|
||||
// doesn't happen with .a because SYMDEF is consulted
|
||||
// first to decide whether each individual object file is needed.
|
||||
for(i=0; i<files; i++)
|
||||
if(strcmp(filen[i], pn) == 0)
|
||||
return;
|
||||
|
||||
if((files&15) == 0){
|
||||
nfilen = malloc((files+16)*sizeof(char*));
|
||||
memmove(nfilen, filen, files*sizeof(char*));
|
||||
@ -354,7 +362,6 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn)
|
||||
pn = strdup(pn);
|
||||
filen[files++] = pn;
|
||||
|
||||
|
||||
/* check the header */
|
||||
line = Brdline(f, '\n');
|
||||
if(line == nil) {
|
||||
@ -390,7 +397,6 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn)
|
||||
ldpkg(f, pkg, import1 - import0 - 2, pn); // -2 for !\n
|
||||
Bseek(f, import1, 0);
|
||||
|
||||
// PGNS: Should be using import path, not pkg.
|
||||
ldobj1(f, pkg, eof - Boffset(f), pn);
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user