src/cmd/gopack/ar.c | 19 +++++++++++++++---- test/fixedbugs/bug302.dir/main.go | 5 +++++ test/fixedbugs/bug302.go | 2 +- test/run | 2 +- diff --git a/src/cmd/gopack/ar.c b/src/cmd/gopack/ar.c index 377366ec48ca7b47575ac8db74ea5fba7d3c0c98..5c8cd75efd1fe2652ebd720eb58b39bd58ef440a 100644 --- a/src/cmd/gopack/ar.c +++ b/src/cmd/gopack/ar.c @@ -601,17 +601,21 @@ obj = objtype(b, 0); if (obj < 0) { /* not an object file */ if (!gflag || strcmp(file, pkgdef) != 0) { /* don't clear allobj if it's pkg defs */ fprint(2, "gopack: non-object file %s\n", file); + errors++; allobj = 0; } d = dirfstat(Bfildes(b)); - if (d != nil && d->length == 0) + if (d != nil && d->length == 0) { fprint(2, "gopack: zero length file %s\n", file); + errors++; + } free(d); Bseek(b, offset, 0); return; } if (lastobj >= 0 && obj != lastobj) { fprint(2, "gopack: inconsistent object file %s\n", file); + errors++; allobj = 0; Bseek(b, offset, 0); return; @@ -619,6 +623,7 @@ } lastobj = obj; if (!readar(b, obj, offset+size, 0)) { fprint(2, "gopack: invalid symbol reference in file %s\n", file); + errors++; allobj = 0; Bseek(b, offset, 0); return; @@ -718,8 +723,8 @@ pkg = nil; first = 1; start = end = 0; for (n=0; n sizeof(pkgbuf)-1) @@ -742,14 +747,19 @@ if(strcmp(pkg, " safe\n") != 0) safe = 0; start = Boffset(b); // after package statement first = 0; + free(line); continue; } - if(line[0] == '$' && line[1] == '$') + if(line[0] == '$' && line[1] == '$') { + free(line); goto foundend; + } end = Boffset(b); // before closing $$ + free(line); } bad: fprint(2, "gopack: bad package import section in %s\n", file); + errors++; return; foundend: @@ -795,6 +805,7 @@ as->file = arstrdup(file); if(s->type == 'T' && duplicate(as->name, &ofile)) { dupfound = 1; fprint(2, "duplicate text symbol: %s and %s: %s\n", as->file, ofile, as->name); + errors++; free(as->name); free(as); return; diff --git a/test/fixedbugs/bug302.dir/main.go b/test/fixedbugs/bug302.dir/main.go index 40131995859d6493e0113d52febb176f39571176..9f874d08f52ace9a41445dac3ec7f38af48b14d1 100644 --- a/test/fixedbugs/bug302.dir/main.go +++ b/test/fixedbugs/bug302.dir/main.go @@ -4,4 +4,9 @@ // license that can be found in the LICENSE file. package main +// Check that the export information is correct in p.6. import _ "./p" + +// Check that it's still correct in pp.a (which contains p.6). +import _ "./pp" + diff --git a/test/fixedbugs/bug302.go b/test/fixedbugs/bug302.go index 2a1d922d3013770ee96003f327c75c0aa7d19b86..e9edb94ac8041c35eba1bb2918253b7ebbcb2fb6 100644 --- a/test/fixedbugs/bug302.go +++ b/test/fixedbugs/bug302.go @@ -1,4 +1,4 @@ -// $G $D/bug302.dir/p.go && $G $D/bug302.dir/main.go +// $G $D/bug302.dir/p.go && gopack grc pp.a p.$A && $G $D/bug302.dir/main.go // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style diff --git a/test/run b/test/run index 6d02c918426d23a85d6f0b315a0efae2199a730d..d2c6b4dc9a086858bf3b5977e65a864f3702581a 100755 --- a/test/run +++ b/test/run @@ -101,7 +101,7 @@ /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d /Segmentation fault/d /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out -rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A $A.out +rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out diffmsg="" if ! diff golden.out run.out then