1# RUN: echo abcd > %t.txt 2 3# RUN: llvm-objcopy -I binary -O elf64-littleaarch64 %t.txt %t.aarch64.o 4# RUN: llvm-readobj --file-headers %t.aarch64.o | FileCheck %s --check-prefixes=CHECK,LE,AARCH64,64 5 6# RUN: llvm-objcopy -I binary -O elf32-littlearm %t.txt %t.arm.o 7# RUN: llvm-readobj --file-headers %t.arm.o | FileCheck %s --check-prefixes=CHECK,LE,ARM,32 8 9# RUN: llvm-objcopy -I binary -O elf32-i386 %t.txt %t.i386.o 10# RUN: llvm-readobj --file-headers %t.i386.o | FileCheck %s --check-prefixes=CHECK,LE,I386,32 11 12# RUN: llvm-objcopy -I binary -O elf64-x86-64 %t.txt %t.x86-64.o 13# RUN: llvm-readobj --file-headers %t.x86-64.o | FileCheck %s --check-prefixes=CHECK,LE,X86-64,64 14 15# RUN: llvm-objcopy -I binary -O elf32-bigmips %t.txt %t.mips.o 16# RUN: llvm-readobj --file-headers %t.mips.o | FileCheck %s --check-prefixes=CHECK,BE,MIPS,32 17 18# RUN: llvm-objcopy -I binary -O elf64-powerpcle %t.txt %t.ppc64le.o 19# RUN: llvm-readobj --file-headers %t.ppc64le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64,64 20 21# RUN: llvm-objcopy -I binary -O elf32-littleriscv %t.txt %t.rv32.o 22# RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32 23 24# RUN: llvm-objcopy -I binary -O elf64-littleriscv %t.txt %t.rv64.o 25# RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64 26 27# RUN: llvm-objcopy -I binary -O elf32-sparc %t.txt %t.sparc.o 28# RUN: llvm-readobj --file-headers %t.sparc.o | FileCheck %s --check-prefixes=CHECK,BE,SPARC,32 29 30# RUN: llvm-objcopy -I binary -O elf32-sparcel %t.txt %t.sparcel.o 31# RUN: llvm-readobj --file-headers %t.sparcel.o | FileCheck %s --check-prefixes=CHECK,LE,SPARCEL,32 32 33# RUN: llvm-objcopy -I binary -O elf32-hexagon %t.txt %t.hexagon.o 34# RUN: llvm-readobj --file-headers %t.hexagon.o | FileCheck %s --check-prefixes=CHECK,LE,HEXAGON,32 35 36# CHECK: Format: 37# 32-SAME: elf32- 38# 64-SAME: elf64- 39# AARCH64-SAME: littleaarch64 40# ARM-SAME: littlearm 41# HEXAGON-SAME: hexagon 42# I386-SAME: i386 43# MIPS-SAME: mips{{$}} 44# RISCV32-SAME: riscv{{$}} 45# RISCV64-SAME: riscv{{$}} 46# PPC-SAME: powerpc{{$}} 47# PPC64le-SAME: powerpc{{$}} 48# SPARC-SAME: sparc 49# SPARCEL-SAME: sparc 50# X86-64-SAME: x86-64 51 52# AARCH64-NEXT: Arch: aarch64 53# ARM-NEXT: Arch: arm 54# HEXAGON-NEXT: Arch: hexagon 55# I386-NEXT: Arch: i386 56# MIPS-NEXT: Arch: mips{{$}} 57# PPC-NEXT: Arch: powerpc{{$}} 58# PPC64-NEXT: Arch: powerpc64le 59# RISCV32-NEXT: Arch: riscv32 60# RISCV64-NEXT: Arch: riscv64 61# SPARC-NEXT: Arch: sparc{{$}} 62# SPARCEL-NEXT: Arch: sparcel 63# X86-64-NEXT: Arch: x86_64 64 65# 32-NEXT: AddressSize: 32bit 66# 64-NEXT: AddressSize: 64bit 67 68# CHECK: ElfHeader { 69# CHECK-NEXT: Ident { 70# CHECK-NEXT: Magic: (7F 45 4C 46) 71# 32-NEXT: Class: 32-bit (0x1) 72# 64-NEXT: Class: 64-bit (0x2) 73# LE-NEXT: DataEncoding: LittleEndian (0x1) 74# BE-NEXT: DataEncoding: BigEndian (0x2) 75# CHECK-NEXT: FileVersion: 1 76# CHECK-NEXT: OS/ABI: SystemV (0x0) 77# CHECK-NEXT: ABIVersion: 0 78# CHECK-NEXT: Unused: (00 00 00 00 00 00 00) 79# CHECK-NEXT: } 80# CHECK-NEXT: Type: Relocatable (0x1) 81 82## In GNU objcopy, e_machine is EM_NONE unless -B is specifid. 83## It is not very clear why it behaves this way. 84## We fill in the field regardless of -B. 85# AARCH64-NEXT: Machine: EM_AARCH64 (0xB7) 86# ARM-NEXT: Machine: EM_ARM (0x28) 87# HEXAGON-NEXT: Machine: EM_HEXAGON (0xA4) 88# I386-NEXT: Machine: EM_386 (0x3) 89# MIPS-NEXT: Machine: EM_MIPS (0x8) 90# PPC-NEXT: Machine: EM_PPC (0x14) 91# PPC64-NEXT: Machine: EM_PPC64 (0x15) 92# RISCV32-NEXT: Machine: EM_RISCV (0xF3) 93# RISCV64-NEXT: Machine: EM_RISCV (0xF3) 94# SPARC-NEXT: Machine: EM_SPARC (0x2) 95# SPARCEL-NEXT: Machine: EM_SPARC (0x2) 96# X86-64-NEXT: Machine: EM_X86_64 (0x3E) 97 98# CHECK-NEXT: Version: 1 99# CHECK-NEXT: Entry: 0x0 100# CHECK-NEXT: ProgramHeaderOffset: 101# CHECK-NEXT: SectionHeaderOffset: 102# CHECK-NEXT: Flags [ (0x0) 103# CHECK-NEXT: ] 104# 32-NEXT: HeaderSize: 52 105# 64-NEXT: HeaderSize: 64 106# 32-NEXT: ProgramHeaderEntrySize: 0 107# 64-NEXT: ProgramHeaderEntrySize: 0 108# CHECK-NEXT: ProgramHeaderCount: 0 109# 32-NEXT: SectionHeaderEntrySize: 40 110# 64-NEXT: SectionHeaderEntrySize: 64 111# CHECK-NEXT: SectionHeaderCount: 4 112# CHECK-NEXT: StringTableSectionIndex: 113# CHECK-NEXT: } 114 115## ELFOSABI_NONE = ELFOSABI_SYSV = 0 is the default. 116## "-freebsd" suffixed target name can change the field to ELFOSABI_FREEBSD. 117 118## Many uses of objcopy use no spaces in the flags, make sure that also works. 119# RUN: llvm-objcopy -Ibinary -O elf64-x86-64-freebsd %t.txt %t.freebsd.o 120# RUN: llvm-readobj --file-headers %t.freebsd.o | FileCheck %s --check-prefixes=FREEBSD 121 122# FREEBSD: OS/ABI: FreeBSD 123