Skip to content

Commit 28ef4c3

Browse files
committed
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 <[email protected]>
1 parent 4e777c8 commit 28ef4c3

File tree

1 file changed

+7
-4
lines changed
  • src/cmd/link/internal/ld

1 file changed

+7
-4
lines changed

src/cmd/link/internal/ld/go.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,14 @@ func ldpkg(f *obj.Biobuf, pkg string, length int64, filename string, whence int)
8787
return
8888
}
8989

90+
// \n$$B marks the beginning of binary export data - don't skip over the B
9091
p0 += 3
91-
for p0 < len(data) && data[p0] != '\n' {
92+
for p0 < len(data) && data[p0] != '\n' && data[p0] != 'B' {
9293
p0++
9394
}
9495

9596
// second marks end of exports / beginning of local data
96-
p1 = strings.Index(data[p0:], "\n$$")
97+
p1 = strings.Index(data[p0:], "\n$$\n")
9798
if p1 < 0 {
9899
fmt.Fprintf(os.Stderr, "%s: cannot find end of exports in %s\n", os.Args[0], filename)
99100
if Debug['u'] != 0 {
@@ -103,10 +104,12 @@ func ldpkg(f *obj.Biobuf, pkg string, length int64, filename string, whence int)
103104
}
104105
p1 += p0
105106

106-
for p0 < p1 && (data[p0] == ' ' || data[p0] == '\t' || data[p0] == '\n') {
107+
for p0 < p1 && data[p0] != 'B' && (data[p0] == ' ' || data[p0] == '\t' || data[p0] == '\n') {
107108
p0++
108109
}
109-
if p0 < p1 {
110+
// don't check this section if we have binary (B) export data
111+
// TODO fix this eventually
112+
if p0 < p1 && data[p0] != 'B' {
110113
if !strings.HasPrefix(data[p0:], "package ") {
111114
fmt.Fprintf(os.Stderr, "%s: bad package section in %s - %.20s\n", os.Args[0], filename, data[p0:])
112115
if Debug['u'] != 0 {

0 commit comments

Comments
 (0)