mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: mark holes in functab with end PC-1
When we have multiple text sections, we need to mark holes between the sections in the functab. A hole is marked with an entry with the end PC of the previous section. As we now use offsets instead of (relocated) PCs, the end offset of a section may be the same of the start of the next one. Distinguish it by using the end address -1. For #48837. Change-Id: I121aac53b32a869378632cf151cb1b6f98ad3089 Reviewed-on: https://go-review.googlesource.com/c/go/+/354636 Trust: Cherry Mui <cherryyz@google.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
6436f5c13d
commit
1ceb72394e
1 changed files with 3 additions and 1 deletions
|
|
@ -631,9 +631,11 @@ func writePCToFunc(ctxt *Link, sb *loader.SymbolBuilder, funcs []loader.Sym, sta
|
||||||
if thisSect := ldr.SymSect(s); thisSect != prevSect {
|
if thisSect := ldr.SymSect(s); thisSect != prevSect {
|
||||||
// With multiple text sections, there may be a hole here in the
|
// With multiple text sections, there may be a hole here in the
|
||||||
// address space. We use an invalid funcoff value to mark the hole.
|
// address space. We use an invalid funcoff value to mark the hole.
|
||||||
|
// Use the end PC - 1 to distinguish the end of a section vs. the
|
||||||
|
// start of the next.
|
||||||
// See also runtime/symtab.go:findfunc
|
// See also runtime/symtab.go:findfunc
|
||||||
prevFuncSize := uint32(ldr.SymSize(prevFunc))
|
prevFuncSize := uint32(ldr.SymSize(prevFunc))
|
||||||
sb.SetUint32(ctxt.Arch, int64(funcIndex*2*4), pcOff(prevFunc)+prevFuncSize)
|
sb.SetUint32(ctxt.Arch, int64(funcIndex*2*4), pcOff(prevFunc)+prevFuncSize-1)
|
||||||
sb.SetUint32(ctxt.Arch, int64((funcIndex*2+1)*4), ^uint32(0))
|
sb.SetUint32(ctxt.Arch, int64((funcIndex*2+1)*4), ^uint32(0))
|
||||||
funcIndex++
|
funcIndex++
|
||||||
prevSect = thisSect
|
prevSect = thisSect
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue