aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/6l
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <michael.hudson@canonical.com>2015-05-05 16:10:12 +1200
committerIan Lance Taylor <iant@golang.org>2015-05-06 00:17:23 +0000
commit9f5d0bff415b57726b38f0ca85183f379ca04432 (patch)
tree19e3fd8ddccf23dab3888e5fe01cd81e0be3eff7 /src/cmd/6l
parentc661cb01f7cbe5683395569dea0556ba1679723a (diff)
downloadgo-9f5d0bff415b57726b38f0ca85183f379ca04432.tar.xz
cmd/6l, cmd/internal/ld: handle R_PCREL to function in other shared library
An ELF linker handles a PC-relative reference to an STT_FUNC defined in a shared library by building a PLT entry and referring to that, so do the same in 6l. Fixes #10690 Change-Id: I061a96fd4400d957e301d0ac86760ce256910e1d Reviewed-on: https://go-review.googlesource.com/9711 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/6l')
-rw-r--r--src/cmd/6l/asm.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmd/6l/asm.go b/src/cmd/6l/asm.go
index deaeb82d39..4df8ac7196 100644
--- a/src/cmd/6l/asm.go
+++ b/src/cmd/6l/asm.go
@@ -33,6 +33,7 @@ package main
import (
"cmd/internal/ld"
"cmd/internal/obj"
+ "debug/elf"
"fmt"
"log"
)
@@ -381,7 +382,11 @@ func elfreloc1(r *ld.Reloc, sectoff int64) int {
case obj.R_PCREL:
if r.Siz == 4 {
- ld.Thearch.Vput(ld.R_X86_64_PC32 | uint64(elfsym)<<32)
+ if r.Xsym.Type == obj.SDYNIMPORT && r.Xsym.ElfType == elf.STT_FUNC {
+ ld.Thearch.Vput(ld.R_X86_64_PLT32 | uint64(elfsym)<<32)
+ } else {
+ ld.Thearch.Vput(ld.R_X86_64_PC32 | uint64(elfsym)<<32)
+ }
} else {
return -1
}