diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c index 9cfa0c45f4a..1ccac71bc1c 100644 --- a/src/cmd/5l/obj.c +++ b/src/cmd/5l/obj.c @@ -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; diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index e29cdb94725..ca679737144 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -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; diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c index 0d950748b60..b83293496ae 100644 --- a/src/cmd/8l/obj.c +++ b/src/cmd/8l/obj.c @@ -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; diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 7ede8c89e18..550cce32097 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