]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/objfile: fix dissassembly of Plan 9 object files
authorAnthony Martin <ality@pbrane.org>
Thu, 28 Aug 2014 23:01:31 +0000 (16:01 -0700)
committerAnthony Martin <ality@pbrane.org>
Thu, 28 Aug 2014 23:01:31 +0000 (16:01 -0700)
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

index d2c3d3f3fe8f7de1a53c05e1091602b9575ccff4..80744f82a8c8246d20a6647fec3963d21247da5e 100644 (file)
@@ -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) {