diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test @@ -30,11 +30,15 @@ # RUN: llvm-objcopy -I binary -O elf32-sparcel %t.txt %t.sparcel.o # RUN: llvm-readobj --file-headers %t.sparcel.o | FileCheck %s --check-prefixes=CHECK,LE,SPARCEL,32 +# RUN: llvm-objcopy -I binary -O elf32-hexagon %t.txt %t.hexagon.o +# RUN: llvm-readobj --file-headers %t.hexagon.o | FileCheck %s --check-prefixes=CHECK,LE,HEXAGON,32 + # CHECK: Format: # 32-SAME: elf32- # 64-SAME: elf64- # AARCH64-SAME: littleaarch64 # ARM-SAME: littlearm +# HEXAGON-SAME: hexagon # I386-SAME: i386 # MIPS-SAME: mips{{$}} # RISCV32-SAME: riscv{{$}} @@ -47,6 +51,7 @@ # AARCH64-NEXT: Arch: aarch64 # ARM-NEXT: Arch: arm +# HEXAGON-NEXT: Arch: hexagon # I386-NEXT: Arch: i386 # MIPS-NEXT: Arch: mips{{$}} # PPC-NEXT: Arch: powerpc{{$}} @@ -79,6 +84,7 @@ ## We fill in the field regardless of -B. # AARCH64-NEXT: Machine: EM_AARCH64 (0xB7) # ARM-NEXT: Machine: EM_ARM (0x28) +# HEXAGON-NEXT: Machine: EM_HEXAGON (0xA4) # I386-NEXT: Machine: EM_386 (0x3) # MIPS-NEXT: Machine: EM_MIPS (0x8) # PPC-NEXT: Machine: EM_PPC (0x14) diff --git a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test --- a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test +++ b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test @@ -105,6 +105,10 @@ # RUN: llvm-readobj --file-headers %t.elf32_sparcel.o | FileCheck %s --check-prefixes=CHECK,LE,SPARCEL,32,SYSV # RUN: llvm-readobj --file-headers %t.elf32_sparcel.dwo | FileCheck %s --check-prefixes=CHECK,LE,SPARCEL,32,SYSV +# RUN: llvm-objcopy %t.o -O elf32-hexagon %t.elf32_hexagon.o --split-dwo=%t.elf32_hexagon.dwo +# RUN: llvm-readobj --file-headers %t.elf32_hexagon.o | FileCheck %s --check-prefixes=CHECK,LE,HEXAGON,32,SYSV +# RUN: llvm-readobj --file-headers %t.elf32_hexagon.dwo | FileCheck %s --check-prefixes=CHECK,LE,HEXAGON,32,SYSV + !ELF FileHeader: Class: ELFCLASS32 @@ -139,6 +143,7 @@ # IAMCU-SAME: iamcu # AARCH-SAME: aarch64 # ARM-SAME: littlearm +# HEXAGON-SAME: hexagon # MIPS-SAME: mips # PPC-SAME: powerpc{{$}} # PPC64BE-SAME: powerpc{{$}} @@ -153,6 +158,7 @@ # IAMCU-NEXT: Arch: i386 # AARCH-NEXT: Arch: aarch64 # ARM-NEXT: Arch: arm +# HEXAGON-NEXT: Arch: hexagon # MIPSBE-NEXT: Arch: mips{{$}} # MIPSLE-NEXT: Arch: mipsel{{$}} # MIPS64BE-NEXT: Arch: mips64{{$}} @@ -181,6 +187,7 @@ # AARCH: Machine: EM_AARCH64 (0xB7) # ARM: Machine: EM_ARM (0x28) +# HEXAGON: Machine: EM_HEXAGON (0xA4) # I386: Machine: EM_386 (0x3) # IAMCU: Machine: EM_IAMCU (0x6) # MIPS: Machine: EM_MIPS (0x8) diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp --- a/llvm/tools/llvm-objcopy/CopyConfig.cpp +++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp @@ -273,6 +273,7 @@ // SPARC {"elf32-sparc", {ELF::EM_SPARC, false, false}}, {"elf32-sparcel", {ELF::EM_SPARC, false, true}}, + {"elf32-hexagon", {ELF::EM_HEXAGON, false, true}}, }; static Expected