mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/objfile, debug/gosym: use the address of runtime.text as textStart
Tools like objdump uses the pcln table to find the line number of a given PC. For a PIE binary, at least in some cases such as on macOS 12 with ld64-711, the table contains unrelocated address, which does not match the address in the symbol table, causing the lookup to fail. In Go 1.18 the pcln table is essentually position independent, except the start PC. Instead of reading the static content from the table, use the PC of runtime.text from the symbol table. While here, change the type of textStart to uint64. What matters here is the word size of the target program, not the host, so it shouldn't be uintptr. Fixes #49700. Change-Id: I517d79be7ba02dd4dd0275e75a11a136b08d76cd Reviewed-on: https://go-review.googlesource.com/c/go/+/366695 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
14f2b2a4c5
commit
b38ab0ac5f
2 changed files with 13 additions and 4 deletions
|
|
@ -152,6 +152,15 @@ func (e *Entry) PCLineTable() (Liner, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
syms, err := e.raw.symbols()
|
||||
if err == nil {
|
||||
for _, s := range syms {
|
||||
if s.Name == "runtime.text" {
|
||||
textStart = s.Addr
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return gosym.NewTable(symtab, gosym.NewLineTable(pclntab, textStart))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue