mirror of
https://github.com/golang/go
synced 2024-11-26 22:11:25 -07:00
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
This commit is contained in:
parent
dc11be8dda
commit
13c69f0379
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user