Skip to content

Commit

Permalink
[llvm-objcopy] Add SystemZ support (llvm#81841)
Browse files Browse the repository at this point in the history
This is also necessary for enabling ClangBuiltLinux:
ClangBuiltLinux/linux#1530
  • Loading branch information
uweigand authored Feb 16, 2024
1 parent 8c20337 commit 3c02cb7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
# RUN: llvm-objcopy -I binary -O elf64-loongarch %t.txt %t.la64.o
# RUN: llvm-readobj --file-headers %t.la64.o | FileCheck %s --check-prefixes=CHECK,LE,LA64,64

# RUN: llvm-objcopy -I binary -O elf64-s390 %t.txt %t.s390x.o
# RUN: llvm-readobj --file-headers %t.s390x.o | FileCheck %s --check-prefixes=CHECK,BE,S390X,64

# CHECK: Format:
# 32-SAME: elf32-
# 64-SAME: elf64-
Expand All @@ -64,6 +67,7 @@
# PPCLE-SAME: powerpcle{{$}}
# SPARC-SAME: sparc
# SPARCEL-SAME: sparc
# S390X-SAME: s390
# X86-64-SAME: x86-64

# AARCH64-NEXT: Arch: aarch64
Expand All @@ -81,6 +85,7 @@
# RISCV64-NEXT: Arch: riscv64
# SPARC-NEXT: Arch: sparc{{$}}
# SPARCEL-NEXT: Arch: sparcel
# S390X-NEXT: Arch: s390x
# X86-64-NEXT: Arch: x86_64

# 32-NEXT: AddressSize: 32bit
Expand Down Expand Up @@ -116,6 +121,7 @@
# RISCV64-NEXT: Machine: EM_RISCV (0xF3)
# SPARC-NEXT: Machine: EM_SPARC (0x2)
# SPARCEL-NEXT: Machine: EM_SPARC (0x2)
# S390X-NEXT: Machine: EM_S390 (0x16)
# X86-64-NEXT: Machine: EM_X86_64 (0x3E)

# CHECK-NEXT: Version: 1
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
# RUN: llvm-readobj --file-headers %t.elf64_loongarch.o | FileCheck %s --check-prefixes=CHECK,LE,LA64,64,SYSV
# RUN: llvm-readobj --file-headers %t.elf64_loongarch.dwo | FileCheck %s --check-prefixes=CHECK,LE,LA64,64,SYSV

# RUN: llvm-objcopy %t.o -O elf64-s390 %t.elf64_s390.o --split-dwo=%t.elf64_s390.dwo
# RUN: llvm-readobj --file-headers %t.elf64_s390.o | FileCheck %s --check-prefixes=CHECK,BE,S390X,64,SYSV
# RUN: llvm-readobj --file-headers %t.elf64_s390.dwo | FileCheck %s --check-prefixes=CHECK,BE,S390X,64,SYSV

!ELF
FileHeader:
Class: ELFCLASS32
Expand Down Expand Up @@ -160,6 +164,7 @@ Symbols:
# RISCV32-SAME: riscv{{$}}
# RISCV64-SAME: riscv{{$}}
# SPARC-SAME: sparc
# S390X-SAME: s390
# X86-64-SAME: x86-64
# DEFAULT-SAME: unknown

Expand All @@ -182,6 +187,7 @@ Symbols:
# RISCV64-NEXT: Arch: riscv64
# SPARC-NEXT: Arch: sparc{{$}}
# SPARCEL-NEXT: Arch: sparcel
# S390X-NEXT: Arch: s390x
# X86-64-NEXT: Arch: x86_64
# DEFAULT-NEXT: Arch: unknown

Expand Down Expand Up @@ -210,6 +216,7 @@ Symbols:
# RISCV32: Machine: EM_RISCV (0xF3)
# RISCV64: Machine: EM_RISCV (0xF3)
# SPARC: Machine: EM_SPARC (0x2)
# S390X: Machine: EM_S390 (0x16)
# X86-64: Machine: EM_X86_64 (0x3E)

# 32: HeaderSize: 52
Expand Down
2 changes: 2 additions & 0 deletions llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ static const StringMap<MachineInfo> TargetMap{
// LoongArch
{"elf32-loongarch", {ELF::EM_LOONGARCH, false, true}},
{"elf64-loongarch", {ELF::EM_LOONGARCH, true, true}},
// SystemZ
{"elf64-s390", {ELF::EM_S390, true, false}},
};

static Expected<TargetInfo>
Expand Down

0 comments on commit 3c02cb7

Please sign in to comment.