From d8269ab0d59212fed0f5975f7083f6bbbfc00ec4 Mon Sep 17 00:00:00 2001 From: limeidan Date: Mon, 24 Nov 2025 17:28:42 +0800 Subject: cmd/link, cmd/internal/obj: fix a remote call failure issue When a function call exceeds the immediate value range of the instruction, a trampoline is required to assist in the jump. Trampoline is only omitted when plt is needed; otherwise, a check is required. Change-Id: I7fe2e08d75f6f574475837b560e650bbd4215858 Reviewed-on: https://go-review.googlesource.com/c/go/+/724580 Reviewed-by: abner chenc LUCI-TryBot-Result: Go LUCI Reviewed-by: sophie zhao Reviewed-by: Cherry Mui Reviewed-by: Dmitri Shuralyov --- src/cmd/internal/obj/loong64/asm.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd/internal/obj') diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go index 3fcd6eafd7..f992518015 100644 --- a/src/cmd/internal/obj/loong64/asm.go +++ b/src/cmd/internal/obj/loong64/asm.go @@ -2437,6 +2437,9 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { v := int32(0) if p.To.Target() != nil { v = int32(p.To.Target().Pc-p.Pc) >> 2 + if v < -1<<25 || v >= 1<<25 { + c.ctxt.Diag("branch too far \n%v", p) + } } o1 = OP_B_BL(c.opirr(p.As), uint32(v)) if p.To.Sym != nil { -- cgit v1.3-6-g1900