]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/objdump: fix dissasembly of Plan 9 object files
authorAnthony Martin <ality@pbrane.org>
Wed, 21 May 2014 21:24:38 +0000 (23:24 +0200)
committerDavid du Colombier <0intro@gmail.com>
Wed, 21 May 2014 21:24:38 +0000 (23:24 +0200)
Ignore symbols that aren't text, data, or bss since they cause
problems when dissassembling instructions with small immediate
values.

Before:
        build.go:142    0x10ee  83ec50      SUBL $text/template/parse.autotmp_1293(SB), SP

After:
        build.go:142    0x10ee  83ec50      SUBL $0x50, SP

Fixes #7947.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/93520045

src/cmd/objdump/objdump_test.go
src/cmd/objdump/plan9obj.go

index 354e5d407acfcd1212e1897f836c06332e948c38..2c61c484cb1d7413d8e491911281a1b26ba40173 100644 (file)
@@ -155,10 +155,6 @@ var armNeed = []string{
 // can handle that one.
 
 func TestDisasm(t *testing.T) {
-       if runtime.GOOS == "plan9" {
-               t.Skip("skipping test; see http://golang.org/issue/7947")
-       }
-
        tmp, exe := buildObjdump(t)
        defer os.RemoveAll(tmp)
 
index 5434f8e4403fe53759444d72d7d732a797c8e917..34462f31c5f28a6acf4476acc04da36f27b0f7f6 100644 (file)
@@ -12,6 +12,15 @@ import (
        "sort"
 )
 
+var validSymType = map[rune]bool{
+       'T': true,
+       't': true,
+       'D': true,
+       'd': true,
+       'B': true,
+       'b': true,
+}
+
 func plan9Symbols(f *os.File) (syms []Sym, goarch string) {
        p, err := plan9obj.NewFile(f)
        if err != nil {
@@ -31,11 +40,17 @@ func plan9Symbols(f *os.File) (syms []Sym, goarch string) {
        // 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))
 
        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) {