go.tools/go/gcimporter: adjust for new .a file format

R=rsc, r
CC=golang-dev
https://golang.org/cl/41510044
This commit is contained in:
Robert Griesemer 2013-12-18 10:53:59 -08:00
parent b6e674b8e7
commit 4e3127283a
1 changed files with 19 additions and 22 deletions

View File

@ -48,21 +48,16 @@ func FindExportData(r *bufio.Reader) (err error) {
return return
} }
if string(line) == "!<arch>\n" { if string(line) == "!<arch>\n" {
// Archive file. Scan to __.PKGDEF, which should // Archive file. Scan to __.PKGDEF.
// be second archive entry.
var name string var name string
var size int var size int
// First entry should be __.GOSYMDEF.
// Older archives used __.SYMDEF, so allow that too.
// Read and discard.
if name, size, err = readGopackHeader(r); err != nil { if name, size, err = readGopackHeader(r); err != nil {
return return
} }
if name != "__.SYMDEF" && name != "__.GOSYMDEF" {
err = errors.New("go archive does not begin with __.SYMDEF or __.GOSYMDEF") // Optional leading __.GOSYMDEF or __.SYMDEF.
return // Read and discard.
} if name == "__.SYMDEF" || name == "__.GOSYMDEF" {
const block = 4096 const block = 4096
tmp := make([]byte, block) tmp := make([]byte, block)
for size > 0 { for size > 0 {
@ -76,10 +71,12 @@ func FindExportData(r *bufio.Reader) (err error) {
size -= n size -= n
} }
// Second entry should be __.PKGDEF.
if name, size, err = readGopackHeader(r); err != nil { if name, size, err = readGopackHeader(r); err != nil {
return return
} }
}
// First real entry should be __.PKGDEF.
if name != "__.PKGDEF" { if name != "__.PKGDEF" {
err = errors.New("go archive is missing __.PKGDEF") err = errors.New("go archive is missing __.PKGDEF")
return return