mirror of
https://github.com/golang/go
synced 2024-11-25 12:07:56 -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) {
|
if(s != S) {
|
||||||
p->dlink = s->data;
|
p->dlink = s->data;
|
||||||
s->data = p;
|
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)
|
if(edatap == P)
|
||||||
datap = p;
|
datap = p;
|
||||||
|
@ -692,6 +692,12 @@ loop:
|
|||||||
if(s != S) {
|
if(s != S) {
|
||||||
p->dlink = s->data;
|
p->dlink = s->data;
|
||||||
s->data = p;
|
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)
|
if(edatap == P)
|
||||||
datap = p;
|
datap = p;
|
||||||
|
@ -729,6 +729,12 @@ loop:
|
|||||||
if(s != S) {
|
if(s != S) {
|
||||||
p->dlink = s->data;
|
p->dlink = s->data;
|
||||||
s->data = p;
|
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)
|
if(edatap == P)
|
||||||
datap = p;
|
datap = p;
|
||||||
|
@ -338,13 +338,21 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn)
|
|||||||
static int files;
|
static int files;
|
||||||
static char **filen;
|
static char **filen;
|
||||||
char **nfilen, *line;
|
char **nfilen, *line;
|
||||||
int n, c1, c2, c3;
|
int i, n, c1, c2, c3;
|
||||||
vlong import0, import1, eof;
|
vlong import0, import1, eof;
|
||||||
char src[1024];
|
char src[1024];
|
||||||
|
|
||||||
eof = Boffset(f) + len;
|
eof = Boffset(f) + len;
|
||||||
src[0] = '\0';
|
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){
|
if((files&15) == 0){
|
||||||
nfilen = malloc((files+16)*sizeof(char*));
|
nfilen = malloc((files+16)*sizeof(char*));
|
||||||
memmove(nfilen, filen, files*sizeof(char*));
|
memmove(nfilen, filen, files*sizeof(char*));
|
||||||
@ -354,7 +362,6 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn)
|
|||||||
pn = strdup(pn);
|
pn = strdup(pn);
|
||||||
filen[files++] = pn;
|
filen[files++] = pn;
|
||||||
|
|
||||||
|
|
||||||
/* check the header */
|
/* check the header */
|
||||||
line = Brdline(f, '\n');
|
line = Brdline(f, '\n');
|
||||||
if(line == nil) {
|
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
|
ldpkg(f, pkg, import1 - import0 - 2, pn); // -2 for !\n
|
||||||
Bseek(f, import1, 0);
|
Bseek(f, import1, 0);
|
||||||
|
|
||||||
// PGNS: Should be using import path, not pkg.
|
|
||||||
ldobj1(f, pkg, eof - Boffset(f), pn);
|
ldobj1(f, pkg, eof - Boffset(f), pn);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user