Skip to content

Commit 15b3765

Browse files
committed
cmd/link: on PPC64, put plt stubs at beginning of Textp
Put call stubs at the beginning (instead of the end). So the trampoline pass knows the addresses of the stubs, and it can insert trampolines when necessary. Fixes #19425. Change-Id: I1e06529ef837a6130df58917315610d45a6819ca Reviewed-on: https://go-review.googlesource.com/38131 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Lynn Boger <[email protected]>
1 parent 43afcb5 commit 15b3765

File tree

1 file changed

+7
-1
lines changed
  • src/cmd/link/internal/ppc64

1 file changed

+7
-1
lines changed

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func genplt(ctxt *ld.Link) {
8787
//
8888
// This assumes "case 1" from the ABI, where the caller needs
8989
// us to save and restore the TOC pointer.
90+
var stubs []*ld.Symbol
9091
for _, s := range ctxt.Textp {
9192
for i := range s.R {
9293
r := &s.R[i]
@@ -108,7 +109,7 @@ func genplt(ctxt *ld.Link) {
108109
if stub.Size == 0 {
109110
// Need outer to resolve .TOC.
110111
stub.Outer = s
111-
ctxt.Textp = append(ctxt.Textp, stub)
112+
stubs = append(stubs, stub)
112113
gencallstub(ctxt, 1, stub, r.Sym)
113114
}
114115

@@ -121,6 +122,11 @@ func genplt(ctxt *ld.Link) {
121122
ctxt.Arch.ByteOrder.PutUint32(s.P[r.Off+4:], o1)
122123
}
123124
}
125+
// Put call stubs at the beginning (instead of the end).
126+
// So when resolving the relocations to calls to the stubs,
127+
// the addresses are known and trampolines can be inserted
128+
// when necessary.
129+
ctxt.Textp = append(stubs, ctxt.Textp...)
124130
}
125131

126132
func genaddmoduledata(ctxt *ld.Link) {

0 commit comments

Comments
 (0)