mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/objdump: use cmd/internal/objfile
This removes a bunch of ugly duplicate code. The end goal is to factor the disassembly code into cmd/internal/objfile too, so that pprof can use it, but one step at a time. LGTM=r, iant R=r, alex.brainman, iant CC=golang-codereviews https://golang.org/cl/149400043
This commit is contained in:
parent
97b24a05df
commit
3eadbb02af
12 changed files with 154 additions and 568 deletions
|
|
@ -85,6 +85,30 @@ func (f *machoFile) pcln() (textStart uint64, symtab, pclntab []byte, err error)
|
|||
return textStart, symtab, pclntab, nil
|
||||
}
|
||||
|
||||
func (f *machoFile) text() (textStart uint64, text []byte, err error) {
|
||||
sect := f.macho.Section("__text")
|
||||
if sect == nil {
|
||||
return 0, nil, fmt.Errorf("text section not found")
|
||||
}
|
||||
textStart = sect.Addr
|
||||
text, err = sect.Data()
|
||||
return
|
||||
}
|
||||
|
||||
func (f *machoFile) goarch() string {
|
||||
switch f.macho.Cpu {
|
||||
case macho.Cpu386:
|
||||
return "386"
|
||||
case macho.CpuAmd64:
|
||||
return "amd64"
|
||||
case macho.CpuArm:
|
||||
return "arm"
|
||||
case macho.CpuPpc64:
|
||||
return "power64"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type uint64s []uint64
|
||||
|
||||
func (x uint64s) Len() int { return len(x) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue