)
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
//
// 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
}
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
}
// 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)
}
}