]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: export data may be marked with $$ or $$B
authorRobert Griesemer <gri@golang.org>
Thu, 22 Oct 2015 17:41:15 +0000 (10:41 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 22 Oct 2015 18:06:08 +0000 (18:06 +0000)
Preparation for dealing with binary export format. Accept $$B
as marker for export data. For now, skip that data if found.

Change-Id: I464ba22aaedcf349725379d91070fc900d93b7a2
Reviewed-on: https://go-review.googlesource.com/16222
Reviewed-by: Chris Manghane <cmang@golang.org>
src/cmd/link/internal/ld/go.go

index 80a6c6ed7d0f78692fc663bf734433a5ed7d9c97..efe6dd0ad7cbcf48228e2845dc6ac55e21159f32 100644 (file)
@@ -87,13 +87,14 @@ func ldpkg(f *obj.Biobuf, pkg string, length int64, filename string, whence int)
                return
        }
 
+       // \n$$B marks the beginning of binary export data - don't skip over the B
        p0 += 3
-       for p0 < len(data) && data[p0] != '\n' {
+       for p0 < len(data) && data[p0] != '\n' && data[p0] != 'B' {
                p0++
        }
 
        // second marks end of exports / beginning of local data
-       p1 = strings.Index(data[p0:], "\n$$")
+       p1 = strings.Index(data[p0:], "\n$$\n")
        if p1 < 0 {
                fmt.Fprintf(os.Stderr, "%s: cannot find end of exports in %s\n", os.Args[0], filename)
                if Debug['u'] != 0 {
@@ -103,10 +104,12 @@ func ldpkg(f *obj.Biobuf, pkg string, length int64, filename string, whence int)
        }
        p1 += p0
 
-       for p0 < p1 && (data[p0] == ' ' || data[p0] == '\t' || data[p0] == '\n') {
+       for p0 < p1 && data[p0] != 'B' && (data[p0] == ' ' || data[p0] == '\t' || data[p0] == '\n') {
                p0++
        }
-       if p0 < p1 {
+       // don't check this section if we have binary (B) export data
+       // TODO fix this eventually
+       if p0 < p1 && data[p0] != 'B' {
                if !strings.HasPrefix(data[p0:], "package ") {
                        fmt.Fprintf(os.Stderr, "%s: bad package section in %s - %.20s\n", os.Args[0], filename, data[p0:])
                        if Debug['u'] != 0 {