]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: improve aix/ppc64 new symbol addressing
authorClément Chigot <clement.chigot@atos.net>
Wed, 28 Nov 2018 12:38:02 +0000 (13:38 +0100)
committerIan Lance Taylor <iant@golang.org>
Mon, 17 Dec 2018 21:13:09 +0000 (21:13 +0000)
This commit updates the new symbol addressing made for aix/ppc64 according
to feedbacks given in CL 151039.

Change-Id: Ic4eb9943dc520d65f7d084adf8fa9a2530f4d3f9
Reviewed-on: https://go-review.googlesource.com/c/151302
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/obj/ppc64/obj9.go
src/cmd/link/internal/ppc64/asm.go

index d7f1a08622af2f3ca7ae569386cf639ef4f9968c..a2ea492710b59314aa96d0af2ba4bccec5184915 100644 (file)
@@ -2212,7 +2212,7 @@ func (c *ctxt9) opform(insn uint32) int {
 // instruction op with source or destination (as appropriate) register reg.
 func (c *ctxt9) symbolAccess(s *obj.LSym, d int64, reg int16, op uint32) (o1, o2 uint32) {
        if c.ctxt.Headtype == objabi.Haix {
-               // Every symbol accesses must be made via a TOC anchor.
+               // Every symbol access must be made via a TOC anchor.
                c.ctxt.Diag("symbolAccess called for %s", s.Name)
        }
        var base uint32
@@ -3656,18 +3656,20 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
                cy := int(c.regoff(p.GetFrom3()))
                o1 = AOP_Z23I(c.oprrr(p.As), uint32(p.To.Reg), uint32(p.From.Reg), uint32(p.Reg), uint32(cy))
 
-       case 95: /* Retrieve TOC symbol */
-               v := c.vregoff(&p.To)
+       case 95: /* Retrieve TOC relative symbol */
+               /* This code is for AIX only */
+               v := c.vregoff(&p.From)
                if v != 0 {
                        c.ctxt.Diag("invalid offset against TOC slot %v", p)
                }
 
-               if c.opform(c.opload(p.As)) != DS_FORM {
+               inst := c.opload(p.As)
+               if c.opform(inst) != DS_FORM {
                        c.ctxt.Diag("invalid form for a TOC access in %v", p)
                }
 
                o1 = AOP_IRR(OP_ADDIS, uint32(p.To.Reg), REG_R2, 0)
-               o2 = AOP_IRR(c.opload(AMOVD), uint32(p.To.Reg), uint32(p.To.Reg), 0)
+               o2 = AOP_IRR(inst, uint32(p.To.Reg), uint32(p.To.Reg), 0)
                rel := obj.Addrel(c.cursym)
                rel.Off = int32(c.pc)
                rel.Siz = 8
index a9928742deaa6f348fdd9b04d94f3058f24e0240..22869160988208d3126ec8f031454de62e6052c4 100644 (file)
@@ -114,6 +114,7 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
 }
 
 // Rewrite p, if necessary, to access a symbol using its TOC anchor.
+// This code is for AIX only.
 func (c *ctxt9) rewriteToUseTOC(p *obj.Prog) {
        if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
                return
index 4f5d8b55398bc6653d4f34efc4d34ea29537e237..3b283b38551b78b58a89f4f6b69384242ba05ab0 100644 (file)
@@ -383,7 +383,7 @@ func addelfdynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
 
 func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
        // Beware that bit0~bit15 start from the third byte of a instruction in Big-Endian machines.
-       if r.Type == objabi.R_ADDR || r.Type == objabi.R_POWER_TLS ||  r.Type == objabi.R_CALLPOWER {
+       if r.Type == objabi.R_ADDR || r.Type == objabi.R_POWER_TLS || r.Type == objabi.R_CALLPOWER {
        } else {
                if ctxt.Arch.ByteOrder == binary.BigEndian {
                        sectoff += 2
@@ -489,7 +489,12 @@ func symtoc(ctxt *ld.Link, s *sym.Symbol) int64 {
        return toc.Value
 }
 
+// archreloctoc relocates a TOC relative symbol.
+// This code is for AIX only.
 func archreloctoc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val int64) int64 {
+       if ctxt.HeadType == objabi.Hlinux {
+               ld.Errorf(s, "archrelocaddr called for %s relocation\n", r.Sym.Name)
+       }
        var o1, o2 uint32
 
        o1 = uint32(val >> 32)
@@ -519,6 +524,8 @@ func archreloctoc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val int64) int64 {
        return int64(o1)<<32 | int64(o2)
 }
 
+// archrelocaddr relocates a symbol address.
+// This code is for AIX only.
 func archrelocaddr(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val int64) int64 {
        if ctxt.HeadType == objabi.Haix {
                ld.Errorf(s, "archrelocaddr called for %s relocation\n", r.Sym.Name)