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>
}
// 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)
}
// 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")
}