Commit 79c527f4 authored by David Crawshaw's avatar David Crawshaw

cmd/link: move ppc64 genplt declarations into loop

(Split out from CL 22243.)

Change-Id: I07709a0c417e7a57e839e5085a37db7d5fbf3a35
Reviewed-on: https://go-review.googlesource.com/22322
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 854ab14b
...@@ -39,14 +39,6 @@ import ( ...@@ -39,14 +39,6 @@ import (
) )
func genplt() { func genplt() {
var s *ld.LSym
var stub *ld.LSym
var pprevtextp **ld.LSym
var r *ld.Reloc
var n string
var o1 uint32
var i int
// The ppc64 ABI PLT has similar concepts to other // The ppc64 ABI PLT has similar concepts to other
// architectures, but is laid out quite differently. When we // architectures, but is laid out quite differently. When we
// see an R_PPC64_REL24 relocation to a dynamic symbol // see an R_PPC64_REL24 relocation to a dynamic symbol
...@@ -95,11 +87,11 @@ func genplt() { ...@@ -95,11 +87,11 @@ func genplt() {
// //
// This assumes "case 1" from the ABI, where the caller needs // This assumes "case 1" from the ABI, where the caller needs
// us to save and restore the TOC pointer. // us to save and restore the TOC pointer.
pprevtextp = &ld.Ctxt.Textp pprevtextp := &ld.Ctxt.Textp
for s = *pprevtextp; s != nil; pprevtextp, s = &s.Next, s.Next { for s := *pprevtextp; s != nil; pprevtextp, s = &s.Next, s.Next {
for i = range s.R { for i := range s.R {
r = &s.R[i] r := &s.R[i]
if r.Type != 256+ld.R_PPC64_REL24 || r.Sym.Type != obj.SDYNIMPORT { if r.Type != 256+ld.R_PPC64_REL24 || r.Sym.Type != obj.SDYNIMPORT {
continue continue
} }
...@@ -109,9 +101,9 @@ func genplt() { ...@@ -109,9 +101,9 @@ func genplt() {
addpltsym(ld.Ctxt, r.Sym) addpltsym(ld.Ctxt, r.Sym)
// Generate call stub // Generate call stub
n = fmt.Sprintf("%s.%s", s.Name, r.Sym.Name) n := fmt.Sprintf("%s.%s", s.Name, r.Sym.Name)
stub = ld.Linklookup(ld.Ctxt, n, 0) stub := ld.Linklookup(ld.Ctxt, n, 0)
if s.Attr.Reachable() { if s.Attr.Reachable() {
stub.Attr |= ld.AttrReachable stub.Attr |= ld.AttrReachable
} }
...@@ -135,7 +127,7 @@ func genplt() { ...@@ -135,7 +127,7 @@ func genplt() {
// Restore TOC after bl. The compiler put a // Restore TOC after bl. The compiler put a
// nop here for us to overwrite. // nop here for us to overwrite.
o1 = 0xe8410018 // ld r2,24(r1) const o1 = 0xe8410018 // ld r2,24(r1)
ld.Ctxt.Arch.ByteOrder.PutUint32(s.P[r.Off+4:], o1) ld.Ctxt.Arch.ByteOrder.PutUint32(s.P[r.Off+4:], o1)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment