]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: move ppc64 genplt declarations into loop
authorDavid Crawshaw <crawshaw@golang.org>
Wed, 20 Apr 2016 18:40:18 +0000 (14:40 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Wed, 20 Apr 2016 19:10:59 +0000 (19:10 +0000)
(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: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/link/internal/ppc64/asm.go

index 562e0810e07fa1960d75c2c04f2cf9a3cf892e59..17ee25608b1244cbedb93ebba930e5575fae1e8a 100644 (file)
@@ -39,14 +39,6 @@ import (
 )
 
 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
        // architectures, but is laid out quite differently. When we
        // see an R_PPC64_REL24 relocation to a dynamic symbol
@@ -95,11 +87,11 @@ func genplt() {
        //
        // This assumes "case 1" from the ABI, where the caller needs
        // 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 i = range s.R {
-                       r = &s.R[i]
+       for s := *pprevtextp; s != nil; pprevtextp, s = &s.Next, s.Next {
+               for i := range s.R {
+                       r := &s.R[i]
                        if r.Type != 256+ld.R_PPC64_REL24 || r.Sym.Type != obj.SDYNIMPORT {
                                continue
                        }
@@ -109,9 +101,9 @@ func genplt() {
                        addpltsym(ld.Ctxt, r.Sym)
 
                        // 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() {
                                stub.Attr |= ld.AttrReachable
                        }
@@ -135,7 +127,7 @@ func genplt() {
 
                        // Restore TOC after bl. The compiler put a
                        // 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)
                }
        }