]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/amd64: always generate R_X86_64_PLT32 for SDYNIMPORT calls
authorJoel Sing <joel@sing.id.au>
Thu, 26 Nov 2020 15:06:08 +0000 (02:06 +1100)
committerJoel Sing <joel@sing.id.au>
Tue, 1 Dec 2020 05:09:44 +0000 (05:09 +0000)
Currently, in the non-DynlinkingGo case with external linking, we generate a
R_X86_64_GOTPCREL relocation for the imported symbol. This results in the
external linker turning this into a R_X86_64_GLOB_DAT relocation, rather
than a R_X86_64_JUMP_SLOT. Always generate R_X86_64_PLT32 for SDYNIMPORT
calls so that these calls work correctly.

Update #36435
Fixes #42671

Change-Id: I8a28884b7853cb4135053ed817bedc919482f4ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/270377
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/amd64/asm.go

index 360c5338ba2d98868efc98b050a7298045e140fa..2d09a6160aaae191a05311dd82e770a6b163027c 100644 (file)
@@ -413,11 +413,7 @@ func elfreloc1(ctxt *ld.Link, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym,
        case objabi.R_CALL:
                if siz == 4 {
                        if ldr.SymType(r.Xsym) == sym.SDYNIMPORT {
-                               if ctxt.DynlinkingGo() {
-                                       out.Write64(uint64(elf.R_X86_64_PLT32) | uint64(elfsym)<<32)
-                               } else {
-                                       out.Write64(uint64(elf.R_X86_64_GOTPCREL) | uint64(elfsym)<<32)
-                               }
+                               out.Write64(uint64(elf.R_X86_64_PLT32) | uint64(elfsym)<<32)
                        } else {
                                out.Write64(uint64(elf.R_X86_64_PC32) | uint64(elfsym)<<32)
                        }