From 13c69f037986ba4a4cb1890822bfd15702a2971e Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Thu, 28 Aug 2014 16:01:31 -0700 Subject: [PATCH] cmd/internal/objfile: fix dissassembly of Plan 9 object files This is a reapplication of CL 93520045 (changeset 5012df7fac58) since that was lost during the move to an internal package. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/134020043 --- src/cmd/internal/objfile/plan9obj.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go index d2c3d3f3fe..80744f82a8 100644 --- a/src/cmd/internal/objfile/plan9obj.go +++ b/src/cmd/internal/objfile/plan9obj.go @@ -13,6 +13,15 @@ import ( "sort" ) +var validSymType = map[rune]bool{ + 'T': true, + 't': true, + 'D': true, + 'd': true, + 'B': true, + 'b': true, +} + type plan9File struct { plan9 *plan9obj.File } @@ -35,6 +44,9 @@ func (f *plan9File) symbols() ([]Sym, error) { // We infer the size of a symbol by looking at where the next symbol begins. var addrs []uint64 for _, s := range plan9Syms { + if !validSymType[s.Type] { + continue + } addrs = append(addrs, s.Value) } sort.Sort(uint64s(addrs)) @@ -42,6 +54,9 @@ func (f *plan9File) symbols() ([]Sym, error) { var syms []Sym for _, s := range plan9Syms { + if !validSymType[s.Type] { + continue + } sym := Sym{Addr: s.Value, Name: s.Name, Code: rune(s.Type)} i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value }) if i < len(addrs) { -- 2.48.1