1 # RUN: echo abcd > %t.txt
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
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
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
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
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
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
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
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
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
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
36 # AARCH64-SAME: aarch64-little
37 # ARM-SAME: arm-little
39 # MIPS-SAME: mips{{$}}
40 # RISCV32-SAME: riscv{{$}}
41 # RISCV64-SAME: riscv{{$}}
48 # AARCH64-NEXT: Arch: aarch64
50 # I386-NEXT: Arch: i386
51 # MIPS-NEXT: Arch: mips{{$}}
52 # PPC-NEXT: Arch: powerpc{{$}}
53 # PPC64-NEXT: Arch: powerpc64le
54 # RISCV32-NEXT: Arch: riscv32
55 # RISCV64-NEXT: Arch: riscv64
56 # SPARC-NEXT: Arch: sparc{{$}}
57 # SPARCEL-NEXT: Arch: sparcel
58 # X86-64-NEXT: Arch: x86_64
60 # 32-NEXT: AddressSize: 32bit
61 # 64-NEXT: AddressSize: 64bit
65 # CHECK-NEXT: Magic: (7F 45 4C 46)
66 # 32-NEXT: Class: 32-bit (0x1)
67 # 64-NEXT: Class: 64-bit (0x2)
68 # LE-NEXT: DataEncoding: LittleEndian (0x1)
69 # BE-NEXT: DataEncoding: BigEndian (0x2)
70 # CHECK-NEXT: FileVersion: 1
71 # CHECK-NEXT: OS/ABI: SystemV (0x0)
72 # CHECK-NEXT: ABIVersion: 0
73 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
75 # CHECK-NEXT: Type: Relocatable (0x1)
77 ## In GNU objcopy, e_machine is EM_NONE unless -B is specifid.
78 ## It is not very clear why it behaves this way.
79 ## We fill in the field regardless of -B.
80 # AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
81 # ARM-NEXT: Machine: EM_ARM (0x28)
82 # I386-NEXT: Machine: EM_386 (0x3)
83 # MIPS-NEXT: Machine: EM_MIPS (0x8)
84 # PPC-NEXT: Machine: EM_PPC (0x14)
85 # PPC64-NEXT: Machine: EM_PPC64 (0x15)
86 # RISCV32-NEXT: Machine: EM_RISCV (0xF3)
87 # RISCV64-NEXT: Machine: EM_RISCV (0xF3)
88 # SPARC-NEXT: Machine: EM_SPARC (0x2)
89 # SPARCEL-NEXT: Machine: EM_SPARC (0x2)
90 # X86-64-NEXT: Machine: EM_X86_64 (0x3E)
92 # CHECK-NEXT: Version: 1
93 # CHECK-NEXT: Entry: 0x0
94 # CHECK-NEXT: ProgramHeaderOffset:
95 # CHECK-NEXT: SectionHeaderOffset:
96 # CHECK-NEXT: Flags [ (0x0)
98 # 32-NEXT: HeaderSize: 52
99 # 64-NEXT: HeaderSize: 64
100 # 32-NEXT: ProgramHeaderEntrySize: 0
101 # 64-NEXT: ProgramHeaderEntrySize: 0
102 # CHECK-NEXT: ProgramHeaderCount: 0
103 # 32-NEXT: SectionHeaderEntrySize: 40
104 # 64-NEXT: SectionHeaderEntrySize: 64
105 # CHECK-NEXT: SectionHeaderCount: 4
106 # CHECK-NEXT: StringTableSectionIndex:
109 ## ELFOSABI_NONE = ELFOSABI_SYSV = 0 is the default.
110 ## "-freebsd" suffixed target name can change the field to ELFOSABI_FREEBSD.
112 ## Many uses of objcopy use no spaces in the flags, make sure that also works.
113 # RUN: llvm-objcopy -Ibinary -O elf64-x86-64-freebsd %t.txt %t.freebsd.o
114 # RUN: llvm-readobj --file-headers %t.freebsd.o | FileCheck %s --check-prefixes=FREEBSD
116 # FREEBSD: OS/ABI: FreeBSD