aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/internal/obj/loong64/asm.go3
-rw-r--r--src/cmd/link/internal/loong64/asm.go13
2 files changed, 11 insertions, 5 deletions
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 {
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