1 | //===- llvm/BinaryFormat/ELF.cpp - The ELF format ---------------*- C++ -*-===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "llvm/BinaryFormat/ELF.h" |
10 | #include "llvm/ADT/StringSwitch.h" |
11 | |
12 | using namespace llvm; |
13 | using namespace ELF; |
14 | |
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(S: "none" , Value: EM_NONE) |
20 | .Case(S: "m32" , Value: EM_M32) |
21 | .Case(S: "sparc" , Value: EM_SPARC) |
22 | .Case(S: "386" , Value: EM_386) |
23 | .Case(S: "68k" , Value: EM_68K) |
24 | .Case(S: "88k" , Value: EM_88K) |
25 | .Case(S: "iamcu" , Value: EM_IAMCU) |
26 | .Case(S: "860" , Value: EM_860) |
27 | .Case(S: "mips" , Value: EM_MIPS) |
28 | .Case(S: "s370" , Value: EM_S370) |
29 | .Case(S: "mips_rs3_le" , Value: EM_MIPS_RS3_LE) |
30 | .Case(S: "parisc" , Value: EM_PARISC) |
31 | .Case(S: "vpp500" , Value: EM_VPP500) |
32 | .Case(S: "sparc32plus" , Value: EM_SPARC32PLUS) |
33 | .Case(S: "960" , Value: EM_960) |
34 | .Case(S: "ppc" , Value: EM_PPC) |
35 | .Case(S: "ppc64" , Value: EM_PPC64) |
36 | .Case(S: "s390" , Value: EM_S390) |
37 | .Case(S: "spu" , Value: EM_SPU) |
38 | .Case(S: "v800" , Value: EM_V800) |
39 | .Case(S: "fr20" , Value: EM_FR20) |
40 | .Case(S: "rh32" , Value: EM_RH32) |
41 | .Case(S: "rce" , Value: EM_RCE) |
42 | .Case(S: "arm" , Value: EM_ARM) |
43 | .Case(S: "alpha" , Value: EM_ALPHA) |
44 | .Case(S: "sh" , Value: EM_SH) |
45 | .Case(S: "sparcv9" , Value: EM_SPARCV9) |
46 | .Case(S: "tricore" , Value: EM_TRICORE) |
47 | .Case(S: "arc" , Value: EM_ARC) |
48 | .Case(S: "h8_300" , Value: EM_H8_300) |
49 | .Case(S: "h8_300h" , Value: EM_H8_300H) |
50 | .Case(S: "h8s" , Value: EM_H8S) |
51 | .Case(S: "h8_500" , Value: EM_H8_500) |
52 | .Case(S: "ia_64" , Value: EM_IA_64) |
53 | .Case(S: "mips_x" , Value: EM_MIPS_X) |
54 | .Case(S: "coldfire" , Value: EM_COLDFIRE) |
55 | .Case(S: "68hc12" , Value: EM_68HC12) |
56 | .Case(S: "mma" , Value: EM_MMA) |
57 | .Case(S: "pcp" , Value: EM_PCP) |
58 | .Case(S: "ncpu" , Value: EM_NCPU) |
59 | .Case(S: "ndr1" , Value: EM_NDR1) |
60 | .Case(S: "starcore" , Value: EM_STARCORE) |
61 | .Case(S: "me16" , Value: EM_ME16) |
62 | .Case(S: "st100" , Value: EM_ST100) |
63 | .Case(S: "tinyj" , Value: EM_TINYJ) |
64 | .Case(S: "x86_64" , Value: EM_X86_64) |
65 | .Case(S: "pdsp" , Value: EM_PDSP) |
66 | .Case(S: "pdp10" , Value: EM_PDP10) |
67 | .Case(S: "pdp11" , Value: EM_PDP11) |
68 | .Case(S: "fx66" , Value: EM_FX66) |
69 | .Case(S: "st9plus" , Value: EM_ST9PLUS) |
70 | .Case(S: "st7" , Value: EM_ST7) |
71 | .Case(S: "68hc16" , Value: EM_68HC16) |
72 | .Case(S: "68hc11" , Value: EM_68HC11) |
73 | .Case(S: "68hc08" , Value: EM_68HC08) |
74 | .Case(S: "68hc05" , Value: EM_68HC05) |
75 | .Case(S: "svx" , Value: EM_SVX) |
76 | .Case(S: "st19" , Value: EM_ST19) |
77 | .Case(S: "vax" , Value: EM_VAX) |
78 | .Case(S: "cris" , Value: EM_CRIS) |
79 | .Case(S: "javelin" , Value: EM_JAVELIN) |
80 | .Case(S: "firepath" , Value: EM_FIREPATH) |
81 | .Case(S: "zsp" , Value: EM_ZSP) |
82 | .Case(S: "mmix" , Value: EM_MMIX) |
83 | .Case(S: "huany" , Value: EM_HUANY) |
84 | .Case(S: "prism" , Value: EM_PRISM) |
85 | .Case(S: "avr" , Value: EM_AVR) |
86 | .Case(S: "fr30" , Value: EM_FR30) |
87 | .Case(S: "d10v" , Value: EM_D10V) |
88 | .Case(S: "d30v" , Value: EM_D30V) |
89 | .Case(S: "v850" , Value: EM_V850) |
90 | .Case(S: "m32r" , Value: EM_M32R) |
91 | .Case(S: "mn10300" , Value: EM_MN10300) |
92 | .Case(S: "mn10200" , Value: EM_MN10200) |
93 | .Case(S: "pj" , Value: EM_PJ) |
94 | .Case(S: "openrisc" , Value: EM_OPENRISC) |
95 | .Case(S: "arc_compact" , Value: EM_ARC_COMPACT) |
96 | .Case(S: "xtensa" , Value: EM_XTENSA) |
97 | .Case(S: "videocore" , Value: EM_VIDEOCORE) |
98 | .Case(S: "tmm_gpp" , Value: EM_TMM_GPP) |
99 | .Case(S: "ns32k" , Value: EM_NS32K) |
100 | .Case(S: "tpc" , Value: EM_TPC) |
101 | .Case(S: "snp1k" , Value: EM_SNP1K) |
102 | .Case(S: "st200" , Value: EM_ST200) |
103 | .Case(S: "ip2k" , Value: EM_IP2K) |
104 | .Case(S: "max" , Value: EM_MAX) |
105 | .Case(S: "cr" , Value: EM_CR) |
106 | .Case(S: "f2mc16" , Value: EM_F2MC16) |
107 | .Case(S: "msp430" , Value: EM_MSP430) |
108 | .Case(S: "blackfin" , Value: EM_BLACKFIN) |
109 | .Case(S: "se_c33" , Value: EM_SE_C33) |
110 | .Case(S: "sep" , Value: EM_SEP) |
111 | .Case(S: "arca" , Value: EM_ARCA) |
112 | .Case(S: "unicore" , Value: EM_UNICORE) |
113 | .Case(S: "excess" , Value: EM_EXCESS) |
114 | .Case(S: "dxp" , Value: EM_DXP) |
115 | .Case(S: "altera_nios2" , Value: EM_ALTERA_NIOS2) |
116 | .Case(S: "crx" , Value: EM_CRX) |
117 | .Case(S: "xgate" , Value: EM_XGATE) |
118 | .Case(S: "c166" , Value: EM_C166) |
119 | .Case(S: "m16c" , Value: EM_M16C) |
120 | .Case(S: "dspic30f" , Value: EM_DSPIC30F) |
121 | .Case(S: "ce" , Value: EM_CE) |
122 | .Case(S: "m32c" , Value: EM_M32C) |
123 | .Case(S: "tsk3000" , Value: EM_TSK3000) |
124 | .Case(S: "rs08" , Value: EM_RS08) |
125 | .Case(S: "sharc" , Value: EM_SHARC) |
126 | .Case(S: "ecog2" , Value: EM_ECOG2) |
127 | .Case(S: "score7" , Value: EM_SCORE7) |
128 | .Case(S: "dsp24" , Value: EM_DSP24) |
129 | .Case(S: "videocore3" , Value: EM_VIDEOCORE3) |
130 | .Case(S: "latticemico32" , Value: EM_LATTICEMICO32) |
131 | .Case(S: "se_c17" , Value: EM_SE_C17) |
132 | .Case(S: "ti_c6000" , Value: EM_TI_C6000) |
133 | .Case(S: "ti_c2000" , Value: EM_TI_C2000) |
134 | .Case(S: "ti_c5500" , Value: EM_TI_C5500) |
135 | .Case(S: "mmdsp_plus" , Value: EM_MMDSP_PLUS) |
136 | .Case(S: "cypress_m8c" , Value: EM_CYPRESS_M8C) |
137 | .Case(S: "r32c" , Value: EM_R32C) |
138 | .Case(S: "trimedia" , Value: EM_TRIMEDIA) |
139 | .Case(S: "hexagon" , Value: EM_HEXAGON) |
140 | .Case(S: "8051" , Value: EM_8051) |
141 | .Case(S: "stxp7x" , Value: EM_STXP7X) |
142 | .Case(S: "nds32" , Value: EM_NDS32) |
143 | .Case(S: "ecog1" , Value: EM_ECOG1) |
144 | .Case(S: "ecog1x" , Value: EM_ECOG1X) |
145 | .Case(S: "maxq30" , Value: EM_MAXQ30) |
146 | .Case(S: "ximo16" , Value: EM_XIMO16) |
147 | .Case(S: "manik" , Value: EM_MANIK) |
148 | .Case(S: "craynv2" , Value: EM_CRAYNV2) |
149 | .Case(S: "rx" , Value: EM_RX) |
150 | .Case(S: "metag" , Value: EM_METAG) |
151 | .Case(S: "mcst_elbrus" , Value: EM_MCST_ELBRUS) |
152 | .Case(S: "ecog16" , Value: EM_ECOG16) |
153 | .Case(S: "cr16" , Value: EM_CR16) |
154 | .Case(S: "etpu" , Value: EM_ETPU) |
155 | .Case(S: "sle9x" , Value: EM_SLE9X) |
156 | .Case(S: "l10m" , Value: EM_L10M) |
157 | .Case(S: "k10m" , Value: EM_K10M) |
158 | .Case(S: "aarch64" , Value: EM_AARCH64) |
159 | .Case(S: "avr32" , Value: EM_AVR32) |
160 | .Case(S: "stm8" , Value: EM_STM8) |
161 | .Case(S: "tile64" , Value: EM_TILE64) |
162 | .Case(S: "tilepro" , Value: EM_TILEPRO) |
163 | .Case(S: "cuda" , Value: EM_CUDA) |
164 | .Case(S: "tilegx" , Value: EM_TILEGX) |
165 | .Case(S: "cloudshield" , Value: EM_CLOUDSHIELD) |
166 | .Case(S: "corea_1st" , Value: EM_COREA_1ST) |
167 | .Case(S: "corea_2nd" , Value: EM_COREA_2ND) |
168 | .Case(S: "arc_compact2" , Value: EM_ARC_COMPACT2) |
169 | .Case(S: "open8" , Value: EM_OPEN8) |
170 | .Case(S: "rl78" , Value: EM_RL78) |
171 | .Case(S: "videocore5" , Value: EM_VIDEOCORE5) |
172 | .Case(S: "78kor" , Value: EM_78KOR) |
173 | .Case(S: "56800ex" , Value: EM_56800EX) |
174 | .Case(S: "ba1" , Value: EM_BA1) |
175 | .Case(S: "ba2" , Value: EM_BA2) |
176 | .Case(S: "xcore" , Value: EM_XCORE) |
177 | .Case(S: "mchp_pic" , Value: EM_MCHP_PIC) |
178 | .Case(S: "intel205" , Value: EM_INTEL205) |
179 | .Case(S: "intel206" , Value: EM_INTEL206) |
180 | .Case(S: "intel207" , Value: EM_INTEL207) |
181 | .Case(S: "intel208" , Value: EM_INTEL208) |
182 | .Case(S: "intel209" , Value: EM_INTEL209) |
183 | .Case(S: "km32" , Value: EM_KM32) |
184 | .Case(S: "kmx32" , Value: EM_KMX32) |
185 | .Case(S: "kmx16" , Value: EM_KMX16) |
186 | .Case(S: "kmx8" , Value: EM_KMX8) |
187 | .Case(S: "kvarc" , Value: EM_KVARC) |
188 | .Case(S: "cdp" , Value: EM_CDP) |
189 | .Case(S: "coge" , Value: EM_COGE) |
190 | .Case(S: "cool" , Value: EM_COOL) |
191 | .Case(S: "norc" , Value: EM_NORC) |
192 | .Case(S: "csr_kalimba" , Value: EM_CSR_KALIMBA) |
193 | .Case(S: "amdgpu" , Value: EM_AMDGPU) |
194 | .Case(S: "riscv" , Value: EM_RISCV) |
195 | .Case(S: "lanai" , Value: EM_LANAI) |
196 | .Case(S: "bpf" , Value: EM_BPF) |
197 | .Case(S: "ve" , Value: EM_VE) |
198 | .Case(S: "csky" , Value: EM_CSKY) |
199 | .Case(S: "loongarch" , Value: EM_LOONGARCH) |
200 | .Default(Value: EM_NONE); |
201 | } |
202 | |
203 | /// Convert an ELF's e_machine value into an architecture name. |
204 | StringRef ELF::convertEMachineToArchName(uint16_t EMachine) { |
205 | switch (EMachine) { |
206 | case EM_NONE: |
207 | return "None" ; |
208 | case EM_M32: |
209 | return "m32" ; |
210 | case EM_SPARC: |
211 | return "sparc" ; |
212 | case EM_386: |
213 | return "386" ; |
214 | case EM_68K: |
215 | return "68k" ; |
216 | case EM_88K: |
217 | return "88k" ; |
218 | case EM_IAMCU: |
219 | return "iamcu" ; |
220 | case EM_860: |
221 | return "860" ; |
222 | case EM_MIPS: |
223 | return "mips" ; |
224 | case EM_S370: |
225 | return "s370" ; |
226 | case EM_MIPS_RS3_LE: |
227 | return "mips_rs3_le" ; |
228 | case EM_PARISC: |
229 | return "parisc" ; |
230 | case EM_VPP500: |
231 | return "vpp500" ; |
232 | case EM_SPARC32PLUS: |
233 | return "sparc32plus" ; |
234 | case EM_960: |
235 | return "960" ; |
236 | case EM_PPC: |
237 | return "ppc" ; |
238 | case EM_PPC64: |
239 | return "ppc64" ; |
240 | case EM_S390: |
241 | return "s390" ; |
242 | case EM_SPU: |
243 | return "spu" ; |
244 | case EM_V800: |
245 | return "v800" ; |
246 | case EM_FR20: |
247 | return "fr20" ; |
248 | case EM_RH32: |
249 | return "rh32" ; |
250 | case EM_RCE: |
251 | return "rce" ; |
252 | case EM_ARM: |
253 | return "arm" ; |
254 | case EM_ALPHA: |
255 | return "alpha" ; |
256 | case EM_SH: |
257 | return "sh" ; |
258 | case EM_SPARCV9: |
259 | return "sparcv9" ; |
260 | case EM_TRICORE: |
261 | return "tricore" ; |
262 | case EM_ARC: |
263 | return "arc" ; |
264 | case EM_H8_300: |
265 | return "h8_300" ; |
266 | case EM_H8_300H: |
267 | return "h8_300h" ; |
268 | case EM_H8S: |
269 | return "h8s" ; |
270 | case EM_H8_500: |
271 | return "h8_500" ; |
272 | case EM_IA_64: |
273 | return "ia_64" ; |
274 | case EM_MIPS_X: |
275 | return "mips_x" ; |
276 | case EM_COLDFIRE: |
277 | return "coldfire" ; |
278 | case EM_68HC12: |
279 | return "68hc12" ; |
280 | case EM_MMA: |
281 | return "mma" ; |
282 | case EM_PCP: |
283 | return "pcp" ; |
284 | case EM_NCPU: |
285 | return "ncpu" ; |
286 | case EM_NDR1: |
287 | return "ndr1" ; |
288 | case EM_STARCORE: |
289 | return "starcore" ; |
290 | case EM_ME16: |
291 | return "me16" ; |
292 | case EM_ST100: |
293 | return "st100" ; |
294 | case EM_TINYJ: |
295 | return "tinyj" ; |
296 | case EM_X86_64: |
297 | return "x86_64" ; |
298 | case EM_PDSP: |
299 | return "pdsp" ; |
300 | case EM_PDP10: |
301 | return "pdp10" ; |
302 | case EM_PDP11: |
303 | return "pdp11" ; |
304 | case EM_FX66: |
305 | return "fx66" ; |
306 | case EM_ST9PLUS: |
307 | return "st9plus" ; |
308 | case EM_ST7: |
309 | return "st7" ; |
310 | case EM_68HC16: |
311 | return "68hc16" ; |
312 | case EM_68HC11: |
313 | return "68hc11" ; |
314 | case EM_68HC08: |
315 | return "68hc08" ; |
316 | case EM_68HC05: |
317 | return "68hc05" ; |
318 | case EM_SVX: |
319 | return "svx" ; |
320 | case EM_ST19: |
321 | return "st19" ; |
322 | case EM_VAX: |
323 | return "vax" ; |
324 | case EM_CRIS: |
325 | return "cris" ; |
326 | case EM_JAVELIN: |
327 | return "javelin" ; |
328 | case EM_FIREPATH: |
329 | return "firepath" ; |
330 | case EM_ZSP: |
331 | return "zsp" ; |
332 | case EM_MMIX: |
333 | return "mmix" ; |
334 | case EM_HUANY: |
335 | return "huany" ; |
336 | case EM_PRISM: |
337 | return "prism" ; |
338 | case EM_AVR: |
339 | return "avr" ; |
340 | case EM_FR30: |
341 | return "fr30" ; |
342 | case EM_D10V: |
343 | return "d10v" ; |
344 | case EM_D30V: |
345 | return "d30v" ; |
346 | case EM_V850: |
347 | return "v850" ; |
348 | case EM_M32R: |
349 | return "m32r" ; |
350 | case EM_MN10300: |
351 | return "mn10300" ; |
352 | case EM_MN10200: |
353 | return "mn10200" ; |
354 | case EM_PJ: |
355 | return "pj" ; |
356 | case EM_OPENRISC: |
357 | return "openrisc" ; |
358 | case EM_ARC_COMPACT: |
359 | return "arc_compact" ; |
360 | case EM_XTENSA: |
361 | return "xtensa" ; |
362 | case EM_VIDEOCORE: |
363 | return "videocore" ; |
364 | case EM_TMM_GPP: |
365 | return "tmm_gpp" ; |
366 | case EM_NS32K: |
367 | return "ns32k" ; |
368 | case EM_TPC: |
369 | return "tpc" ; |
370 | case EM_SNP1K: |
371 | return "snp1k" ; |
372 | case EM_ST200: |
373 | return "st200" ; |
374 | case EM_IP2K: |
375 | return "ip2k" ; |
376 | case EM_MAX: |
377 | return "max" ; |
378 | case EM_CR: |
379 | return "cr" ; |
380 | case EM_F2MC16: |
381 | return "f2mc16" ; |
382 | case EM_MSP430: |
383 | return "msp430" ; |
384 | case EM_BLACKFIN: |
385 | return "blackfin" ; |
386 | case EM_SE_C33: |
387 | return "se_c33" ; |
388 | case EM_SEP: |
389 | return "sep" ; |
390 | case EM_ARCA: |
391 | return "arca" ; |
392 | case EM_UNICORE: |
393 | return "unicore" ; |
394 | case EM_EXCESS: |
395 | return "excess" ; |
396 | case EM_DXP: |
397 | return "dxp" ; |
398 | case EM_ALTERA_NIOS2: |
399 | return "altera_nios2" ; |
400 | case EM_CRX: |
401 | return "crx" ; |
402 | case EM_XGATE: |
403 | return "xgate" ; |
404 | case EM_C166: |
405 | return "c166" ; |
406 | case EM_M16C: |
407 | return "m16c" ; |
408 | case EM_DSPIC30F: |
409 | return "dspic30f" ; |
410 | case EM_CE: |
411 | return "ce" ; |
412 | case EM_M32C: |
413 | return "m32c" ; |
414 | case EM_TSK3000: |
415 | return "tsk3000" ; |
416 | case EM_RS08: |
417 | return "rs08" ; |
418 | case EM_SHARC: |
419 | return "sharc" ; |
420 | case EM_ECOG2: |
421 | return "ecog2" ; |
422 | case EM_SCORE7: |
423 | return "score7" ; |
424 | case EM_DSP24: |
425 | return "dsp24" ; |
426 | case EM_VIDEOCORE3: |
427 | return "videocore3" ; |
428 | case EM_LATTICEMICO32: |
429 | return "latticemico32" ; |
430 | case EM_SE_C17: |
431 | return "se_c17" ; |
432 | case EM_TI_C6000: |
433 | return "ti_c6000" ; |
434 | case EM_TI_C2000: |
435 | return "ti_c2000" ; |
436 | case EM_TI_C5500: |
437 | return "ti_c5500" ; |
438 | case EM_MMDSP_PLUS: |
439 | return "mmdsp_plus" ; |
440 | case EM_CYPRESS_M8C: |
441 | return "cypress_m8c" ; |
442 | case EM_R32C: |
443 | return "r32c" ; |
444 | case EM_TRIMEDIA: |
445 | return "trimedia" ; |
446 | case EM_HEXAGON: |
447 | return "hexagon" ; |
448 | case EM_8051: |
449 | return "8051" ; |
450 | case EM_STXP7X: |
451 | return "stxp7x" ; |
452 | case EM_NDS32: |
453 | return "nds32" ; |
454 | case EM_ECOG1: |
455 | return "ecog1" ; |
456 | case EM_MAXQ30: |
457 | return "maxq30" ; |
458 | case EM_XIMO16: |
459 | return "ximo16" ; |
460 | case EM_MANIK: |
461 | return "manik" ; |
462 | case EM_CRAYNV2: |
463 | return "craynv2" ; |
464 | case EM_RX: |
465 | return "rx" ; |
466 | case EM_METAG: |
467 | return "metag" ; |
468 | case EM_MCST_ELBRUS: |
469 | return "mcst_elbrus" ; |
470 | case EM_ECOG16: |
471 | return "ecog16" ; |
472 | case EM_CR16: |
473 | return "cr16" ; |
474 | case EM_ETPU: |
475 | return "etpu" ; |
476 | case EM_SLE9X: |
477 | return "sle9x" ; |
478 | case EM_L10M: |
479 | return "l10m" ; |
480 | case EM_K10M: |
481 | return "k10m" ; |
482 | case EM_AARCH64: |
483 | return "AArch64" ; |
484 | case EM_AVR32: |
485 | return "avr32" ; |
486 | case EM_STM8: |
487 | return "stm8" ; |
488 | case EM_TILE64: |
489 | return "tile64" ; |
490 | case EM_TILEPRO: |
491 | return "tilepro" ; |
492 | case EM_CUDA: |
493 | return "cuda" ; |
494 | case EM_TILEGX: |
495 | return "tilegx" ; |
496 | case EM_CLOUDSHIELD: |
497 | return "cloudshield" ; |
498 | case EM_COREA_1ST: |
499 | return "corea_1st" ; |
500 | case EM_COREA_2ND: |
501 | return "corea_2nd" ; |
502 | case EM_ARC_COMPACT2: |
503 | return "arc_compact2" ; |
504 | case EM_OPEN8: |
505 | return "open8" ; |
506 | case EM_RL78: |
507 | return "rl78" ; |
508 | case EM_VIDEOCORE5: |
509 | return "videocore5" ; |
510 | case EM_78KOR: |
511 | return "78kor" ; |
512 | case EM_56800EX: |
513 | return "56800ex" ; |
514 | case EM_BA1: |
515 | return "ba1" ; |
516 | case EM_BA2: |
517 | return "ba2" ; |
518 | case EM_XCORE: |
519 | return "xcore" ; |
520 | case EM_MCHP_PIC: |
521 | return "mchp_pic" ; |
522 | case EM_INTEL205: |
523 | return "intel205" ; |
524 | case EM_INTEL206: |
525 | return "intel206" ; |
526 | case EM_INTEL207: |
527 | return "intel207" ; |
528 | case EM_INTEL208: |
529 | return "intel208" ; |
530 | case EM_INTEL209: |
531 | return "intel209" ; |
532 | case EM_KM32: |
533 | return "km32" ; |
534 | case EM_KMX32: |
535 | return "kmx32" ; |
536 | case EM_KMX16: |
537 | return "kmx16" ; |
538 | case EM_KMX8: |
539 | return "kmx8" ; |
540 | case EM_KVARC: |
541 | return "kvarc" ; |
542 | case EM_CDP: |
543 | return "cdp" ; |
544 | case EM_COGE: |
545 | return "coge" ; |
546 | case EM_COOL: |
547 | return "cool" ; |
548 | case EM_NORC: |
549 | return "norc" ; |
550 | case EM_CSR_KALIMBA: |
551 | return "csr_kalimba" ; |
552 | case EM_AMDGPU: |
553 | return "amdgpu" ; |
554 | case EM_RISCV: |
555 | return "riscv" ; |
556 | case EM_LANAI: |
557 | return "lanai" ; |
558 | case EM_BPF: |
559 | return "bpf" ; |
560 | case EM_VE: |
561 | return "ve" ; |
562 | case EM_CSKY: |
563 | return "csky" ; |
564 | case EM_LOONGARCH: |
565 | return "loongarch" ; |
566 | default: |
567 | return "None" ; |
568 | } |
569 | } |
570 | |
571 | uint8_t ELF::convertNameToOSABI(StringRef Name) { |
572 | return StringSwitch<uint16_t>(Name) |
573 | .StartsWith(S: "hpux" , Value: ELFOSABI_HPUX) |
574 | .StartsWith(S: "netbsd" , Value: ELFOSABI_NETBSD) |
575 | .StartsWith(S: "gnu" , Value: ELFOSABI_GNU) |
576 | .StartsWith(S: "hurd" , Value: ELFOSABI_HURD) |
577 | .StartsWith(S: "solaris" , Value: ELFOSABI_SOLARIS) |
578 | .StartsWith(S: "aix" , Value: ELFOSABI_AIX) |
579 | .StartsWith(S: "irix" , Value: ELFOSABI_IRIX) |
580 | .StartsWith(S: "freebsd" , Value: ELFOSABI_FREEBSD) |
581 | .StartsWith(S: "tru64" , Value: ELFOSABI_TRU64) |
582 | .StartsWith(S: "modesto" , Value: ELFOSABI_MODESTO) |
583 | .StartsWith(S: "openbsd" , Value: ELFOSABI_OPENBSD) |
584 | .StartsWith(S: "openvms" , Value: ELFOSABI_OPENVMS) |
585 | .StartsWith(S: "nsk" , Value: ELFOSABI_NSK) |
586 | .StartsWith(S: "aros" , Value: ELFOSABI_AROS) |
587 | .StartsWith(S: "fenixos" , Value: ELFOSABI_FENIXOS) |
588 | .StartsWith(S: "cloudabi" , Value: ELFOSABI_CLOUDABI) |
589 | .StartsWith(S: "cuda" , Value: ELFOSABI_CUDA) |
590 | .StartsWith(S: "amdhsa" , Value: ELFOSABI_AMDGPU_HSA) |
591 | .StartsWith(S: "amdpal" , Value: ELFOSABI_AMDGPU_PAL) |
592 | .StartsWith(S: "mesa3d" , Value: ELFOSABI_AMDGPU_MESA3D) |
593 | .StartsWith(S: "arm" , Value: ELFOSABI_ARM) |
594 | .StartsWith(S: "standalone" , Value: ELFOSABI_STANDALONE) |
595 | .StartsWith(S: "none" , Value: ELFOSABI_NONE) |
596 | .Default(Value: ELFOSABI_NONE); |
597 | } |
598 | |
599 | StringRef ELF::convertOSABIToName(uint8_t OSABI) { |
600 | switch (OSABI) { |
601 | case ELFOSABI_HPUX: |
602 | return "hpux" ; |
603 | case ELFOSABI_NETBSD: |
604 | return "netbsd" ; |
605 | case ELFOSABI_GNU: |
606 | return "gnu" ; |
607 | case ELFOSABI_HURD: |
608 | return "hurd" ; |
609 | case ELFOSABI_SOLARIS: |
610 | return "solaris" ; |
611 | case ELFOSABI_AIX: |
612 | return "aix" ; |
613 | case ELFOSABI_IRIX: |
614 | return "irix" ; |
615 | case ELFOSABI_FREEBSD: |
616 | return "freebsd" ; |
617 | case ELFOSABI_TRU64: |
618 | return "tru64" ; |
619 | case ELFOSABI_MODESTO: |
620 | return "modesto" ; |
621 | case ELFOSABI_OPENBSD: |
622 | return "openbsd" ; |
623 | case ELFOSABI_OPENVMS: |
624 | return "openvms" ; |
625 | case ELFOSABI_NSK: |
626 | return "nsk" ; |
627 | case ELFOSABI_AROS: |
628 | return "aros" ; |
629 | case ELFOSABI_FENIXOS: |
630 | return "fenixos" ; |
631 | case ELFOSABI_CLOUDABI: |
632 | return "cloudabi" ; |
633 | case ELFOSABI_CUDA: |
634 | return "cuda" ; |
635 | case ELFOSABI_AMDGPU_HSA: |
636 | return "amdhsa" ; |
637 | case ELFOSABI_AMDGPU_PAL: |
638 | return "amdpal" ; |
639 | case ELFOSABI_AMDGPU_MESA3D: |
640 | return "mesa3d" ; |
641 | case ELFOSABI_ARM: |
642 | return "arm" ; |
643 | case ELFOSABI_STANDALONE: |
644 | return "standalone" ; |
645 | default: |
646 | return "none" ; |
647 | } |
648 | } |
649 | |