aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-12-17 21:43:33 -0500
committerRuss Cox <rsc@golang.org>2013-12-17 21:43:33 -0500
commitb02233402961621e1cd705d79dcf63387daadea2 (patch)
treea9cd225a70bc87fc9f64700b94f1f7630b51b93d /src/cmd/ld
parentdeb554934c0c2a87b24f4eb29cdcbbd4ea68a6d6 (diff)
downloadgo-b02233402961621e1cd705d79dcf63387daadea2.tar.xz
cmd/gc: implement -pack flag
The -pack flag causes 5g, 6g, 8g to write a Go archive directly, instead of requiring the use of 'go tool pack' to convert the .5/.6/.8 to .a format. Writing directly avoids the copy and also avoids having the export data stored twice in the archive (once in __.PKGDEF, once in .5/.6/.8). A separate CL will enable the use of this flag by cmd/go. Other build systems that do not know about -pack will be unaffected. The changes to cmd/ld handle a minor simplification to the format: an unused section is removed. R=iant, r CC=golang-dev https://golang.org/cl/42880043
Diffstat (limited to 'src/cmd/ld')
-rw-r--r--src/cmd/ld/go.c21
-rw-r--r--src/cmd/ld/lib.c21
2 files changed, 11 insertions, 31 deletions
diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c
index 900ecb0ae9..a5a0fa5433 100644
--- a/src/cmd/ld/go.c
+++ b/src/cmd/ld/go.c
@@ -151,28 +151,11 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename, int whence)
}
loadpkgdata(filename, pkg, p0, p1 - p0);
}
-
- // The __.PKGDEF archive summary has no local types.
+
+ // __.PKGDEF has no cgo section - those are in the C compiler-generated object files.
if(whence == Pkgdef)
return;
- // local types begin where exports end.
- // skip rest of line after $$ we found above
- p0 = p1 + 3;
- while(*p0 != '\n' && *p0 != '\0')
- p0++;
-
- // local types end at next \n$$.
- p1 = strstr(p0, "\n$$");
- if(p1 == nil) {
- fprint(2, "%s: cannot find end of local types in %s\n", argv0, filename);
- if(debug['u'])
- errorexit();
- return;
- }
-
- loadpkgdata(filename, pkg, p0, p1 - p0);
-
// look for cgo section
p0 = strstr(p1, "\n$$ // cgo");
if(p0 != nil) {
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
index 76a3a1393a..f4ac30a571 100644
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -327,25 +327,22 @@ objfile(char *file, char *pkg)
return;
}
- /* skip over __.GOSYMDEF */
+ /* skip over optional __.GOSYMDEF and process __.PKGDEF */
off = Boffset(f);
if((l = nextar(f, off, &arhdr)) <= 0) {
diag("%s: short read on archive file symbol header", file);
goto out;
}
- if(strncmp(arhdr.name, symname, strlen(symname))) {
- diag("%s: first entry not symbol header", file);
- goto out;
- }
- off += l;
-
- /* skip over (or process) __.PKGDEF */
- if((l = nextar(f, off, &arhdr)) <= 0) {
- diag("%s: short read on archive file symbol header", file);
- goto out;
+ if(strncmp(arhdr.name, symname, strlen(symname)) == 0) {
+ off += l;
+ if((l = nextar(f, off, &arhdr)) <= 0) {
+ diag("%s: short read on archive file symbol header", file);
+ goto out;
+ }
}
+
if(strncmp(arhdr.name, pkgname, strlen(pkgname))) {
- diag("%s: second entry not package header", file);
+ diag("%s: cannot find package header", file);
goto out;
}
off += l;