Skip to content

Commit 0a65559

Browse files
pmurlaboger
authored andcommitted
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 <[email protected]> Run-TryBot: Lynn Boger <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Lynn Boger <[email protected]>
1 parent f009b5b commit 0a65559

File tree

1 file changed

+5
-2
lines changed
  • src/cmd/link/internal/ppc64

1 file changed

+5
-2
lines changed

src/cmd/link/internal/ppc64/asm.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,11 @@ func ensureglinkresolver(ctxt *ld.Link, ldr *loader.Loader) *loader.SymbolBuilde
10391039
glink.AddUint32(ctxt.Arch, 0x7800f082) // srdi r0,r0,2
10401040

10411041
// r11 = address of the first byte of the PLT
1042-
glink.AddSymRef(ctxt.Arch, ctxt.PLT, 0, objabi.R_ADDRPOWER, 8)
1043-
1042+
r, _ := glink.AddRel(objabi.R_ADDRPOWER)
1043+
r.SetSym(ctxt.PLT)
1044+
r.SetSiz(8)
1045+
r.SetOff(int32(glink.Size()))
1046+
r.SetAdd(0)
10441047
glink.AddUint32(ctxt.Arch, 0x3d600000) // addis r11,0,.plt@ha
10451048
glink.AddUint32(ctxt.Arch, 0x396b0000) // addi r11,r11,.plt@l
10461049

0 commit comments

Comments
 (0)