[llvm] r315935 - Add base relative relocation record that can be used for the following case (OpenCL example):

Tony Tye via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 13:44:29 PDT 2017


Author: t-tye
Date: Mon Oct 16 13:44:29 2017
New Revision: 315935

URL: http://llvm.org/viewvc/llvm-project?rev=315935&view=rev
Log:
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.

Differential Revision: https://reviews.llvm.org/D38909

Modified:
    llvm/trunk/docs/AMDGPUUsage.rst
    llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
    llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml

Modified: llvm/trunk/docs/AMDGPUUsage.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AMDGPUUsage.rst?rev=315935&r1=315934&r2=315935&view=diff
==============================================================================
--- llvm/trunk/docs/AMDGPUUsage.rst (original)
+++ llvm/trunk/docs/AMDGPUUsage.rst Mon Oct 16 13:44:29 2017
@@ -684,7 +684,12 @@ Following notations are used for specify
 
 **S**
   Represents the value of the symbol whose index resides in the relocation
-  entry.
+  entry. Relocations not using this must specify a symbol index of ``STN_UNDEF``.
+
+**B**
+  Represents the base address of a loaded executable or shared object which is
+  the difference between the ELF address and the actual load address. Relocations
+  using this are only valid in executable or shared objects.
 
 The following relocation types are supported:
 
@@ -706,6 +711,8 @@ The following relocation types are suppo
      ``R_AMDGPU_GOTPCREL32_HI``  9      ``word32``  (G + GOT + A - P) >> 32
      ``R_AMDGPU_REL32_LO``       10     ``word32``  (S + A - P) & 0xFFFFFFFF
      ``R_AMDGPU_REL32_HI``       11     ``word32``  (S + A - P) >> 32
+     *reserved*                  12
+     ``R_AMDGPU_RELATIVE64``     13     ``word64``  B + A
      ==========================  =====  ==========  ==============================
 
 .. _amdgpu-dwarf:

Modified: llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def?rev=315935&r1=315934&r2=315935&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def (original)
+++ llvm/trunk/include/llvm/BinaryFormat/ELFRelocs/AMDGPU.def Mon Oct 16 13:44:29 2017
@@ -14,3 +14,4 @@ ELF_RELOC(R_AMDGPU_GOTPCREL32_LO,  8)
 ELF_RELOC(R_AMDGPU_GOTPCREL32_HI,  9)
 ELF_RELOC(R_AMDGPU_REL32_LO,      10)
 ELF_RELOC(R_AMDGPU_REL32_HI,      11)
+ELF_RELOC(R_AMDGPU_RELATIVE64,    13)

Modified: llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml?rev=315935&r1=315934&r2=315935&view=diff
==============================================================================
--- llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml (original)
+++ llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml Mon Oct 16 13:44:29 2017
@@ -15,6 +15,7 @@
 # CHECK:     0x18 R_AMDGPU_GOTPCREL32_HI  - 0x0
 # CHECK:     0x20 R_AMDGPU_REL32_LO       - 0x0
 # CHECK:     0x22 R_AMDGPU_REL32_HI       - 0x0
+# CHECK:     0x24 R_AMDGPU_RELATIVE64     - 0x0
 # CHECK:   }
 # CHECK: ]
 
@@ -72,6 +73,9 @@ Sections:
       - Offset:          0x22
         Symbol:          s11
         Type:            R_AMDGPU_REL32_HI
+      - Offset:          0x24
+        Symbol:          s12
+        Type:            R_AMDGPU_RELATIVE64
 
 Symbols:
   Local:




More information about the llvm-commits mailing list