diff options
author | Russ Cox <rsc@golang.org> | 2013-12-17 21:43:33 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2013-12-17 21:43:33 -0500 |
commit | 07e48d93cafafc4cf2bf9082be6c0c8bf17a5db2 (patch) | |
tree | b6b0873eca41ab4323d69db3bac99e402ec90258 /src/cmd/ld/lib.c | |
parent | 6cf2b6fcbb73ac89921d4c953927ea8f6ec3c806 (diff) | |
download | go-07e48d93cafafc4cf2bf9082be6c0c8bf17a5db2.tar.gz |
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://codereview.appspot.com/42880043
Diffstat (limited to 'src/cmd/ld/lib.c')
-rw-r--r-- | src/cmd/ld/lib.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c index 76a3a1393..f4ac30a57 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; |