[lld] r273192 - ELF/AMDGPU: Add support for R_AMDGPU_REL32 relocations
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 12:48:29 PDT 2016
Author: tstellar
Date: Mon Jun 20 14:48:29 2016
New Revision: 273192
URL: http://llvm.org/viewvc/llvm-project?rev=273192&view=rev
Log:
ELF/AMDGPU: Add support for R_AMDGPU_REL32 relocations
Reviewers: rafael, ruiu
Subscribers: kzhuravl, llvm-commits
Differential Revision: http://reviews.llvm.org/D21294
Added:
lld/trunk/test/ELF/amdgpu-relocs.s
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=273192&r1=273191&r2=273192&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Jun 20 14:48:29 2016
@@ -1405,17 +1405,16 @@ void AArch64TargetInfo::relaxTlsIeToLe(u
llvm_unreachable("invalid relocation for TLS IE to LE relaxation");
}
-// Implementing relocations for AMDGPU is low priority since most
-// programs don't use relocations now. Thus, this function is not
-// actually called (relocateOne is called for each relocation).
-// That's why the AMDGPU port works without implementing this function.
void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
uint64_t Val) const {
- llvm_unreachable("not implemented");
+ assert(Type == R_AMDGPU_REL32);
+ write32le(Loc, Val);
}
RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
- llvm_unreachable("not implemented");
+ if (Type != R_AMDGPU_REL32)
+ error("do not know how to handle relocation");
+ return R_PC;
}
ARMTargetInfo::ARMTargetInfo() {
Added: lld/trunk/test/ELF/amdgpu-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/amdgpu-relocs.s?rev=273192&view=auto
==============================================================================
--- lld/trunk/test/ELF/amdgpu-relocs.s (added)
+++ lld/trunk/test/ELF/amdgpu-relocs.s Mon Jun 20 14:48:29 2016
@@ -0,0 +1,18 @@
+# RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o
+# RUN: ld.lld -shared %t.o -o %t.so
+# RUN: llvm-readobj -r %t.so | FileCheck %s
+
+# REQUIRES: amdgpu
+
+# Make sure that the reloc for local_var is resolved by lld.
+
+ .text
+
+kernel0:
+ s_mov_b32 s0, local_var+4
+ s_endpgm
+
+ .local local_var
+
+# CHECK: Relocations [
+# CHECK-NEXT: ]
More information about the llvm-commits
mailing list