Skip to content

Commit

Permalink
cmd/internal/objfile: Skip mach-o debug symbols.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
Ryan Brown authored and ianlancetaylor committed May 26, 2015
1 parent fad25c2 commit bc89ad5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cmd/internal/objfile/macho.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"sort"
)

const stabTypeMask = 0xe0

type machoFile struct {
macho *macho.File
}
Expand All @@ -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.
var addrs []uint64
for _, s := range f.macho.Symtab.Syms {
addrs = append(addrs, s.Value)
// Skip stab debug info.
if s.Type&stabTypeMask == 0 {
addrs = append(addrs, s.Value)
}
}
sort.Sort(uint64s(addrs))

var syms []Sym
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: '?'}
i := sort.Search(len(addrs), func(x int) bool { return addrs[x] > s.Value })
if i < len(addrs) {
Expand Down

0 comments on commit bc89ad5

Please sign in to comment.