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 elf32-powerpc %t.txt %t.ppc32be.o
19 # RUN: llvm-readobj --file-headers %t.ppc32be.o | FileCheck %s --check-prefixes=CHECK,BE,PPC32,PPC32BE,32
21 # RUN: llvm-objcopy -I binary -O elf32-powerpcle %t.txt %t.ppc32le.o
22 # RUN: llvm-readobj --file-headers %t.ppc32le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC32,PPC32LE,32
24 # RUN: llvm-objcopy -I binary -O elf64-powerpc %t.txt %t.ppc64be.o
25 # RUN: llvm-readobj --file-headers %t.ppc64be.o | FileCheck %s --check-prefixes=CHECK,BE,PPC64,PPC64BE,64
27 # RUN: llvm-objcopy -I binary -O elf64-powerpcle %t.txt %t.ppc64le.o
28 # RUN: llvm-readobj --file-headers %t.ppc64le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64,PPC64LE,64
30 # RUN: llvm-objcopy -I binary -O elf32-littleriscv %t.txt %t.rv32.o
31 # RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32
33 # RUN: llvm-objcopy -I binary -O elf64-littleriscv %t.txt %t.rv64.o
34 # RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64
36 # RUN: llvm-objcopy -I binary -O elf32-sparc %t.txt %t.sparc.o
37 # RUN: llvm-readobj --file-headers %t.sparc.o | FileCheck %s --check-prefixes=CHECK,BE,SPARC,32
39 # RUN: llvm-objcopy -I binary -O elf32-sparcel %t.txt %t.sparcel.o
40 # RUN: llvm-readobj --file-headers %t.sparcel.o | FileCheck %s --check-prefixes=CHECK,LE,SPARCEL,32
42 # RUN: llvm-objcopy -I binary -O elf32-hexagon %t.txt %t.hexagon.o
43 # RUN: llvm-readobj --file-headers %t.hexagon.o | FileCheck %s --check-prefixes=CHECK,LE,HEXAGON,32
45 # RUN: llvm-objcopy -I binary -O elf32-loongarch %t.txt %t.la32.o
46 # RUN: llvm-readobj --file-headers %t.la32.o | FileCheck %s --check-prefixes=CHECK,LE,LA32,32
48 # RUN: llvm-objcopy -I binary -O elf64-loongarch %t.txt %t.la64.o
49 # RUN: llvm-readobj --file-headers %t.la64.o | FileCheck %s --check-prefixes=CHECK,LE,LA64,64
54 # AARCH64-SAME: littleaarch64
56 # HEXAGON-SAME: hexagon
58 # LA32-SAME: loongarch{{$}}
59 # LA64-SAME: loongarch{{$}}
60 # MIPS-SAME: mips{{$}}
61 # RISCV32-SAME: riscv{{$}}
62 # RISCV64-SAME: riscv{{$}}
63 # PPCBE-SAME: powerpc{{$}}
64 # PPCLE-SAME: powerpcle{{$}}
69 # AARCH64-NEXT: Arch: aarch64
71 # HEXAGON-NEXT: Arch: hexagon
72 # I386-NEXT: Arch: i386
73 # LA32-NEXT: Arch: loongarch32
74 # LA64-NEXT: Arch: loongarch64
75 # MIPS-NEXT: Arch: mips{{$}}
76 # PPC32BE-NEXT: Arch: powerpc{{$}}
77 # PPC32LE-NEXT: Arch: powerpcle{{$}}
78 # PPC64BE-NEXT: Arch: powerpc64{{$}}
79 # PPC64LE-NEXT: Arch: powerpc64le{{$}}
80 # RISCV32-NEXT: Arch: riscv32
81 # RISCV64-NEXT: Arch: riscv64
82 # SPARC-NEXT: Arch: sparc{{$}}
83 # SPARCEL-NEXT: Arch: sparcel
84 # X86-64-NEXT: Arch: x86_64
86 # 32-NEXT: AddressSize: 32bit
87 # 64-NEXT: AddressSize: 64bit
91 # CHECK-NEXT: Magic: (7F 45 4C 46)
92 # 32-NEXT: Class: 32-bit (0x1)
93 # 64-NEXT: Class: 64-bit (0x2)
94 # LE-NEXT: DataEncoding: LittleEndian (0x1)
95 # BE-NEXT: DataEncoding: BigEndian (0x2)
96 # CHECK-NEXT: FileVersion: 1
97 # CHECK-NEXT: OS/ABI: SystemV (0x0)
98 # CHECK-NEXT: ABIVersion: 0
99 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
101 # CHECK-NEXT: Type: Relocatable (0x1)
103 ## In GNU objcopy, e_machine is EM_NONE unless -B is specifid.
104 ## It is not very clear why it behaves this way.
105 ## We fill in the field regardless of -B.
106 # AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
107 # ARM-NEXT: Machine: EM_ARM (0x28)
108 # HEXAGON-NEXT: Machine: EM_HEXAGON (0xA4)
109 # I386-NEXT: Machine: EM_386 (0x3)
110 # LA32-NEXT: Machine: EM_LOONGARCH (0x102)
111 # LA64-NEXT: Machine: EM_LOONGARCH (0x102)
112 # MIPS-NEXT: Machine: EM_MIPS (0x8)
113 # PPC32-NEXT: Machine: EM_PPC (0x14)
114 # PPC64-NEXT: Machine: EM_PPC64 (0x15)
115 # RISCV32-NEXT: Machine: EM_RISCV (0xF3)
116 # RISCV64-NEXT: Machine: EM_RISCV (0xF3)
117 # SPARC-NEXT: Machine: EM_SPARC (0x2)
118 # SPARCEL-NEXT: Machine: EM_SPARC (0x2)
119 # X86-64-NEXT: Machine: EM_X86_64 (0x3E)
121 # CHECK-NEXT: Version: 1
122 # CHECK-NEXT: Entry: 0x0
123 # CHECK-NEXT: ProgramHeaderOffset:
124 # CHECK-NEXT: SectionHeaderOffset:
125 # CHECK-NEXT: Flags [ (0x0)
127 # 32-NEXT: HeaderSize: 52
128 # 64-NEXT: HeaderSize: 64
129 # 32-NEXT: ProgramHeaderEntrySize: 0
130 # 64-NEXT: ProgramHeaderEntrySize: 0
131 # CHECK-NEXT: ProgramHeaderCount: 0
132 # 32-NEXT: SectionHeaderEntrySize: 40
133 # 64-NEXT: SectionHeaderEntrySize: 64
134 # CHECK-NEXT: SectionHeaderCount: 4
135 # CHECK-NEXT: StringTableSectionIndex:
138 ## ELFOSABI_NONE = ELFOSABI_SYSV = 0 is the default.
139 ## "-freebsd" suffixed target name can change the field to ELFOSABI_FREEBSD.
141 ## Many uses of objcopy use no spaces in the flags, make sure that also works.
142 # RUN: llvm-objcopy -Ibinary -O elf64-x86-64-freebsd %t.txt %t.freebsd.o
143 # RUN: llvm-readobj --file-headers %t.freebsd.o | FileCheck %s --check-prefixes=FREEBSD
145 # FREEBSD: OS/ABI: FreeBSD