mirror of
https://github.com/golang/go
synced 2024-11-05 15:56:12 -07:00
cmd/internal/objfile: Skip mach-o debug symbols.
This allows objdump to disassemble gcc generated binaries on OS X 10.6. Change-Id: I1a5bfbf7c252e78215ef1f122520689d5ce6ddca Reviewed-on: https://go-review.googlesource.com/10383 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
fad25c29a1
commit
bc89ad598e
@ -13,6 +13,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const stabTypeMask = 0xe0
|
||||||
|
|
||||||
type machoFile struct {
|
type machoFile struct {
|
||||||
macho *macho.File
|
macho *macho.File
|
||||||
}
|
}
|
||||||
@ -34,12 +36,19 @@ func (f *machoFile) symbols() ([]Sym, error) {
|
|||||||
// We infer the size of a symbol by looking at where the next symbol begins.
|
// We infer the size of a symbol by looking at where the next symbol begins.
|
||||||
var addrs []uint64
|
var addrs []uint64
|
||||||
for _, s := range f.macho.Symtab.Syms {
|
for _, s := range f.macho.Symtab.Syms {
|
||||||
|
// Skip stab debug info.
|
||||||
|
if s.Type&stabTypeMask == 0 {
|
||||||
addrs = append(addrs, s.Value)
|
addrs = append(addrs, s.Value)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sort.Sort(uint64s(addrs))
|
sort.Sort(uint64s(addrs))
|
||||||
|
|
||||||
var syms []Sym
|
var syms []Sym
|
||||||
for _, s := range f.macho.Symtab.Syms {
|
for _, s := range f.macho.Symtab.Syms {
|
||||||
|
if s.Type&stabTypeMask != 0 {
|
||||||
|
// Skip stab debug info.
|
||||||
|
continue
|
||||||
|
}
|
||||||
sym := Sym{Name: s.Name, Addr: s.Value, Code: '?'}
|
sym := Sym{Name: s.Name, Addr: s.Value, Code: '?'}
|
||||||
i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value })
|
i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value })
|
||||||
if i < len(addrs) {
|
if i < len(addrs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user