From d5f4d94b8084848b71bd34ab4e744303673d6b20 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Wed, 9 Jul 2008 16:40:11 -0700 Subject: [PATCH] redefinition fix for autolib: if first ATEXT is already defined, skip this file SVN=126580 --- src/cmd/6l/obj.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index 02bd12298f2..41976b60539 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -461,7 +461,7 @@ objfile(char *file) struct ar_hdr arhdr; char *e, *start, *stop; - if(file[0] == '-' && file[1] == 'l') { + if(file[0] == '-' && file[1] == 'l') { // TODO: fix this if(debug['9']) sprint(name, "/%s/lib/lib", thestring); else @@ -819,6 +819,9 @@ ldobj(int f, long c, char *pn) static int files; static char **filen; char **nfilen; + int ntext; + + ntext = 0; if((files&15) == 0){ nfilen = malloc((files+16)*sizeof(char*)); @@ -1062,6 +1065,13 @@ loop: goto loop; case ATEXT: + s = p->from.sym; + if(ntext++ == 0 && s->type != 0 && s->type != SXREF) { + /* redefinition, so file has probably been seen before */ + if(debug['v']) + diag("skipping: %s: redefinition: %s", pn, s->name); + return; + } if(curtext != P) { histtoauto(); curtext->to.autom = curauto; @@ -1069,7 +1079,6 @@ loop: } skip = 0; curtext = p; - s = p->from.sym; if(s == S) { diag("%s: no TEXT symbol: %P", pn, p); errorexit();