From: Joel Sing Date: Wed, 22 Jan 2020 16:31:49 +0000 (+1100) Subject: cmd/internal/obj/riscv: restore the ADDI instruction in jalrToSym X-Git-Tag: go1.14rc1~81 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9f07cdd99ee70b90e2a5fe998acb48c5fc6e39f2;p=gostls13.git cmd/internal/obj/riscv: restore the ADDI instruction in jalrToSym While this instruction is not needed for the relocation (the lower immediate can be patched directly into the JALR instruction), other code currently depends on the jump sequence being 12 bytes (or three instructions) long. Put the ADDI instruction back until these can be found and fixed. Updates #27532 Change-Id: Idb73d716be8eb2eb796591b30f1ec4dc104f2bf8 Reviewed-on: https://go-review.googlesource.com/c/go/+/215840 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 520158119e..6b36a94daa 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -55,6 +55,15 @@ 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) + // TODO(jsing): This instruction is not necessary, as the lower bits + // of the immediate can be encoded directly in the JALR instruction. + // However, other code currently depends on jalrToSym being 12 bytes... + p.As = AADDI + p.From = obj.Addr{Type: obj.TYPE_CONST} + p.Reg = REG_TMP + p.To = obj.Addr{Type: obj.TYPE_REG, Reg: REG_TMP} + p = obj.Appendp(p, newprog) + // Leave Sym only for the CALL reloc in assemble. p.As = AJALR p.From.Type = obj.TYPE_REG