1 //===- llvm/BinaryFormat/ELF.cpp - The ELF format ---------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/BinaryFormat/ELF.h"
10 #include "llvm/ADT/StringSwitch.h"
15 /// Convert an architecture name into ELF's e_machine value.
16 uint16_t ELF::convertArchNameToEMachine(StringRef Arch
) {
17 std::string LowerArch
= Arch
.lower();
18 return StringSwitch
<uint16_t>(LowerArch
)
19 .Case("none", EM_NONE
)
21 .Case("sparc", EM_SPARC
)
25 .Case("iamcu", EM_IAMCU
)
27 .Case("mips", EM_MIPS
)
28 .Case("s370", EM_S370
)
29 .Case("mips_rs3_le", EM_MIPS_RS3_LE
)
30 .Case("parisc", EM_PARISC
)
31 .Case("vpp500", EM_VPP500
)
32 .Case("sparc32plus", EM_SPARC32PLUS
)
35 .Case("ppc64", EM_PPC64
)
36 .Case("s390", EM_S390
)
38 .Case("v800", EM_V800
)
39 .Case("fr20", EM_FR20
)
40 .Case("rh32", EM_RH32
)
43 .Case("alpha", EM_ALPHA
)
45 .Case("sparcv9", EM_SPARCV9
)
46 .Case("tricore", EM_TRICORE
)
48 .Case("h8_300", EM_H8_300
)
49 .Case("h8_300h", EM_H8_300H
)
51 .Case("h8_500", EM_H8_500
)
52 .Case("ia_64", EM_IA_64
)
53 .Case("mips_x", EM_MIPS_X
)
54 .Case("coldfire", EM_COLDFIRE
)
55 .Case("68hc12", EM_68HC12
)
58 .Case("ncpu", EM_NCPU
)
59 .Case("ndr1", EM_NDR1
)
60 .Case("starcore", EM_STARCORE
)
61 .Case("me16", EM_ME16
)
62 .Case("st100", EM_ST100
)
63 .Case("tinyj", EM_TINYJ
)
64 .Case("x86_64", EM_X86_64
)
65 .Case("pdsp", EM_PDSP
)
66 .Case("pdp10", EM_PDP10
)
67 .Case("pdp11", EM_PDP11
)
68 .Case("fx66", EM_FX66
)
69 .Case("st9plus", EM_ST9PLUS
)
71 .Case("68hc16", EM_68HC16
)
72 .Case("68hc11", EM_68HC11
)
73 .Case("68hc08", EM_68HC08
)
74 .Case("68hc05", EM_68HC05
)
76 .Case("st19", EM_ST19
)
78 .Case("cris", EM_CRIS
)
79 .Case("javelin", EM_JAVELIN
)
80 .Case("firepath", EM_FIREPATH
)
82 .Case("mmix", EM_MMIX
)
83 .Case("huany", EM_HUANY
)
84 .Case("prism", EM_PRISM
)
86 .Case("fr30", EM_FR30
)
87 .Case("d10v", EM_D10V
)
88 .Case("d30v", EM_D30V
)
89 .Case("v850", EM_V850
)
90 .Case("m32r", EM_M32R
)
91 .Case("mn10300", EM_MN10300
)
92 .Case("mn10200", EM_MN10200
)
94 .Case("openrisc", EM_OPENRISC
)
95 .Case("arc_compact", EM_ARC_COMPACT
)
96 .Case("xtensa", EM_XTENSA
)
97 .Case("videocore", EM_VIDEOCORE
)
98 .Case("tmm_gpp", EM_TMM_GPP
)
99 .Case("ns32k", EM_NS32K
)
101 .Case("snp1k", EM_SNP1K
)
102 .Case("st200", EM_ST200
)
103 .Case("ip2k", EM_IP2K
)
106 .Case("f2mc16", EM_F2MC16
)
107 .Case("msp430", EM_MSP430
)
108 .Case("blackfin", EM_BLACKFIN
)
109 .Case("se_c33", EM_SE_C33
)
111 .Case("arca", EM_ARCA
)
112 .Case("unicore", EM_UNICORE
)
113 .Case("excess", EM_EXCESS
)
115 .Case("altera_nios2", EM_ALTERA_NIOS2
)
117 .Case("xgate", EM_XGATE
)
118 .Case("c166", EM_C166
)
119 .Case("m16c", EM_M16C
)
120 .Case("dspic30f", EM_DSPIC30F
)
122 .Case("m32c", EM_M32C
)
123 .Case("tsk3000", EM_TSK3000
)
124 .Case("rs08", EM_RS08
)
125 .Case("sharc", EM_SHARC
)
126 .Case("ecog2", EM_ECOG2
)
127 .Case("score7", EM_SCORE7
)
128 .Case("dsp24", EM_DSP24
)
129 .Case("videocore3", EM_VIDEOCORE3
)
130 .Case("latticemico32", EM_LATTICEMICO32
)
131 .Case("se_c17", EM_SE_C17
)
132 .Case("ti_c6000", EM_TI_C6000
)
133 .Case("ti_c2000", EM_TI_C2000
)
134 .Case("ti_c5500", EM_TI_C5500
)
135 .Case("mmdsp_plus", EM_MMDSP_PLUS
)
136 .Case("cypress_m8c", EM_CYPRESS_M8C
)
137 .Case("r32c", EM_R32C
)
138 .Case("trimedia", EM_TRIMEDIA
)
139 .Case("hexagon", EM_HEXAGON
)
140 .Case("8051", EM_8051
)
141 .Case("stxp7x", EM_STXP7X
)
142 .Case("nds32", EM_NDS32
)
143 .Case("ecog1", EM_ECOG1
)
144 .Case("ecog1x", EM_ECOG1X
)
145 .Case("maxq30", EM_MAXQ30
)
146 .Case("ximo16", EM_XIMO16
)
147 .Case("manik", EM_MANIK
)
148 .Case("craynv2", EM_CRAYNV2
)
150 .Case("metag", EM_METAG
)
151 .Case("mcst_elbrus", EM_MCST_ELBRUS
)
152 .Case("ecog16", EM_ECOG16
)
153 .Case("cr16", EM_CR16
)
154 .Case("etpu", EM_ETPU
)
155 .Case("sle9x", EM_SLE9X
)
156 .Case("l10m", EM_L10M
)
157 .Case("k10m", EM_K10M
)
158 .Case("aarch64", EM_AARCH64
)
159 .Case("avr32", EM_AVR32
)
160 .Case("stm8", EM_STM8
)
161 .Case("tile64", EM_TILE64
)
162 .Case("tilepro", EM_TILEPRO
)
163 .Case("cuda", EM_CUDA
)
164 .Case("tilegx", EM_TILEGX
)
165 .Case("cloudshield", EM_CLOUDSHIELD
)
166 .Case("corea_1st", EM_COREA_1ST
)
167 .Case("corea_2nd", EM_COREA_2ND
)
168 .Case("arc_compact2", EM_ARC_COMPACT2
)
169 .Case("open8", EM_OPEN8
)
170 .Case("rl78", EM_RL78
)
171 .Case("videocore5", EM_VIDEOCORE5
)
172 .Case("78kor", EM_78KOR
)
173 .Case("56800ex", EM_56800EX
)
176 .Case("xcore", EM_XCORE
)
177 .Case("mchp_pic", EM_MCHP_PIC
)
178 .Case("intel205", EM_INTEL205
)
179 .Case("intel206", EM_INTEL206
)
180 .Case("intel207", EM_INTEL207
)
181 .Case("intel208", EM_INTEL208
)
182 .Case("intel209", EM_INTEL209
)
183 .Case("km32", EM_KM32
)
184 .Case("kmx32", EM_KMX32
)
185 .Case("kmx16", EM_KMX16
)
186 .Case("kmx8", EM_KMX8
)
187 .Case("kvarc", EM_KVARC
)
189 .Case("coge", EM_COGE
)
190 .Case("cool", EM_COOL
)
191 .Case("norc", EM_NORC
)
192 .Case("csr_kalimba", EM_CSR_KALIMBA
)
193 .Case("amdgpu", EM_AMDGPU
)
194 .Case("riscv", EM_RISCV
)
195 .Case("lanai", EM_LANAI
)
198 .Case("csky", EM_CSKY
)
199 .Case("loongarch", EM_LOONGARCH
)
203 /// Convert an ELF's e_machine value into an architecture name.
204 StringRef
ELF::convertEMachineToArchName(uint16_t EMachine
) {
227 return "mips_rs3_le";
233 return "sparc32plus";
359 return "arc_compact";
398 case EM_ALTERA_NIOS2
:
399 return "altera_nios2";
428 case EM_LATTICEMICO32
:
429 return "latticemico32";
441 return "cypress_m8c";
469 return "mcst_elbrus";
497 return "cloudshield";
502 case EM_ARC_COMPACT2
:
503 return "arc_compact2";
551 return "csr_kalimba";