[PATCH] D21646: AMDGPU/SI: Add support for R_AMDGPU_ABS32

Konstantin Zhuravlyov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 08:36:59 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL276294: AMDGPU/SI: Add support for R_AMDGPU_ABS32 (authored by kzhuravl).

Changed prior to commit:
  https://reviews.llvm.org/D21646?vs=64532&id=64901#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21646

Files:
  llvm/trunk/include/llvm/Object/RelocVisitor.h
  llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
  llvm/trunk/test/MC/AMDGPU/reloc.s

Index: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
@@ -56,6 +56,7 @@
   default: break;
   case FK_PCRel_4:
     return ELF::R_AMDGPU_REL32;
+  case FK_Data_4:
   case FK_SecRel_4:
     return ELF::R_AMDGPU_ABS32;
   }
Index: llvm/trunk/include/llvm/Object/RelocVisitor.h
===================================================================
--- llvm/trunk/include/llvm/Object/RelocVisitor.h
+++ llvm/trunk/include/llvm/Object/RelocVisitor.h
@@ -139,6 +139,14 @@
           HasError = true;
           return RelocToApply();
         }
+      case Triple::amdgcn:
+        switch (RelocType) {
+        case llvm::ELF::R_AMDGPU_ABS32:
+          return visitELF_AMDGPU_ABS32(R, Value);
+        default:
+          HasError = true;
+          return RelocToApply();
+        }
       default:
         HasError = true;
         return RelocToApply();
@@ -403,6 +411,11 @@
     return RelocToApply(static_cast<uint32_t>(Res), 4);
   }
 
+  RelocToApply visitELF_AMDGPU_ABS32(RelocationRef R, uint64_t Value) {
+    int64_t Addend = getELFAddend(R);
+    return RelocToApply(Value + Addend, 4);
+  }
+
   /// I386 COFF
   RelocToApply visitCOFF_I386_SECREL(RelocationRef R, uint64_t Value) {
     return RelocToApply(static_cast<uint32_t>(Value), /*Width=*/4);
Index: llvm/trunk/test/MC/AMDGPU/reloc.s
===================================================================
--- llvm/trunk/test/MC/AMDGPU/reloc.s
+++ llvm/trunk/test/MC/AMDGPU/reloc.s
@@ -4,6 +4,7 @@
 // CHECK: R_AMDGPU_ABS32_LO SCRATCH_RSRC_DWORD0 0x0
 // CHECK: R_AMDGPU_ABS32_HI SCRATCH_RSRC_DWORD1 0x0
 // CHECK: R_AMDGPU_GOTPCREL global_var 0x0
+// CHECK: R_AMDGPU_ABS32 var 0x0
 // CHECK: ]
 
 kernel:
@@ -14,3 +15,6 @@
 .globl global_var
 
 .globl SCRATCH_RSRC_DWORD0
+
+.section nonalloc, "w", @progbits
+  .long var, common_var


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21646.64901.patch
Type: text/x-patch
Size: 2031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/4b0726b0/attachment.bin>


More information about the llvm-commits mailing list