mirror of
https://github.com/golang/go
synced 2024-11-23 09:20:05 -07:00
debug/macho: fill Rpath.LoadBytes in NewFile
Also, fix some error messages. Fixes #22065 Change-Id: Iac05c24b7bb128be3f43b8f2aa180b3957d5ee72 Reviewed-on: https://go-review.googlesource.com/66390 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
4896fc2fa4
commit
0d0c1132f6
@ -290,6 +290,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
|
||||
return nil, &FormatError{offset, "invalid path in rpath command", hdr.Path}
|
||||
}
|
||||
l.Path = cstring(cmddat[hdr.Path:])
|
||||
l.LoadBytes = LoadBytes(cmddat)
|
||||
f.Loads[i] = l
|
||||
|
||||
case LoadCmdDylib:
|
||||
|
@ -234,6 +234,11 @@ func TestOpen(t *testing.T) {
|
||||
t.Errorf("open %s:\n\thave %#v\n\twant %#v\n", tt.file, f.FileHeader, tt.hdr)
|
||||
continue
|
||||
}
|
||||
for i, l := range f.Loads {
|
||||
if len(l.Raw()) < 8 {
|
||||
t.Errorf("open %s, command %d:\n\tload command %T don't have enough data\n", tt.file, i, l)
|
||||
}
|
||||
}
|
||||
if tt.loads != nil {
|
||||
for i, l := range f.Loads {
|
||||
if i >= len(tt.loads) {
|
||||
@ -249,22 +254,22 @@ func TestOpen(t *testing.T) {
|
||||
case *Segment:
|
||||
have := &l.SegmentHeader
|
||||
if !reflect.DeepEqual(have, want) {
|
||||
t.Errorf("open %s, segment %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
t.Errorf("open %s, command %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
}
|
||||
case *Dylib:
|
||||
have := l
|
||||
have.LoadBytes = nil
|
||||
if !reflect.DeepEqual(have, want) {
|
||||
t.Errorf("open %s, segment %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
t.Errorf("open %s, command %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
}
|
||||
case *Rpath:
|
||||
have := l
|
||||
have.LoadBytes = nil
|
||||
if !reflect.DeepEqual(have, want) {
|
||||
t.Errorf("open %s, segment %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
t.Errorf("open %s, command %d:\n\thave %#v\n\twant %#v\n", tt.file, i, have, want)
|
||||
}
|
||||
default:
|
||||
t.Errorf("open %s, section %d: unknown load command\n\thave %#v\n\twant %#v\n", tt.file, i, l, want)
|
||||
t.Errorf("open %s, command %d: unknown load command\n\thave %#v\n\twant %#v\n", tt.file, i, l, want)
|
||||
}
|
||||
}
|
||||
tn := len(tt.loads)
|
||||
|
Loading…
Reference in New Issue
Block a user