diff --git a/chore/nmdump/nmdump.go b/chore/nmdump/nmdump.go index da9e4ba9..5998905a 100644 --- a/chore/nmdump/nmdump.go +++ b/chore/nmdump/nmdump.go @@ -33,7 +33,9 @@ func main() { items, err := nm.List(os.Args[1]) check(err) for _, item := range items { - fmt.Printf("\n%s:\n", item.File) + if item.File != "" { + fmt.Printf("\n%s:\n", item.File) + } for _, sym := range item.Symbols { if sym.FAddr { fmt.Printf("%016x %c %s\n", sym.Addr, sym.Type, sym.Name) diff --git a/x/nm/nm.go b/x/nm/nm.go index d9a2c161..99c7d65d 100644 --- a/x/nm/nm.go +++ b/x/nm/nm.go @@ -87,10 +87,14 @@ func (p *Cmd) List(arfile string) (items []*ObjectFile, err error) { } func listOutput(data []byte) (items []*ObjectFile, err error) { - var item *ObjectFile - var sep = []byte{'\n'} - for _, line := range bytes.Split(data, sep) { + sep := []byte{'\n'} + item := &ObjectFile{} + lines := bytes.Split(data, sep) + for _, line := range lines { if len(line) == 0 { + if item.File == "" && len(item.Symbols) > 0 { + items = append(items, item) + } item = nil continue }