1
0
mirror of https://github.com/golang/go synced 2024-09-30 12:18:33 -06:00

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 <cmang@golang.org>
This commit is contained in:
Robert Griesemer 2015-10-22 10:41:15 -07:00
parent 4e777c8eff
commit 28ef4c38c8

View 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 {