From 28ef4c38c8ad12de60aa741d46c3978a64faf54c Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 22 Oct 2015 10:41:15 -0700 Subject: [PATCH] cmd/link/internal/ld: export data may be marked with $$ or $$B 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 --- src/cmd/link/internal/ld/go.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cmd/link/internal/ld/go.go b/src/cmd/link/internal/ld/go.go index 80a6c6ed7d..efe6dd0ad7 100644 --- a/src/cmd/link/internal/ld/go.go +++ b/src/cmd/link/internal/ld/go.go @@ -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 {