summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Tye <Tony.Tye@amd.com>2017-10-16 20:46:53 +0000
committerTony Tye <Tony.Tye@amd.com>2017-10-16 20:46:53 +0000
commit394e1dde6e6c85450f124053b49329d287d088d6 (patch)
treefb507b28ee3871eb7bed5245b3ea69fa92b4802e
parentd288430c3e8597c5eb74ab6fe9ee6f4ef75b1723 (diff)
downloadbcm5719-llvm-394e1dde6e6c85450f124053b49329d287d088d6.tar.gz
bcm5719-llvm-394e1dde6e6c85450f124053b49329d287d088d6.zip
Add base relative relocation record that can be used for the following case (OpenCL example):
static __global int Var = 0; __global int* Ptr[] = {&Var}; ... In this case Var is a non premptable symbol and so its address can be used as the value of Ptr, with a base relative relocation that will add the delta between the ELF address and the actual load address. Such relocations do not require a symbol. This also fixes LLD which was incorrectly generating a PCREL64 for this case. Differential Revision: https://reviews.llvm.org/D38910 llvm-svn: 315936
-rw-r--r--lld/ELF/Arch/AMDGPU.cpp2
-rw-r--r--lld/test/ELF/amdgpu-relocs.s13
2 files changed, 14 insertions, 1 deletions
diff --git a/lld/ELF/Arch/AMDGPU.cpp b/lld/ELF/Arch/AMDGPU.cpp
index 1c82ff26bf9..a969a84d219 100644
--- a/lld/ELF/Arch/AMDGPU.cpp
+++ b/lld/ELF/Arch/AMDGPU.cpp
@@ -32,7 +32,7 @@ public:
} // namespace
AMDGPU::AMDGPU() {
- RelativeRel = R_AMDGPU_REL64;
+ RelativeRel = R_AMDGPU_RELATIVE64;
GotRel = R_AMDGPU_ABS64;
GotEntrySize = 8;
}
diff --git a/lld/test/ELF/amdgpu-relocs.s b/lld/test/ELF/amdgpu-relocs.s
index 2e85ff7b194..8b5a61ed21f 100644
--- a/lld/test/ELF/amdgpu-relocs.s
+++ b/lld/test/ELF/amdgpu-relocs.s
@@ -65,10 +65,23 @@ ptr:
.quad temp
.size ptr, 8
+# R_AMDGPU_RELATIVE64:
+ .type temp2, @object
+ .local temp2
+ .size temp2, 4
+
+ .type ptr2, @object
+ .globl ptr2
+ .size ptr2, 8
+ .p2align 3
+ptr2:
+ .quad temp2
+
# The relocation for local_var{0, 1, 2} and var should be resolved by the
# linker.
# CHECK: Relocations [
# CHECK: .rela.dyn {
+# CHECK-NEXT: R_AMDGPU_RELATIVE64 - 0x0
# CHECK-NEXT: R_AMDGPU_ABS64 common_var0 0x0
# CHECK-NEXT: R_AMDGPU_ABS64 common_var1 0x0
# CHECK-NEXT: R_AMDGPU_ABS64 common_var2 0x0
OpenPOWER on IntegriCloud