mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 250a091 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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5c613e9162
commit
67dbde0d71
4 changed files with 9 additions and 56 deletions
|
|
@ -549,22 +549,9 @@ func skiptopkgdef(b *obj.Biobuf) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// symbol table may be first; skip it
|
// package export block should be first
|
||||||
sz := arsize(b, "__.GOSYMDEF")
|
sz := arsize(b, "__.PKGDEF")
|
||||||
|
return sz > 0
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var idirs []string
|
var idirs []string
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ func (r *objReader) parseArchive() error {
|
||||||
return errCorruptArchive
|
return errCorruptArchive
|
||||||
}
|
}
|
||||||
switch name {
|
switch name {
|
||||||
case "__.SYMDEF", "__.GOSYMDEF", "__.PKGDEF":
|
case "__.PKGDEF":
|
||||||
r.skip(size)
|
r.skip(size)
|
||||||
default:
|
default:
|
||||||
oldLimit := r.limit
|
oldLimit := r.limit
|
||||||
|
|
|
||||||
|
|
@ -255,10 +255,7 @@ var coutbuf struct {
|
||||||
f *os.File
|
f *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const pkgname = "__.PKGDEF"
|
||||||
symname = "__.GOSYMDEF"
|
|
||||||
pkgname = "__.PKGDEF"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Set if we see an object compiled by the host compiler that is not
|
// Set if we see an object compiled by the host compiler that is not
|
||||||
|
|
@ -781,7 +778,7 @@ func objfile(lib *Library) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip over optional __.GOSYMDEF and process __.PKGDEF */
|
/* process __.PKGDEF */
|
||||||
off := obj.Boffset(f)
|
off := obj.Boffset(f)
|
||||||
|
|
||||||
var arhdr ArHdr
|
var arhdr ArHdr
|
||||||
|
|
@ -792,15 +789,6 @@ func objfile(lib *Library) {
|
||||||
goto out
|
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) {
|
if !strings.HasPrefix(arhdr.name, pkgname) {
|
||||||
Diag("%s: cannot find package header", lib.File)
|
Diag("%s: cannot find package header", lib.File)
|
||||||
goto out
|
goto out
|
||||||
|
|
@ -829,7 +817,7 @@ func objfile(lib *Library) {
|
||||||
* the individual symbols that are unused.
|
* the individual symbols that are unused.
|
||||||
*
|
*
|
||||||
* loading every object will also make it possible to
|
* loading every object will also make it possible to
|
||||||
* load foreign objects not referenced by __.GOSYMDEF.
|
* load foreign objects not referenced by __.PKGDEF.
|
||||||
*/
|
*/
|
||||||
for {
|
for {
|
||||||
l = nextar(f, off, &arhdr)
|
l = nextar(f, off, &arhdr)
|
||||||
|
|
|
||||||
|
|
@ -52,33 +52,11 @@ func FindExportData(r *bufio.Reader) (hdr string, err error) {
|
||||||
if string(line) == "!<arch>\n" {
|
if string(line) == "!<arch>\n" {
|
||||||
// Archive file. Scan to __.PKGDEF.
|
// Archive file. Scan to __.PKGDEF.
|
||||||
var name string
|
var name string
|
||||||
var size int
|
if name, _, err = readGopackHeader(r); err != nil {
|
||||||
if name, size, err = readGopackHeader(r); err != nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optional leading __.GOSYMDEF or __.SYMDEF.
|
// First entry should be __.PKGDEF.
|
||||||
// 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.
|
|
||||||
if name != "__.PKGDEF" {
|
if name != "__.PKGDEF" {
|
||||||
err = errors.New("go archive is missing __.PKGDEF")
|
err = errors.New("go archive is missing __.PKGDEF")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue