Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3538)

Side by Side Diff: src/cmd/objdump/plan9obj.go

Issue 91360046: code review 91360046: objdump: implement disassembly (Closed)
Patch Set: diff -r ab46827fd5f7 https://code.google.com/p/go/ Created 9 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/objdump/pe.go ('k') | src/cmd/objdump/testdata/fmthello.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Parsing of Plan 9 a.out executables. 5 // Parsing of Plan 9 a.out executables.
6 6
7 package main 7 package main
8 8
9 import ( 9 import (
10 "debug/plan9obj" 10 "debug/plan9obj"
11 "os" 11 "os"
12 "sort" 12 "sort"
13 ) 13 )
14 14
15 func plan9Symbols(f *os.File) []Sym { 15 func plan9Symbols(f *os.File) (syms []Sym, goarch string) {
16 p, err := plan9obj.NewFile(f) 16 p, err := plan9obj.NewFile(f)
17 if err != nil { 17 if err != nil {
18 errorf("parsing %s: %v", f.Name(), err) 18 errorf("parsing %s: %v", f.Name(), err)
19 » » return nil 19 » » return
20 } 20 }
21 21
22 plan9Syms, err := p.Symbols() 22 plan9Syms, err := p.Symbols()
23 if err != nil { 23 if err != nil {
24 errorf("parsing %s: %v", f.Name(), err) 24 errorf("parsing %s: %v", f.Name(), err)
25 » » return nil 25 » » return
26 } 26 }
27 27
28 goarch = "386"
29
28 // Build sorted list of addresses of all symbols. 30 // Build sorted list of addresses of all symbols.
29 // We infer the size of a symbol by looking at where the next symbol beg ins. 31 // We infer the size of a symbol by looking at where the next symbol beg ins.
30 var addrs []uint64 32 var addrs []uint64
31 for _, s := range plan9Syms { 33 for _, s := range plan9Syms {
32 addrs = append(addrs, s.Value) 34 addrs = append(addrs, s.Value)
33 } 35 }
34 sort.Sort(uint64s(addrs)) 36 sort.Sort(uint64s(addrs))
35 37
36 var syms []Sym
37
38 for _, s := range plan9Syms { 38 for _, s := range plan9Syms {
39 sym := Sym{Addr: s.Value, Name: s.Name, Code: rune(s.Type)} 39 sym := Sym{Addr: s.Value, Name: s.Name, Code: rune(s.Type)}
40 i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value }) 40 i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value })
41 if i < len(addrs) { 41 if i < len(addrs) {
42 sym.Size = int64(addrs[i] - s.Value) 42 sym.Size = int64(addrs[i] - s.Value)
43 } 43 }
44 syms = append(syms, sym) 44 syms = append(syms, sym)
45 } 45 }
46 46
47 » return syms 47 » return
48 } 48 }
OLDNEW
« no previous file with comments | « src/cmd/objdump/pe.go ('k') | src/cmd/objdump/testdata/fmthello.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b