Commit 67dbde0d authored by Matthew Dempsky's avatar Matthew Dempsky

cmd: stop looking for __.(GO)?SYMDEF entries in archives

The Go toolchain stopped creating them before Go 1.3, so no point in
worrying about them today.

History:

- Git commit 250a0919 added cmd/ar, which wrote Plan 9 __.SYMDEF
entries into archive files.

- golang.org/cl/6500117 renamed __.SYMDEF to __.GOSYMDEF.  (Notably,
the commit message suggests users need to use Go nm to read symbols,
but even back then the toolchain did nothing with __.(GO)?SYMDEF files
except skip over them.)

- golang.org/cl/42880043 added the -pack flag to cmd/gc to directly
produce archives by the Go compiler, and did not write __.GOSYMDEF
entries.

- golang.org/cl/52310044 rewrote cmd/pack in Go, and removed support
for producing __.GOSYMDEF entries.

Change-Id: I255edf40d0d3690e3447e488039fcdef73c6d6b1
Reviewed-on: https://go-review.googlesource.com/19924
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5c613e91
......@@ -549,22 +549,9 @@ func skiptopkgdef(b *obj.Biobuf) bool {
return false
}
// symbol table may be first; skip it
sz := arsize(b, "__.GOSYMDEF")
if sz >= 0 {
obj.Bseek(b, int64(sz), 1)
} else {
obj.Bseek(b, 8, 0)
}
// package export block is next
sz = arsize(b, "__.PKGDEF")
if sz <= 0 {
return false
}
return true
// package export block should be first
sz := arsize(b, "__.PKGDEF")
return sz > 0
}
var idirs []string
......
......@@ -530,7 +530,7 @@ func (r *objReader) parseArchive() error {
return errCorruptArchive
}
switch name {
case "__.SYMDEF", "__.GOSYMDEF", "__.PKGDEF":
case "__.PKGDEF":
r.skip(size)
default:
oldLimit := r.limit
......
......@@ -255,10 +255,7 @@ var coutbuf struct {
f *os.File
}
const (
symname = "__.GOSYMDEF"
pkgname = "__.PKGDEF"
)
const pkgname = "__.PKGDEF"
var (
// Set if we see an object compiled by the host compiler that is not
......@@ -781,7 +778,7 @@ func objfile(lib *Library) {
return
}
/* skip over optional __.GOSYMDEF and process __.PKGDEF */
/* process __.PKGDEF */
off := obj.Boffset(f)
var arhdr ArHdr
......@@ -792,15 +789,6 @@ func objfile(lib *Library) {
goto out
}
if strings.HasPrefix(arhdr.name, symname) {
off += l
l = nextar(f, off, &arhdr)
if l <= 0 {
Diag("%s: short read on archive file symbol header", lib.File)
goto out
}
}
if !strings.HasPrefix(arhdr.name, pkgname) {
Diag("%s: cannot find package header", lib.File)
goto out
......@@ -829,7 +817,7 @@ func objfile(lib *Library) {
* the individual symbols that are unused.
*
* loading every object will also make it possible to
* load foreign objects not referenced by __.GOSYMDEF.
* load foreign objects not referenced by __.PKGDEF.
*/
for {
l = nextar(f, off, &arhdr)
......
......@@ -52,33 +52,11 @@ func FindExportData(r *bufio.Reader) (hdr string, err error) {
if string(line) == "!<arch>\n" {
// Archive file. Scan to __.PKGDEF.
var name string
var size int
if name, size, err = readGopackHeader(r); err != nil {
if name, _, err = readGopackHeader(r); err != nil {
return
}
// Optional leading __.GOSYMDEF or __.SYMDEF.
// Read and discard.
if name == "__.SYMDEF" || name == "__.GOSYMDEF" {
const block = 4096
tmp := make([]byte, block)
for size > 0 {
n := size
if n > block {
n = block
}
if _, err = io.ReadFull(r, tmp[:n]); err != nil {
return
}
size -= n
}
if name, _, err = readGopackHeader(r); err != nil {
return
}
}
// First real entry should be __.PKGDEF.
// First entry should be __.PKGDEF.
if name != "__.PKGDEF" {
err = errors.New("go archive is missing __.PKGDEF")
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment