Skip to content

Commit

Permalink
cmd/{addr2line,objdump}: fix finding pclntab and symtab for pe and pl…
Browse files Browse the repository at this point in the history
…an9obj

Broken by 8b5fc7c59d05.

Update golang#8092

LGTM=iant, alex.brainman
R=rsc, iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/138770043
  • Loading branch information
mdempsky authored and ianlancetaylor committed Aug 28, 2014
1 parent 2c110a1 commit 43d4f93
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
17 changes: 13 additions & 4 deletions src/cmd/internal/objfile/pe.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,20 @@ func (f *peFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
if sect := f.pe.Section(".text"); sect != nil {
textStart = imageBase + uint64(sect.VirtualAddress)
}
if pclntab, err = loadPETable(f.pe, "pclntab", "epclntab"); err != nil {
return 0, nil, nil, err
if pclntab, err = loadPETable(f.pe, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPETable(f.pe, "pclntab", "epclntab"); err2 != nil {
return 0, nil, nil, err
}
}
if symtab, err = loadPETable(f.pe, "symtab", "esymtab"); err != nil {
return 0, nil, nil, err
if symtab, err = loadPETable(f.pe, "runtime.symtab", "runtime.esymtab"); err != nil {
// Same as above.
var err2 error
if symtab, err2 = loadPETable(f.pe, "symtab", "esymtab"); err2 != nil {
return 0, nil, nil, err
}
}
return textStart, symtab, pclntab, nil
}
Expand Down
17 changes: 13 additions & 4 deletions src/cmd/internal/objfile/plan9obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ func (f *plan9File) symbols() ([]Sym, error) {

func (f *plan9File) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
textStart = f.plan9.LoadAddress + f.plan9.HdrSize
if pclntab, err = loadPlan9Table(f.plan9, "pclntab", "epclntab"); err != nil {
return 0, nil, nil, err
if pclntab, err = loadPlan9Table(f.plan9, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPlan9Table(f.plan9, "pclntab", "epclntab"); err2 != nil {
return 0, nil, nil, err
}
}
if symtab, err = loadPlan9Table(f.plan9, "symtab", "esymtab"); err != nil {
return 0, nil, nil, err
if symtab, err = loadPlan9Table(f.plan9, "runtime.symtab", "runtime.esymtab"); err != nil {
// Same as above.
var err2 error
if symtab, err2 = loadPlan9Table(f.plan9, "symtab", "esymtab"); err2 != nil {
return 0, nil, nil, err
}
}
return textStart, symtab, pclntab, nil
}
Expand Down
34 changes: 26 additions & 8 deletions src/cmd/objdump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,20 @@ func loadTables(f *os.File) (textStart uint64, textData, symtab, pclntab []byte,
textStart = imageBase + uint64(sect.VirtualAddress)
textData, _ = sect.Data()
}
if pclntab, err = loadPETable(obj, "pclntab", "epclntab"); err != nil {
return 0, nil, nil, nil, err
if pclntab, err = loadPETable(obj, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPETable(obj, "pclntab", "epclntab"); err2 != nil {
return 0, nil, nil, nil, err
}
}
if symtab, err = loadPETable(obj, "symtab", "esymtab"); err != nil {
return 0, nil, nil, nil, err
if symtab, err = loadPETable(obj, "runtime.symtab", "runtime.esymtab"); err != nil {
// Same as above.
var err2 error
if symtab, err2 = loadPETable(obj, "symtab", "esymtab"); err2 != nil {
return 0, nil, nil, nil, err
}
}
return textStart, textData, symtab, pclntab, nil
}
Expand All @@ -369,11 +378,20 @@ func loadTables(f *os.File) (textStart uint64, textData, symtab, pclntab []byte,
if sect := obj.Section("text"); sect != nil {
textData, _ = sect.Data()
}
if pclntab, err = loadPlan9Table(obj, "pclntab", "epclntab"); err != nil {
return 0, nil, nil, nil, err
if pclntab, err = loadPlan9Table(obj, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPlan9Table(obj, "pclntab", "epclntab"); err2 != nil {
return 0, nil, nil, nil, err
}
}
if symtab, err = loadPlan9Table(obj, "symtab", "esymtab"); err != nil {
return 0, nil, nil, nil, err
if symtab, err = loadPlan9Table(obj, "runtime.symtab", "runtime.esymtab"); err != nil {
// Same as above.
var err2 error
if symtab, err2 = loadPlan9Table(obj, "symtab", "esymtab"); err2 != nil {
return 0, nil, nil, nil, err
}
}
return textStart, textData, symtab, pclntab, nil
}
Expand Down

0 comments on commit 43d4f93

Please sign in to comment.