summaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile/plan9obj.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-29 18:07:24 -0400
committerRuss Cox <rsc@golang.org>2014-10-29 18:07:24 -0400
commit3eadbb02afa1494821de000ee280e00c3c398f1d (patch)
tree60ec9919c7f424685a26b5220e4844797be6c343 /src/cmd/internal/objfile/plan9obj.go
parent97b24a05dff7adef3a0fb463a575b705be985468 (diff)
downloadgo-git-3eadbb02afa1494821de000ee280e00c3c398f1d.tar.gz
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
Diffstat (limited to 'src/cmd/internal/objfile/plan9obj.go')
-rw-r--r--src/cmd/internal/objfile/plan9obj.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go
index 80744f82a8..eb6cba5eb1 100644
--- a/src/cmd/internal/objfile/plan9obj.go
+++ b/src/cmd/internal/objfile/plan9obj.go
@@ -88,6 +88,16 @@ func (f *plan9File) pcln() (textStart uint64, symtab, pclntab []byte, err error)
return textStart, symtab, pclntab, nil
}
+func (f *plan9File) text() (textStart uint64, text []byte, err error) {
+ sect := f.plan9.Section("text")
+ if sect == nil {
+ return 0, nil, fmt.Errorf("text section not found")
+ }
+ textStart = f.plan9.LoadAddress + f.plan9.HdrSize
+ text, err = sect.Data()
+ return
+}
+
func findPlan9Symbol(f *plan9obj.File, name string) (*plan9obj.Sym, error) {
syms, err := f.Symbols()
if err != nil {
@@ -122,3 +132,15 @@ func loadPlan9Table(f *plan9obj.File, sname, ename string) ([]byte, error) {
textStart := f.LoadAddress + f.HdrSize
return data[ssym.Value-textStart : esym.Value-textStart], nil
}
+
+func (f *plan9File) goarch() string {
+ switch f.plan9.Magic {
+ case plan9obj.Magic386:
+ return "386"
+ case plan9obj.MagicAMD64:
+ return "amd64"
+ case plan9obj.MagicARM:
+ return "arm"
+ }
+ return ""
+}