mirror of https://github.com/golang/go.git
[dev.link] cmd/objdump: switch to using NewReaderFromBytes
Convert the object file dumper to use NewReaderFromBytes when reading new object files, as opposed to NewReader. Change-Id: I9f5e0356bd21c16f545cdd70262e983a2ed38bfc Reviewed-on: https://go-review.googlesource.com/c/go/+/201441 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
6cbf37b30b
commit
e5acb58c39
|
|
@ -502,12 +502,15 @@ func (r *objReader) parseObject(prefix []byte) error {
|
|||
}
|
||||
// TODO: extract OS + build ID if/when we need it
|
||||
|
||||
r.readFull(r.tmp[:8])
|
||||
if bytes.Equal(r.tmp[:8], []byte("\x00go114LD")) {
|
||||
r.offset -= 8
|
||||
p, err := r.peek(8)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if bytes.Equal(p, []byte("\x00go114LD")) {
|
||||
r.readNew()
|
||||
return nil
|
||||
}
|
||||
r.readFull(r.tmp[:8])
|
||||
if !bytes.Equal(r.tmp[:8], []byte("\x00go114ld")) {
|
||||
return r.error(errCorruptObject)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ import (
|
|||
// the data to the current goobj API.
|
||||
func (r *objReader) readNew() {
|
||||
start := uint32(r.offset)
|
||||
rr := goobj2.NewReader(r.f, start)
|
||||
|
||||
length := r.limit - r.offset
|
||||
objbytes := make([]byte, length)
|
||||
r.readFull(objbytes)
|
||||
rr := goobj2.NewReaderFromBytes(objbytes, false)
|
||||
if rr == nil {
|
||||
panic("cannot read object file")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue