1
0
mirror of https://github.com/golang/go synced 2024-11-26 19:41:19 -07:00

cmd/link: fix glink resolver generation on ppc64le

AddSymRef grows the section to fit the relocation. This was not
being accounted for. Instead, add a relocation and explicitly
populate it so we patch the desired instructions.

Change-Id: I583147e2545aea34c854f9d35ca920c57be60b90
Reviewed-on: https://go-review.googlesource.com/c/go/+/300949
Run-TryBot: Paul Murphy <murp@ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
This commit is contained in:
Paul E. Murphy 2021-03-10 14:32:27 -06:00 committed by Lynn Boger
parent f009b5b226
commit 0a655598e1

View File

@ -1039,8 +1039,11 @@ func ensureglinkresolver(ctxt *ld.Link, ldr *loader.Loader) *loader.SymbolBuilde
glink.AddUint32(ctxt.Arch, 0x7800f082) // srdi r0,r0,2 glink.AddUint32(ctxt.Arch, 0x7800f082) // srdi r0,r0,2
// r11 = address of the first byte of the PLT // r11 = address of the first byte of the PLT
glink.AddSymRef(ctxt.Arch, ctxt.PLT, 0, objabi.R_ADDRPOWER, 8) r, _ := glink.AddRel(objabi.R_ADDRPOWER)
r.SetSym(ctxt.PLT)
r.SetSiz(8)
r.SetOff(int32(glink.Size()))
r.SetAdd(0)
glink.AddUint32(ctxt.Arch, 0x3d600000) // addis r11,0,.plt@ha glink.AddUint32(ctxt.Arch, 0x3d600000) // addis r11,0,.plt@ha
glink.AddUint32(ctxt.Arch, 0x396b0000) // addi r11,r11,.plt@l glink.AddUint32(ctxt.Arch, 0x396b0000) // addi r11,r11,.plt@l