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
51 # RUN: llvm-objcopy -I binary -O elf64-s390 %t.txt %t.s390x.o
52 # RUN: llvm-readobj --file-headers %t.s390x.o | FileCheck %s --check-prefixes=CHECK,BE,S390X,64
57 # AARCH64-SAME: littleaarch64
59 # HEXAGON-SAME: hexagon
61 # LA32-SAME: loongarch{{$}}
62 # LA64-SAME: loongarch{{$}}
63 # MIPS-SAME: mips{{$}}
64 # RISCV32-SAME: riscv{{$}}
65 # RISCV64-SAME: riscv{{$}}
66 # PPCBE-SAME: powerpc{{$}}
67 # PPCLE-SAME: powerpcle{{$}}
73 # AARCH64-NEXT: Arch: aarch64
75 # HEXAGON-NEXT: Arch: hexagon
76 # I386-NEXT: Arch: i386
77 # LA32-NEXT: Arch: loongarch32
78 # LA64-NEXT: Arch: loongarch64
79 # MIPS-NEXT: Arch: mips{{$}}
80 # PPC32BE-NEXT: Arch: powerpc{{$}}
81 # PPC32LE-NEXT: Arch: powerpcle{{$}}
82 # PPC64BE-NEXT: Arch: powerpc64{{$}}
83 # PPC64LE-NEXT: Arch: powerpc64le{{$}}
84 # RISCV32-NEXT: Arch: riscv32
85 # RISCV64-NEXT: Arch: riscv64
86 # SPARC-NEXT: Arch: sparc{{$}}
87 # SPARCEL-NEXT: Arch: sparcel
88 # S390X-NEXT: Arch: s390x
89 # X86-64-NEXT: Arch: x86_64
91 # 32-NEXT: AddressSize: 32bit
92 # 64-NEXT: AddressSize: 64bit
96 # CHECK-NEXT: Magic: (7F 45 4C 46)
97 # 32-NEXT: Class: 32-bit (0x1)
98 # 64-NEXT: Class: 64-bit (0x2)
99 # LE-NEXT: DataEncoding: LittleEndian (0x1)
100 # BE-NEXT: DataEncoding: BigEndian (0x2)
101 # CHECK-NEXT: FileVersion: 1
102 # CHECK-NEXT: OS/ABI: SystemV (0x0)
103 # CHECK-NEXT: ABIVersion: 0
104 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
106 # CHECK-NEXT: Type: Relocatable (0x1)
108 ## In GNU objcopy, e_machine is EM_NONE unless -B is specifid.
109 ## It is not very clear why it behaves this way.
110 ## We fill in the field regardless of -B.
111 # AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
112 # ARM-NEXT: Machine: EM_ARM (0x28)
113 # HEXAGON-NEXT: Machine: EM_HEXAGON (0xA4)
114 # I386-NEXT: Machine: EM_386 (0x3)
115 # LA32-NEXT: Machine: EM_LOONGARCH (0x102)
116 # LA64-NEXT: Machine: EM_LOONGARCH (0x102)
117 # MIPS-NEXT: Machine: EM_MIPS (0x8)
118 # PPC32-NEXT: Machine: EM_PPC (0x14)
119 # PPC64-NEXT: Machine: EM_PPC64 (0x15)
120 # RISCV32-NEXT: Machine: EM_RISCV (0xF3)
121 # RISCV64-NEXT: Machine: EM_RISCV (0xF3)
122 # SPARC-NEXT: Machine: EM_SPARC (0x2)
123 # SPARCEL-NEXT: Machine: EM_SPARC (0x2)
124 # S390X-NEXT: Machine: EM_S390 (0x16)
125 # X86-64-NEXT: Machine: EM_X86_64 (0x3E)
127 # CHECK-NEXT: Version: 1
128 # CHECK-NEXT: Entry: 0x0
129 # CHECK-NEXT: ProgramHeaderOffset:
130 # CHECK-NEXT: SectionHeaderOffset:
131 # CHECK-NEXT: Flags [ (0x0)
133 # 32-NEXT: HeaderSize: 52
134 # 64-NEXT: HeaderSize: 64
135 # 32-NEXT: ProgramHeaderEntrySize: 0
136 # 64-NEXT: ProgramHeaderEntrySize: 0
137 # CHECK-NEXT: ProgramHeaderCount: 0
138 # 32-NEXT: SectionHeaderEntrySize: 40
139 # 64-NEXT: SectionHeaderEntrySize: 64
140 # CHECK-NEXT: SectionHeaderCount: 4
141 # CHECK-NEXT: StringTableSectionIndex:
144 ## ELFOSABI_NONE = ELFOSABI_SYSV = 0 is the default.
145 ## "-freebsd" suffixed target name can change the field to ELFOSABI_FREEBSD.
147 ## Many uses of objcopy use no spaces in the flags, make sure that also works.
148 # RUN: llvm-objcopy -Ibinary -O elf64-x86-64-freebsd %t.txt %t.freebsd.o
149 # RUN: llvm-readobj --file-headers %t.freebsd.o | FileCheck %s --check-prefixes=FREEBSD
151 # FREEBSD: OS/ABI: FreeBSD