]> Cypherpunks repositories - gostls13.git/commitdiff
liblink, cmd/link: add version number to object file
authorRuss Cox <rsc@golang.org>
Mon, 14 Apr 2014 17:20:51 +0000 (13:20 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 14 Apr 2014 17:20:51 +0000 (13:20 -0400)
There are changes we know we want to make, but not before Go 1.3
Add a version number so that we can make them more easily later.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/87670043

src/cmd/link/testdata/Makefile
src/cmd/link/testdata/autosection.6
src/cmd/link/testdata/autoweak.6
src/cmd/link/testdata/dead.6
src/cmd/link/testdata/hello.6
src/cmd/link/testdata/layout.6
src/cmd/link/testdata/link.hello.darwin.amd64
src/cmd/link/testdata/pclntab.6
src/liblink/objfile.c
src/pkg/debug/goobj/read.go

index 1d5810a800f985645aad06156c67610e909bae71..3b1b15f7313ccb7195c95889051342ab4bf36f76 100644 (file)
@@ -1,10 +1,15 @@
-all: hello.6 pclntab.6
+ALL=\
+       autosection.6\
+       autoweak.6\
+       dead.6\
+       hello.6\
+       layout.6\
+       pclntab.6\
 
-hello.6: hello.s
-       go tool 6a hello.s
+all: $(ALL)
 
-pclntab.6: pclntab.s
-       go tool 6a pclntab.s
+%.6: %.s
+       go tool 6a $*.s
 
 pclntab.s: genpcln.go
        go run genpcln.go >pclntab.s
index 62619a7ea3e36cdc72a8c89a4a59107a28269c2c..996268061bb8eae0b015b2c5796f6f755b66f40f 100644 (file)
Binary files a/src/cmd/link/testdata/autosection.6 and b/src/cmd/link/testdata/autosection.6 differ
index f7e9e69713090a69ebf1e32ba62ce2fb881de00b..7bf428b51dcc62577675796ecc31b1ede76c5cff 100644 (file)
Binary files a/src/cmd/link/testdata/autoweak.6 and b/src/cmd/link/testdata/autoweak.6 differ
index f8eaf7ab8df8abd3416d27508dee24aa8b21f25a..a512543cba614b4497add9f81ef6d5883635fce4 100644 (file)
Binary files a/src/cmd/link/testdata/dead.6 and b/src/cmd/link/testdata/dead.6 differ
index 26a04a20169dc8731970e9adf2c054424105aef9..c6435a5e6fd6d964cd87e456a99f087a97fe0e0a 100644 (file)
Binary files a/src/cmd/link/testdata/hello.6 and b/src/cmd/link/testdata/hello.6 differ
index b19491efc5cb4f5349f46b12419de50c6bd48635..0a600d7c74994a8ea741b7891f1d1e8b021fd93e 100644 (file)
Binary files a/src/cmd/link/testdata/layout.6 and b/src/cmd/link/testdata/layout.6 differ
index 5d94af1d9c3fa398c01785a9c071c8ace0725bed..b1f0a93b21927049a101dd35e3bf36624553f2d0 100644 (file)
@@ -49,8 +49,8 @@
 00001080  02 20 00 04 20 00 06 05  02 05 02 05 02 05 02 02  |. .. ...........|
 00001090  02 02 02 05 02 02 02 01  00 00 00 00 00 00 00 00  |................|
 000010a0  02 00 00 00 88 00 00 00  2f 55 73 65 72 73 2f 72  |......../Users/r|
-000010b0  73 63 2f 72 73 63 67 6f  2f 73 72 63 2f 63 6d 64  |sc/rscgo/src/cmd|
-000010c0  2f 6c 64 32 2f 74 65 73  74 64 61 74 61 2f 68 65  |/ld2/testdata/he|
+000010b0  73 63 2f 67 2f 67 6f 2f  73 72 63 2f 63 6d 64 2f  |sc/g/go/src/cmd/|
+000010c0  6c 69 6e 6b 2f 74 65 73  74 64 61 74 61 2f 68 65  |link/testdata/he|
 000010d0  6c 6c 6f 2e 73 00 00 00  00 00 00 00 00 00 00 00  |llo.s...........|
 *
 00002000  68 65 6c 6c 6f 20 77 6f  72 6c 64 0a              |hello world.|
index bc889c964a0c346dd56b00f7f8698ad5b6c62128..722a7f806e8ddf84997c425a963fd77a06a718c4 100644 (file)
Binary files a/src/cmd/link/testdata/pclntab.6 and b/src/cmd/link/testdata/pclntab.6 differ
index b6025362518683ce342b32426004288b50ae3051..f0f3f7622349359daef0e63ad7cdc700ccaaf4b1 100644 (file)
@@ -16,6 +16,7 @@
 // The file format is:
 //
 //     - magic header: "\x00\x00go13ld"
+//     - byte 1 - version number
 //     - sequence of strings giving dependencies (imported packages)
 //     - empty string (marks end of sequence)
 //     - sequence of defined symbols
@@ -248,7 +249,8 @@ linkwriteobj(Link *ctxt, Biobuf *b)
        Bputc(b, 0);
        Bputc(b, 0);
        Bprint(b, "go13ld");
-       
+       Bputc(b, 1); // version
+
        // Emit autolib.
        for(h = ctxt->hist; h != nil; h = h->link)
                if(h->offset < 0)
@@ -453,6 +455,8 @@ ldobjfile(Link *ctxt, Biobuf *f, char *pkg, int64 len, char *pn)
        Bread(f, buf, sizeof buf);
        if(memcmp(buf, startmagic, sizeof buf) != 0)
                sysfatal("%s: invalid file start %x %x %x %x %x %x %x %x", pn, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+       if((c = Bgetc(f)) != 1)
+               sysfatal("%s: invalid file version number %d", pn, c);
 
        for(;;) {
                lib = rdstring(f);
index f65abb6c27399e253c0612dd16c80c6a9a9a9b14..8882eae53496e27aae41a72ea67b66d0e80b2485 100644 (file)
@@ -573,6 +573,11 @@ func (r *objReader) parseObject(prefix []byte) error {
                return r.error(errCorruptObject)
        }
 
+       b := r.readByte()
+       if b != 1 {
+               return r.error(errCorruptObject)
+       }
+
        // Direct package dependencies.
        for {
                s := r.readString()