]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/arm64: handle calls to SDYNIMPORT with internal linking
authorJoel Sing <joel@sing.id.au>
Mon, 24 Aug 2020 15:27:23 +0000 (01:27 +1000)
committerJoel Sing <joel@sing.id.au>
Thu, 15 Oct 2020 16:42:52 +0000 (16:42 +0000)
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>
src/cmd/link/internal/arm64/asm.go

index 7bf41c93a6d874d8140ad531b63b5e81dfb32cde..585c96852f98a395608564bac022c29c2c94395e 100644 (file)
@@ -219,15 +219,16 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
                        // External linker will do this relocation.
                        return true
                }
-               if target.IsDarwin() { // XXX why we don't need this for ELF?
-                       // Internal linking.
-                       // 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
+               // Internal linking.
+               if r.Add() != 0 {
+                       ldr.Errorf(s, "PLT call with non-zero addend (%v)", r.Add())
                }
+               // 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:
                if ldr.SymType(s) == sym.STEXT && target.IsElf() {