[PATCH] D143539: [AMDGPU] Add AMDGPU support for llvm-objcopy
Aakanksha Patil via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 14:01:05 PDT 2023
aakanksha555 updated this revision to Diff 538258.
Herald added subscribers: kerbowa, jvesely, emaste.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143539/new/
https://reviews.llvm.org/D143539
Files:
llvm/test/tools/llvm-objcopy/ELF/amdgpu-cross-arch-headers.test
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -302,6 +302,8 @@
// FIXME: consolidate with the bfd parsing used by lld.
static const StringMap<MachineInfo> TargetMap{
// Name, {EMachine, 64bit, LittleEndian}
+ // AMDGPU
+ {"elf64-amdgpu", {ELF::EM_AMDGPU, true, true}},
// x86
{"elf32-i386", {ELF::EM_386, false, true}},
{"elf32-x86-64", {ELF::EM_X86_64, false, true}},
Index: llvm/test/tools/llvm-objcopy/ELF/amdgpu-cross-arch-headers.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/amdgpu-cross-arch-headers.test
@@ -0,0 +1,57 @@
+# Show that the --output-format correctly configures both the main output file
+# and DWO output.
+# Note that we don't actually need any DWARF to produce the DWO file.
+
+# RUN: yaml2obj %s -o %t.o
+
+# Without --output-format, the format should match the input.
+
+# RUN: llvm-objcopy %t.o -O elf64-amdgpu %t.elf64_amdgpu.o --split-dwo=%t.elf64_amdgpu.dwo
+# RUN: llvm-readobj --file-headers %t.elf64_amdgpu.o | FileCheck %s --check-prefixes=CHECK,LE,AMDGPU,64,SYSV
+# RUN: llvm-readobj --file-headers %t.elf64_amdgpu.dwo | FileCheck %s --check-prefixes=CHECK,LE,AMDGPU,64,SYSV
+
+!ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ # Arbitrary values that do not match any value we convert to via --output-format.
+ Machine: EM_AMDGPU
+ OSABI: ELFOSABI_STANDALONE
+ Flags: [EF_AMDGPU_MACH_AMDGCN_GFX900]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+Symbols:
+ - Name: foo
+ Type: STT_FUNC
+ Section: .text
+ Value: 0x1234
+ Binding: STB_GLOBAL
+ - Name: bar
+ Type: STT_OBJECT
+ Section: .data
+ Value: 0xabcd
+ Binding: STB_GLOBAL
+
+# CHECK: Format:
+# AMDGPU-SAME: elf64-amdgpu
+
+# AMDGPU-NEXT: Arch: amdgcn
+
+# 64-NEXT: AddressSize: 64bit
+
+# 64: Class: 64-bit
+# LE: DataEncoding: LittleEndian
+
+# SYSV: OS/ABI: SystemV (0x0)
+
+# AMDGPU: Machine: EM_AMDGPU (0xE0)
+
+# 64: HeaderSize: 64
+
+# 64: SectionHeaderEntrySize: 64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143539.538258.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230707/8e175a8b/attachment-0001.bin>
More information about the llvm-commits
mailing list