Skip to content

Commit 3a6cd4c

Browse files
committed
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 <[email protected]> Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 24902c5 commit 3a6cd4c

File tree

1 file changed

+2
-2
lines changed
  • src/cmd/internal/obj/riscv

1 file changed

+2
-2
lines changed

src/cmd/internal/obj/riscv/obj.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ func jalrToSym(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc, lr int16) *ob
5858
p.Mark |= NEED_PCREL_ITYPE_RELOC
5959
p = obj.Appendp(p, newprog)
6060

61-
// Leave p.To.Sym only for the CALL reloc in assemble.
61+
// Leave Sym only for the CALL reloc in assemble.
6262
p.As = AJALR
6363
p.From.Type = obj.TYPE_REG
6464
p.From.Reg = lr
65+
p.From.Sym = to.Sym
6566
p.Reg = 0
6667
p.To.Type = obj.TYPE_REG
6768
p.To.Reg = REG_TMP
68-
p.To.Sym = to.Sym
6969
lowerJALR(p)
7070

7171
return p

0 commit comments

Comments
 (0)