1
0
mirror of https://github.com/golang/go synced 2024-11-08 12:06:18 -07:00

cmd/link/internal/arm64: handle calls to SDYNIMPORT with internal linking

Handle calls to symbols that are SDYNIMPORT when linking internally on arm64.

Update #36435

Change-Id: I8b5421171bf471cf31c91d90b8ba99511d2c9e2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/250181
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Joel Sing 2020-08-25 01:27:23 +10:00
parent 2517f4946b
commit 623319a847

View File

@ -219,15 +219,16 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
// External linker will do this relocation. // External linker will do this relocation.
return true return true
} }
if target.IsDarwin() { // XXX why we don't need this for ELF? // Internal linking.
// Internal linking. if r.Add() != 0 {
// Build a PLT entry and change the relocation target to that entry. ldr.Errorf(s, "PLT call with non-zero addend (%v)", r.Add())
addpltsym(target, ldr, syms, targ)
su := ldr.MakeSymbolUpdater(s)
su.SetRelocSym(rIdx, syms.PLT)
su.SetRelocAdd(rIdx, int64(ldr.SymPlt(targ)))
return true
} }
// Build a PLT entry and change the relocation target to that entry.
addpltsym(target, ldr, syms, targ)
su := ldr.MakeSymbolUpdater(s)
su.SetRelocSym(rIdx, syms.PLT)
su.SetRelocAdd(rIdx, int64(ldr.SymPlt(targ)))
return true
case objabi.R_ADDR: case objabi.R_ADDR:
if ldr.SymType(s) == sym.STEXT && target.IsElf() { if ldr.SymType(s) == sym.STEXT && target.IsElf() {