mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/nm: handle cgo archive
This CL also make cmd/nm accept PE object file. Fixes #21706 Change-Id: I4a528b7d53da1082e61523ebeba02c4c514a43a7 Reviewed-on: https://go-review.googlesource.com/64890 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
6a537c1d47
commit
589ea93678
11 changed files with 212 additions and 86 deletions
|
|
@ -22,12 +22,33 @@ type goobjFile struct {
|
|||
f *os.File // the underlying .o or .a file
|
||||
}
|
||||
|
||||
func openGoobj(r *os.File) (rawFile, error) {
|
||||
func openGoFile(r *os.File) (*File, error) {
|
||||
f, err := goobj.Parse(r, `""`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &goobjFile{goobj: f, f: r}, nil
|
||||
rf := &goobjFile{goobj: f, f: r}
|
||||
if len(f.Native) == 0 {
|
||||
return &File{r, []*Entry{&Entry{raw: rf}}}, nil
|
||||
}
|
||||
entries := make([]*Entry, len(f.Native)+1)
|
||||
entries[0] = &Entry{
|
||||
raw: rf,
|
||||
}
|
||||
L:
|
||||
for i, nr := range f.Native {
|
||||
for _, try := range openers {
|
||||
if raw, err := try(nr); err == nil {
|
||||
entries[i+1] = &Entry{
|
||||
name: nr.Name,
|
||||
raw: raw,
|
||||
}
|
||||
continue L
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("open %s: unrecognized archive member %s", r.Name(), nr.Name)
|
||||
}
|
||||
return &File{r, entries}, nil
|
||||
}
|
||||
|
||||
func goobjName(id goobj.SymID) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue