From: Joel Sing Date: Tue, 31 Dec 2019 14:44:54 +0000 (+1100) Subject: cmd/internal/obj/riscv: correct CALL reloc symbol handling X-Git-Tag: go1.14rc1~180 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3a6cd4c72d5c8fc6c86f074eadaaf3972e591973;p=gostls13.git cmd/internal/obj/riscv: correct CALL reloc symbol handling Move the CALL reloc symbol back to p.From.Sym, rather than p.To.Sym - while p.To.Sym is the correct final location, the call to lowerJALR flips the p.To and p.From addresses (and proves that this form of obj.Prog rewriting is not a good idea). Updates #27532 Change-Id: Iaf9fa24b05bda32b963f8d243401c6cd82c1355c Reviewed-on: https://go-review.googlesource.com/c/go/+/212759 Reviewed-by: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index 2e9ac6750b..b024a6a546 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -58,14 +58,14 @@ func jalrToSym(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc, lr int16) *ob p.Mark |= NEED_PCREL_ITYPE_RELOC p = obj.Appendp(p, newprog) - // Leave p.To.Sym only for the CALL reloc in assemble. + // Leave Sym only for the CALL reloc in assemble. p.As = AJALR p.From.Type = obj.TYPE_REG p.From.Reg = lr + p.From.Sym = to.Sym p.Reg = 0 p.To.Type = obj.TYPE_REG p.To.Reg = REG_TMP - p.To.Sym = to.Sym lowerJALR(p) return p