From 477a8e97a9240972e658378a94fc791ff62cc64c Mon Sep 17 00:00:00 2001 From: Valery Pykhtin Date: Wed, 9 Mar 2016 17:08:19 +0000 Subject: [PATCH] [AMDGPU] add AMDGPU target support to ELFObjectFile.h header Differential Revision: http://reviews.llvm.org/D17144 llvm-svn: 263026 --- include/llvm/Object/ELFObjectFile.h | 12 ++++++++++++ lib/ObjectYAML/ELFYAML.cpp | 1 + test/Object/AMDGPU/elf-definitios.yaml | 3 +++ test/Object/AMDGPU/elf32-unknown.yaml | 11 +++++++++++ test/Object/AMDGPU/elf64-unknown.yaml | 11 +++++++++++ 5 files changed, 38 insertions(+) create mode 100644 test/Object/AMDGPU/elf32-unknown.yaml create mode 100644 test/Object/AMDGPU/elf64-unknown.yaml diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index d927aace242..b01fa1da4b3 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -846,6 +846,8 @@ StringRef ELFObjectFile::getFileFormatName() const { return "ELF32-sparc"; case ELF::EM_WEBASSEMBLY: return "ELF32-wasm"; + case ELF::EM_AMDGPU: + return "ELF32-amdgpu"; default: return "ELF32-unknown"; } @@ -867,6 +869,10 @@ StringRef ELFObjectFile::getFileFormatName() const { return "ELF64-mips"; case ELF::EM_WEBASSEMBLY: return "ELF64-wasm"; + case ELF::EM_AMDGPU: + return (EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA + && IsLittleEndian) ? + "ELF64-amdgpu-hsacobj" : "ELF64-amdgpu"; default: return "ELF64-unknown"; } @@ -923,6 +929,12 @@ unsigned ELFObjectFile::getArch() const { default: return Triple::UnknownArch; } + case ELF::EM_AMDGPU: + return (EF.getHeader()->e_ident[ELF::EI_CLASS] == ELF::ELFCLASS64 + && EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA + && IsLittleEndian) ? + Triple::amdgcn : Triple::UnknownArch; + default: return Triple::UnknownArch; } diff --git a/lib/ObjectYAML/ELFYAML.cpp b/lib/ObjectYAML/ELFYAML.cpp index 06db57a1788..3b94fa62e1d 100644 --- a/lib/ObjectYAML/ELFYAML.cpp +++ b/lib/ObjectYAML/ELFYAML.cpp @@ -239,6 +239,7 @@ void ScalarEnumerationTraits::enumeration( ECase(ELFOSABI_FENIXOS) ECase(ELFOSABI_CLOUDABI) ECase(ELFOSABI_C6000_ELFABI) + ECase(ELFOSABI_AMDGPU_HSA) ECase(ELFOSABI_C6000_LINUX) ECase(ELFOSABI_ARM) ECase(ELFOSABI_STANDALONE) diff --git a/test/Object/AMDGPU/elf-definitios.yaml b/test/Object/AMDGPU/elf-definitios.yaml index 5f5e200b49b..6d535095123 100644 --- a/test/Object/AMDGPU/elf-definitios.yaml +++ b/test/Object/AMDGPU/elf-definitios.yaml @@ -1,6 +1,8 @@ # RUN: yaml2obj -format=elf %s > %t.o # RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s +# CHECK: Format: ELF64-amdgpu-hsacobj +# CHECK: Arch: amdgcn # CHECK: Machine: EM_AMDGPU (0xE0) # CHECK: Sections [ # CHECK: Section { @@ -18,6 +20,7 @@ FileHeader: Data: ELFDATA2LSB Type: ET_REL Machine: EM_AMDGPU + OSABI: ELFOSABI_AMDGPU_HSA Sections: - Name: .shf_amdgpu diff --git a/test/Object/AMDGPU/elf32-unknown.yaml b/test/Object/AMDGPU/elf32-unknown.yaml new file mode 100644 index 00000000000..708db8dc9fc --- /dev/null +++ b/test/Object/AMDGPU/elf32-unknown.yaml @@ -0,0 +1,11 @@ +# RUN: yaml2obj -format=elf %s > %t.o +# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s + +# CHECK: Format: ELF32-amdgpu + +--- +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_AMDGPU diff --git a/test/Object/AMDGPU/elf64-unknown.yaml b/test/Object/AMDGPU/elf64-unknown.yaml new file mode 100644 index 00000000000..cae248854ad --- /dev/null +++ b/test/Object/AMDGPU/elf64-unknown.yaml @@ -0,0 +1,11 @@ +# RUN: yaml2obj -format=elf %s > %t.o +# RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s + +# CHECK: Format: ELF64-amdgpu + +--- +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_AMDGPU