[llvm] r273066 - Support/ELF: Add AMDGPU relocation definitions to match documentation
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 15:38:09 PDT 2016
Author: tstellar
Date: Fri Jun 17 17:38:08 2016
New Revision: 273066
URL: http://llvm.org/viewvc/llvm-project?rev=273066&view=rev
Log:
Support/ELF: Add AMDGPU relocation definitions to match documentation
Reviewers: arsenm, kzhuravl, rafael
Subscribers: llvm-commits, kzhuravl
Differential Revision: http://reviews.llvm.org/D21443
Added:
llvm/trunk/include/llvm/Support/ELFRelocs/AMDGPU.def
llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml
Modified:
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/Object/ELF.cpp
llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=273066&r1=273065&r2=273066&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Fri Jun 17 17:38:08 2016
@@ -615,6 +615,11 @@ enum {
#include "ELFRelocs/WebAssembly.def"
};
+// ELF Relocation types for AMDGPU
+enum {
+#include "ELFRelocs/AMDGPU.def"
+};
+
#undef ELF_RELOC
// Section header.
Added: llvm/trunk/include/llvm/Support/ELFRelocs/AMDGPU.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELFRelocs/AMDGPU.def?rev=273066&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/ELFRelocs/AMDGPU.def (added)
+++ llvm/trunk/include/llvm/Support/ELFRelocs/AMDGPU.def Fri Jun 17 17:38:08 2016
@@ -0,0 +1,11 @@
+#ifndef ELF_RELOC
+#error "ELF_RELOC must be defined"
+#endif
+
+ELF_RELOC(R_AMDGPU_NONE, 0)
+ELF_RELOC(R_AMDGPU_ABS32_LO, 1)
+ELF_RELOC(R_AMDGPU_ABS32_HI, 2)
+ELF_RELOC(R_AMDGPU_ABS64, 3)
+ELF_RELOC(R_AMDGPU_REL32, 4)
+ELF_RELOC(R_AMDGPU_REL64, 5)
+ELF_RELOC(R_AMDGPU_ABS32, 6)
Modified: llvm/trunk/lib/Object/ELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELF.cpp?rev=273066&r1=273065&r2=273066&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELF.cpp (original)
+++ llvm/trunk/lib/Object/ELF.cpp Fri Jun 17 17:38:08 2016
@@ -105,6 +105,13 @@ StringRef getELFRelocationTypeName(uint3
break;
}
break;
+ case ELF::EM_AMDGPU:
+ switch (Type) {
+#include "llvm/Support/ELFRelocs/AMDGPU.def"
+ default:
+ break;
+ }
+ break;
default:
break;
}
Modified: llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/ELFYAML.cpp?rev=273066&r1=273065&r2=273066&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/ELFYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/ELFYAML.cpp Fri Jun 17 17:38:08 2016
@@ -531,6 +531,9 @@ void ScalarEnumerationTraits<ELFYAML::EL
case ELF::EM_LANAI:
#include "llvm/Support/ELFRelocs/Lanai.def"
break;
+ case ELF::EM_AMDGPU:
+#include "llvm/Support/ELFRelocs/AMDGPU.def"
+ break;
default:
llvm_unreachable("Unsupported architecture");
}
Added: llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml?rev=273066&view=auto
==============================================================================
--- llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml (added)
+++ llvm/trunk/test/Object/AMDGPU/elf64-relocs.yaml Fri Jun 17 17:38:08 2016
@@ -0,0 +1,65 @@
+# RUN: yaml2obj -format=elf %s > %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# CHECK: Relocations [
+# CHECK: Section (2) .rela.text {
+# CHECK: 0x0 R_AMDGPU_NONE main 0x0
+# CHECK: 0x8 R_AMDGPU_ABS32_LO - 0x0
+# CHECK: 0x10 R_AMDGPU_ABS32_HI - 0x0
+# CHECK: 0x18 R_AMDGPU_ABS64 - 0x0
+# CHECK: 0x20 R_AMDGPU_REL32 - 0x0
+# CHECK: 0x28 R_AMDGPU_REL64 - 0x0
+# CHECK: 0x30 R_AMDGPU_ABS32 - 0x0
+# CHECK: }
+# CHECK: ]
+
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_AMDGPU
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .text
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x08
+ Content: 0000000000000000
+ - Type: SHT_RELA
+ Name: .rela.text
+ Link: .symtab
+ Info: .text
+ AddressAlign: 0x08
+ Relocations:
+ - Offset: 0x0
+ Symbol: main
+ Type: R_AMDGPU_NONE
+ - Offset: 0x8
+ Symbol: a
+ Type: R_AMDGPU_ABS32_LO
+ - Offset: 0x10
+ Symbol: b
+ Type: R_AMDGPU_ABS32_HI
+ - Offset: 0x18
+ Symbol: c
+ Type: R_AMDGPU_ABS64
+ - Offset: 0x20
+ Symbol: d
+ Type: R_AMDGPU_REL32
+ - Offset: 0x28
+ Symbol: e
+ Type: R_AMDGPU_REL64
+ - Offset: 0x30
+ Symbol: f
+ Type: R_AMDGPU_ABS32
+
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+
+ Global:
+ - Name: main
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x08
More information about the llvm-commits
mailing list