diff options
author | Russ Cox <rsc@golang.org> | 2010-01-25 08:53:27 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-01-25 08:53:27 -0800 |
commit | 21f966ea37841047df960b5ad5b65ae2d038bde3 (patch) | |
tree | 7bc30939b7f895277960d75ed82101429c21b7a4 /src/cmd/ld | |
parent | 67efc04f32bfdc91c66a67fd06af40453d2569ea (diff) | |
download | golang-21f966ea37841047df960b5ad5b65ae2d038bde3.tar.gz |
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 issue 87.
R=r
CC=golang-dev
http://codereview.appspot.com/194052
Diffstat (limited to 'src/cmd/ld')
-rw-r--r-- | src/cmd/ld/lib.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 7ede8c89e..550cce320 100644 --- a/src/cmd/ld/lib.c +++ b/src/cmd/ld/lib.c @@ -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; |