diff options
| author | limeidan <limeidan@loongson.cn> | 2025-11-24 17:28:42 +0800 |
|---|---|---|
| committer | abner chenc <chenguoqi@loongson.cn> | 2025-11-26 18:59:35 -0800 |
| commit | d8269ab0d59212fed0f5975f7083f6bbbfc00ec4 (patch) | |
| tree | 36be981db2c4423b3ce5d1401c8f8fde3fa8740e /src/cmd/link | |
| parent | c6d64f85565e6a934110c4928ca95fea0045ebaa (diff) | |
| download | go-d8269ab0d59212fed0f5975f7083f6bbbfc00ec4.tar.xz | |
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 <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/cmd/link')
| -rw-r--r-- | src/cmd/link/internal/loong64/asm.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cmd/link/internal/loong64/asm.go b/src/cmd/link/internal/loong64/asm.go index 219cfc7196..142578bceb 100644 --- a/src/cmd/link/internal/loong64/asm.go +++ b/src/cmd/link/internal/loong64/asm.go @@ -643,11 +643,14 @@ func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) { relocs := ldr.Relocs(s) r := relocs.At(ri) switch r.Type() { - case objabi.ElfRelocOffset + objabi.RelocType(elf.R_LARCH_B26): - // Nothing to do. - // The plt symbol has not been added. If we add tramp - // here, plt will not work. - case objabi.R_CALLLOONG64: + case objabi.ElfRelocOffset + objabi.RelocType(elf.R_LARCH_B26), objabi.R_CALLLOONG64: + if ldr.SymType(rs) == sym.SDYNIMPORT { + // Nothing to do. + // The plt symbol has not been added. If we add tramp + // here, plt will not work. + return + } + var t int64 // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages |
