[PATCH] D21294: ELF/AMDGPU: Add support for R_AMDGPU_ABS32 relocations

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 20:22:03 PDT 2016


tstellarAMD updated this revision to Diff 60787.
tstellarAMD added a comment.

Add better error handling.


http://reviews.llvm.org/D21294

Files:
  ELF/Target.cpp
  test/ELF/amdgpu-relocs.s

Index: test/ELF/amdgpu-relocs.s
===================================================================
--- /dev/null
+++ test/ELF/amdgpu-relocs.s
@@ -0,0 +1,27 @@
+# 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 gdata is resolved by lld.
+
+  .text
+  .globl kernel0
+  .p2align 8
+  .type kernel0, at function
+  .amdgpu_hsa_kernel kernel0
+
+kernel0:
+  s_mov_b32 s0, gdata+4
+  s_endpgm
+
+.Lfunc_end0:
+  .size kernel0, .Lfunc_end0-kernel0
+
+  .type   gdata, at object
+  .local  gdata
+  .comm   gdata,1024,4
+
+# CHECK: Relocations [
+# CHECK-NEXT: ]
Index: ELF/Target.cpp
===================================================================
--- ELF/Target.cpp
+++ ELF/Target.cpp
@@ -1430,17 +1430,16 @@
   write32le(Loc, NewInst);
 }
 
-// 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() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21294.60787.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160615/98f18a15/attachment.bin>


More information about the llvm-commits mailing list