Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions llvm/test/tools/llvm-objcopy/ELF/amdgpu-cross-arch-headers.test
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ static const StringMap<MachineInfo> TargetMap{
{"elf64-loongarch", {ELF::EM_LOONGARCH, true, true}},
// SystemZ
{"elf64-s390", {ELF::EM_S390, true, false}},
// AMDGPU
{"elf64-amdgpu", {ELF::EM_AMDGPU, true, true}},
};

static Expected<TargetInfo>
Expand Down