Commit a91c1f5c authored by David du Colombier's avatar David du Colombier Committed by Aram Hăvărneanu

cmd/addr2line, cmd/objdump: fix on amd64 Plan 9

Fix virtual address of the start of the text segment
on amd64 Plan 9.

This issue has been partially fixed in cmd/add2line,
as part of CL 106460044, but we forgot to report the
change to cmd/objdump.

In the meantime, we also fixed the textStart address
in both cmd/add2line and cmd/objdump.

LGTM=aram, ality, mischief
R=rsc, mischief, aram, ality
CC=golang-codereviews, jas
https://golang.org/cl/117920043
parent e315fac7
......@@ -161,11 +161,7 @@ func loadTables(f *os.File) (textStart uint64, symtab, pclntab []byte, err error
}
if obj, err := plan9obj.NewFile(f); err == nil {
sym, err := findPlan9Symbol(obj, "text")
if err != nil {
return 0, nil, nil, err
}
textStart = sym.Value
textStart = obj.LoadAddress + obj.HdrSize
if pclntab, err = loadPlan9Table(obj, "pclntab", "epclntab"); err != nil {
return 0, nil, nil, err
}
......@@ -245,5 +241,6 @@ func loadPlan9Table(f *plan9obj.File, sname, ename string) ([]byte, error) {
if err != nil {
return nil, err
}
return data[ssym.Value-(f.LoadAddress+f.HdrSize) : esym.Value-(f.LoadAddress+f.HdrSize)], nil
textStart := f.LoadAddress + f.HdrSize
return data[ssym.Value-textStart : esym.Value-textStart], nil
}
......@@ -365,11 +365,7 @@ func loadTables(f *os.File) (textStart uint64, textData, symtab, pclntab []byte,
}
if obj, err := plan9obj.NewFile(f); err == nil {
sym, err := findPlan9Symbol(obj, "text")
if err != nil {
return 0, nil, nil, nil, err
}
textStart = sym.Value
textStart = obj.LoadAddress + obj.HdrSize
if sect := obj.Section("text"); sect != nil {
textData, _ = sect.Data()
}
......@@ -444,10 +440,6 @@ func loadPlan9Table(f *plan9obj.File, sname, ename string) ([]byte, error) {
if err != nil {
return nil, err
}
text, err := findPlan9Symbol(f, "text")
if err != nil {
return nil, err
}
sect := f.Section("text")
if sect == nil {
return nil, err
......@@ -456,7 +448,8 @@ func loadPlan9Table(f *plan9obj.File, sname, ename string) ([]byte, error) {
if err != nil {
return nil, err
}
return data[ssym.Value-text.Value : esym.Value-text.Value], nil
textStart := f.LoadAddress + f.HdrSize
return data[ssym.Value-textStart : esym.Value-textStart], nil
}
// TODO(rsc): This code is taken from cmd/nm. Arrange some way to share the code.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment