llvm.org GIT mirror llvm / b1f70e7
[llvm-objcopy] Add RISC-V support for -B/-O Reviewers: jorgbrown, espindola, alexshap, jhenderson Subscribers: emaste, arichardson, fedor.sergeev, jakehehrlich, kito-cheng, shiva0217, MaskRay, rogfer01, rkruppe, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61272 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359568 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rupprecht 1 year, 5 months ago
3 changed file(s) with 58 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
1717 # RUN: llvm-objcopy -I binary -B powerpc:common64 %t.txt %t.powerpc_common64.o
1818 # RUN: llvm-readobj --file-headers %t.powerpc_common64.o | FileCheck %s --check-prefixes=CHECK,LE,PPC,64
1919
20 # RUN: llvm-objcopy -I binary -B riscv:rv32 %t.txt %t.rv32.o
21 # RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32
22
23 # RUN: llvm-objcopy -I binary -B riscv:rv64 %t.txt %t.rv64.o
24 # RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64
25
2026 # RUN: llvm-objcopy -I binary -B sparc %t.txt %t.sparc.o
2127 # RUN: llvm-readobj --file-headers %t.sparc.o | FileCheck %s --check-prefixes=CHECK,LE,SPARC,32
2228
2430 # RUN: llvm-readobj --file-headers %t.x86-64.o | FileCheck %s --check-prefixes=CHECK,LE,X86-64,64
2531
2632 # CHECK: Format:
27 # AARCH64-SAME: ELF64-aarch64-little
28 # ARM-SAME: ELF32-arm-little
29 # I386-SAME: ELF32-i386
30 # MIPS-SAME: ELF32-mips{{$}}
31 # PPC-SAME: ELF64-ppc64
32 # SPARC-SAME: ELF32-sparc
33 # X86-64-SAME: ELF64-x86-64
33 # 32-SAME: ELF32-
34 # 64-SAME: ELF64-
35 # AARCH64-SAME: aarch64-little
36 # ARM-SAME: arm-little
37 # I386-SAME: i386
38 # MIPS-SAME: mips{{$}}
39 # RISCV32-SAME: riscv{{$}}
40 # RISCV64-SAME: riscv{{$}}
41 # PPC-SAME: ppc64
42 # SPARC-SAME: sparc
43 # X86-64-SAME: x86-64
3444
3545 # AARCH64-NEXT: Arch: aarch64
3646 # ARM-NEXT: Arch: arm
3747 # I386-NEXT: Arch: i386
3848 # MIPS-NEXT: Arch: mips{{$$}}
3949 # PPC-NEXT: Arch: powerpc64le
50 # RISCV32-NEXT: Arch: riscv32
51 # RISCV64-NEXT: Arch: riscv64
4052 # SPARC-NEXT: Arch: sparcel
4153 # X86-64-NEXT: Arch: x86_64
4254
6173 # I386-NEXT: Machine: EM_386 (0x3)
6274 # MIPS-NEXT: Machine: EM_MIPS (0x8)
6375 # PPC-NEXT: Machine: EM_PPC64 (0x15)
76 # RISCV32-NEXT: Machine: EM_RISCV (0xF3)
77 # RISCV64-NEXT: Machine: EM_RISCV (0xF3)
6478 # SPARC-NEXT: Machine: EM_SPARC (0x2)
6579 # X86-64-NEXT: Machine: EM_X86_64 (0x3E)
6680 # CHECK-NEXT: Version: 1
5151 # RUN: llvm-objcopy %t.o -O elf64-powerpcle %t.elf64_ppcle.o --split-dwo=%t.elf64_ppcle.dwo
5252 # RUN: llvm-readobj --file-headers %t.elf64_ppcle.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64LE,64,SYSV
5353 # RUN: llvm-readobj --file-headers %t.elf64_ppcle.dwo | FileCheck %s --check-prefixes=CHECK,LE,PPC64LE,64,SYSV
54
55 # RUN: llvm-objcopy %t.o -O elf32-littleriscv %t.elf32_littleriscv.o --split-dwo=%t.elf32_littleriscv.dwo
56 # RUN: llvm-readobj --file-headers %t.elf32_littleriscv.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32,SYSV
57 # RUN: llvm-readobj --file-headers %t.elf32_littleriscv.dwo | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32,SYSV
58
59 # RUN: llvm-objcopy %t.o -O elf64-littleriscv %t.elf64_littleriscv.o --split-dwo=%t.elf64_littleriscv.dwo
60 # RUN: llvm-readobj --file-headers %t.elf64_littleriscv.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64,SYSV
61 # RUN: llvm-readobj --file-headers %t.elf64_littleriscv.dwo | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64,SYSV
5462
5563 # RUN: llvm-objcopy %t.o -O elf64-x86-64 %t.elf64_x86_64.o --split-dwo=%t.elf64_x86_64.dwo
5664 # RUN: llvm-readobj --file-headers %t.elf64_x86_64.o | FileCheck %s --check-prefixes=CHECK,LE,X86-64,64,SYSV
126134 # PPC-SAME: ppc{{$}}
127135 # PPC64BE-SAME: ppc64{{$}}
128136 # PPC64LE-SAME: ppc64{{$}}
137 # RISCV32-SAME: riscv{{$}}
138 # RISCV64-SAME: riscv{{$}}
129139 # X86-64-SAME: x86-64
130140 # DEFAULT-SAME: unknown
131141
140150 # PPC-NEXT: Arch: powerpc{{$}}
141151 # PPC64BE-NEXT: Arch: powerpc64{{$}}
142152 # PPC64LE-NEXT: Arch: powerpc64le
153 # RISCV32-NEXT: Arch: riscv32
154 # RISCV64-NEXT: Arch: riscv64
143155 # X86-64-NEXT: Arch: x86_64
144156 # DEFAULT-NEXT: Arch: unknown
145157
155167 # FREEBSD: OS/ABI: FreeBSD (0x9)
156168 # DEFAULT: OS/ABI: Standalone (0xFF)
157169
158 # AARCH: Machine: EM_AARCH64 (0xB7)
159 # ARM: Machine: EM_ARM (0x28)
160 # I386: Machine: EM_386 (0x3)
161 # IAMCU: Machine: EM_IAMCU (0x6)
162 # MIPS: Machine: EM_MIPS (0x8)
163 # PPC: Machine: EM_PPC (0x14)
164 # PPC64: Machine: EM_PPC64 (0x15)
165 # X86-64: Machine: EM_X86_64 (0x3E)
170 # AARCH: Machine: EM_AARCH64 (0xB7)
171 # ARM: Machine: EM_ARM (0x28)
172 # I386: Machine: EM_386 (0x3)
173 # IAMCU: Machine: EM_IAMCU (0x6)
174 # MIPS: Machine: EM_MIPS (0x8)
175 # PPC: Machine: EM_PPC (0x14)
176 # PPC64: Machine: EM_PPC64 (0x15)
177 # RISCV32: Machine: EM_RISCV (0xF3)
178 # RISCV64: Machine: EM_RISCV (0xF3)
179 # X86-64: Machine: EM_X86_64 (0x3E)
166180
167181 # 32: HeaderSize: 52
168182 # 64: HeaderSize: 64
259259 {"i386:x86-64", {ELF::EM_X86_64, true, true}},
260260 {"mips", {ELF::EM_MIPS, false, false}},
261261 {"powerpc:common64", {ELF::EM_PPC64, true, true}},
262 {"riscv:rv32", {ELF::EM_RISCV, false, true}},
263 {"riscv:rv64", {ELF::EM_RISCV, true, true}},
262264 {"sparc", {ELF::EM_SPARC, false, true}},
263265 {"x86-64", {ELF::EM_X86_64, true, true}},
264266 };
274276 // FIXME: consolidate with the bfd parsing used by lld.
275277 static const StringMap OutputFormatMap{
276278 // Name, {EMachine, 64bit, LittleEndian}
279 // x86
277280 {"elf32-i386", {ELF::EM_386, false, true}},
281 {"elf32-x86-64", {ELF::EM_X86_64, false, true}},
282 {"elf64-x86-64", {ELF::EM_X86_64, true, true}},
283 // Intel MCU
278284 {"elf32-iamcu", {ELF::EM_IAMCU, false, true}},
285 // ARM
279286 {"elf32-littlearm", {ELF::EM_ARM, false, true}},
280 {"elf32-x86-64", {ELF::EM_X86_64, false, true}},
287 // ARM AArch64
281288 {"elf64-aarch64", {ELF::EM_AARCH64, true, true}},
282289 {"elf64-littleaarch64", {ELF::EM_AARCH64, true, true}},
290 // RISC-V
291 {"elf32-littleriscv", {ELF::EM_RISCV, false, true}},
292 {"elf64-littleriscv", {ELF::EM_RISCV, true, true}},
293 // PowerPC
283294 {"elf32-powerpc", {ELF::EM_PPC, false, false}},
284295 {"elf32-powerpcle", {ELF::EM_PPC, false, true}},
285296 {"elf64-powerpc", {ELF::EM_PPC64, true, false}},
286297 {"elf64-powerpcle", {ELF::EM_PPC64, true, true}},
287 {"elf64-x86-64", {ELF::EM_X86_64, true, true}},
288 {"elf32-tradbigmips", {ELF::EM_MIPS, false, false}},
298 // MIPS
289299 {"elf32-bigmips", {ELF::EM_MIPS, false, false}},
290300 {"elf32-ntradbigmips", {ELF::EM_MIPS, false, false}},
301 {"elf32-ntradlittlemips", {ELF::EM_MIPS, false, true}},
302 {"elf32-tradbigmips", {ELF::EM_MIPS, false, false}},
291303 {"elf32-tradlittlemips", {ELF::EM_MIPS, false, true}},
292 {"elf32-ntradlittlemips", {ELF::EM_MIPS, false, true}},
293304 {"elf64-tradbigmips", {ELF::EM_MIPS, true, false}},
294305 {"elf64-tradlittlemips", {ELF::EM_MIPS, true, true}},
295306 };