aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLynn Boger <laboger@linux.vnet.ibm.com>2017-03-23 10:58:40 -0400
committerBrad Fitzpatrick <bradfitz@golang.org>2017-03-23 15:39:24 +0000
commitd43130743c4fab18f49d8f16fa5eec2346d3e060 (patch)
tree36320cc175d04461f13ce95570343556d1095e03
parent0a5cec792f745e2ee88d586f6e8551b9f702f41d (diff)
downloadgo-d43130743c4fab18f49d8f16fa5eec2346d3e060.tar.gz
go-d43130743c4fab18f49d8f16fa5eec2346d3e060.zip
[release-branch.go1.8] cmd/link: put plt stubs first in Textp on ppc64x
Previously call stubs were generated and inserted in Textp after much of the text, resulting in calls too far in some cases. This puts the call stubs first, which in many cases makes some calls not so far, but also enables trampolines to be generated when necessary. This is a backport for go 1.8 based on CL38131. Fixes #19578 Change-Id: If3ba3d5222a7f7969ed2de1df4854a1b4a80a0f0 Reviewed-on: https://go-review.googlesource.com/38472 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/cmd/link/internal/ppc64/asm.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go
index 97107b9e52..cf2c532f9e 100644
--- a/src/cmd/link/internal/ppc64/asm.go
+++ b/src/cmd/link/internal/ppc64/asm.go
@@ -87,6 +87,7 @@ func genplt(ctxt *ld.Link) {
//
// This assumes "case 1" from the ABI, where the caller needs
// us to save and restore the TOC pointer.
+ var stubs []*ld.Symbol
for _, s := range ctxt.Textp {
for i := range s.R {
r := &s.R[i]
@@ -108,7 +109,7 @@ func genplt(ctxt *ld.Link) {
if stub.Size == 0 {
// Need outer to resolve .TOC.
stub.Outer = s
- ctxt.Textp = append(ctxt.Textp, stub)
+ stubs = append(stubs, stub)
gencallstub(ctxt, 1, stub, r.Sym)
}
@@ -121,6 +122,11 @@ func genplt(ctxt *ld.Link) {
ctxt.Arch.ByteOrder.PutUint32(s.P[r.Off+4:], o1)
}
}
+ // Put call stubs at the beginning (instead of the end).
+ // So when resolving the relocations to calls to the stubs,
+ // the addresses are known and trampolines can be inserted
+ // when necessary.
+ ctxt.Textp = append(stubs, ctxt.Textp...)
}
func genaddmoduledata(ctxt *ld.Link) {