[llvm-exegesis] [NFC] Fixing typo.
[llvm-complete.git] / lib / ObjectYAML / ELFYAML.cpp
blobcec56771e1d8840154768abb97c43445cee0faf9
1 //===- ELFYAML.cpp - ELF YAMLIO implementation ----------------------------===//
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 // This file defines classes for handling the YAML representation of ELF.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ObjectYAML/ELFYAML.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/BinaryFormat/ELF.h"
16 #include "llvm/Support/Casting.h"
17 #include "llvm/Support/ErrorHandling.h"
18 #include "llvm/Support/MipsABIFlags.h"
19 #include "llvm/Support/YAMLTraits.h"
20 #include <cassert>
21 #include <cstdint>
23 namespace llvm {
25 ELFYAML::Section::~Section() = default;
27 namespace yaml {
29 void ScalarEnumerationTraits<ELFYAML::ELF_ET>::enumeration(
30 IO &IO, ELFYAML::ELF_ET &Value) {
31 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
32 ECase(ET_NONE);
33 ECase(ET_REL);
34 ECase(ET_EXEC);
35 ECase(ET_DYN);
36 ECase(ET_CORE);
37 #undef ECase
38 IO.enumFallback<Hex16>(Value);
41 void ScalarEnumerationTraits<ELFYAML::ELF_PT>::enumeration(
42 IO &IO, ELFYAML::ELF_PT &Value) {
43 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
44 ECase(PT_NULL);
45 ECase(PT_LOAD);
46 ECase(PT_DYNAMIC);
47 ECase(PT_INTERP);
48 ECase(PT_NOTE);
49 ECase(PT_SHLIB);
50 ECase(PT_PHDR);
51 ECase(PT_TLS);
52 ECase(PT_GNU_EH_FRAME);
53 #undef ECase
54 IO.enumFallback<Hex32>(Value);
57 void ScalarEnumerationTraits<ELFYAML::ELF_EM>::enumeration(
58 IO &IO, ELFYAML::ELF_EM &Value) {
59 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
60 ECase(EM_NONE);
61 ECase(EM_M32);
62 ECase(EM_SPARC);
63 ECase(EM_386);
64 ECase(EM_68K);
65 ECase(EM_88K);
66 ECase(EM_IAMCU);
67 ECase(EM_860);
68 ECase(EM_MIPS);
69 ECase(EM_S370);
70 ECase(EM_MIPS_RS3_LE);
71 ECase(EM_PARISC);
72 ECase(EM_VPP500);
73 ECase(EM_SPARC32PLUS);
74 ECase(EM_960);
75 ECase(EM_PPC);
76 ECase(EM_PPC64);
77 ECase(EM_S390);
78 ECase(EM_SPU);
79 ECase(EM_V800);
80 ECase(EM_FR20);
81 ECase(EM_RH32);
82 ECase(EM_RCE);
83 ECase(EM_ARM);
84 ECase(EM_ALPHA);
85 ECase(EM_SH);
86 ECase(EM_SPARCV9);
87 ECase(EM_TRICORE);
88 ECase(EM_ARC);
89 ECase(EM_H8_300);
90 ECase(EM_H8_300H);
91 ECase(EM_H8S);
92 ECase(EM_H8_500);
93 ECase(EM_IA_64);
94 ECase(EM_MIPS_X);
95 ECase(EM_COLDFIRE);
96 ECase(EM_68HC12);
97 ECase(EM_MMA);
98 ECase(EM_PCP);
99 ECase(EM_NCPU);
100 ECase(EM_NDR1);
101 ECase(EM_STARCORE);
102 ECase(EM_ME16);
103 ECase(EM_ST100);
104 ECase(EM_TINYJ);
105 ECase(EM_X86_64);
106 ECase(EM_PDSP);
107 ECase(EM_PDP10);
108 ECase(EM_PDP11);
109 ECase(EM_FX66);
110 ECase(EM_ST9PLUS);
111 ECase(EM_ST7);
112 ECase(EM_68HC16);
113 ECase(EM_68HC11);
114 ECase(EM_68HC08);
115 ECase(EM_68HC05);
116 ECase(EM_SVX);
117 ECase(EM_ST19);
118 ECase(EM_VAX);
119 ECase(EM_CRIS);
120 ECase(EM_JAVELIN);
121 ECase(EM_FIREPATH);
122 ECase(EM_ZSP);
123 ECase(EM_MMIX);
124 ECase(EM_HUANY);
125 ECase(EM_PRISM);
126 ECase(EM_AVR);
127 ECase(EM_FR30);
128 ECase(EM_D10V);
129 ECase(EM_D30V);
130 ECase(EM_V850);
131 ECase(EM_M32R);
132 ECase(EM_MN10300);
133 ECase(EM_MN10200);
134 ECase(EM_PJ);
135 ECase(EM_OPENRISC);
136 ECase(EM_ARC_COMPACT);
137 ECase(EM_XTENSA);
138 ECase(EM_VIDEOCORE);
139 ECase(EM_TMM_GPP);
140 ECase(EM_NS32K);
141 ECase(EM_TPC);
142 ECase(EM_SNP1K);
143 ECase(EM_ST200);
144 ECase(EM_IP2K);
145 ECase(EM_MAX);
146 ECase(EM_CR);
147 ECase(EM_F2MC16);
148 ECase(EM_MSP430);
149 ECase(EM_BLACKFIN);
150 ECase(EM_SE_C33);
151 ECase(EM_SEP);
152 ECase(EM_ARCA);
153 ECase(EM_UNICORE);
154 ECase(EM_EXCESS);
155 ECase(EM_DXP);
156 ECase(EM_ALTERA_NIOS2);
157 ECase(EM_CRX);
158 ECase(EM_XGATE);
159 ECase(EM_C166);
160 ECase(EM_M16C);
161 ECase(EM_DSPIC30F);
162 ECase(EM_CE);
163 ECase(EM_M32C);
164 ECase(EM_TSK3000);
165 ECase(EM_RS08);
166 ECase(EM_SHARC);
167 ECase(EM_ECOG2);
168 ECase(EM_SCORE7);
169 ECase(EM_DSP24);
170 ECase(EM_VIDEOCORE3);
171 ECase(EM_LATTICEMICO32);
172 ECase(EM_SE_C17);
173 ECase(EM_TI_C6000);
174 ECase(EM_TI_C2000);
175 ECase(EM_TI_C5500);
176 ECase(EM_MMDSP_PLUS);
177 ECase(EM_CYPRESS_M8C);
178 ECase(EM_R32C);
179 ECase(EM_TRIMEDIA);
180 ECase(EM_HEXAGON);
181 ECase(EM_8051);
182 ECase(EM_STXP7X);
183 ECase(EM_NDS32);
184 ECase(EM_ECOG1);
185 ECase(EM_ECOG1X);
186 ECase(EM_MAXQ30);
187 ECase(EM_XIMO16);
188 ECase(EM_MANIK);
189 ECase(EM_CRAYNV2);
190 ECase(EM_RX);
191 ECase(EM_METAG);
192 ECase(EM_MCST_ELBRUS);
193 ECase(EM_ECOG16);
194 ECase(EM_CR16);
195 ECase(EM_ETPU);
196 ECase(EM_SLE9X);
197 ECase(EM_L10M);
198 ECase(EM_K10M);
199 ECase(EM_AARCH64);
200 ECase(EM_AVR32);
201 ECase(EM_STM8);
202 ECase(EM_TILE64);
203 ECase(EM_TILEPRO);
204 ECase(EM_CUDA);
205 ECase(EM_TILEGX);
206 ECase(EM_CLOUDSHIELD);
207 ECase(EM_COREA_1ST);
208 ECase(EM_COREA_2ND);
209 ECase(EM_ARC_COMPACT2);
210 ECase(EM_OPEN8);
211 ECase(EM_RL78);
212 ECase(EM_VIDEOCORE5);
213 ECase(EM_78KOR);
214 ECase(EM_56800EX);
215 ECase(EM_AMDGPU);
216 ECase(EM_RISCV);
217 ECase(EM_LANAI);
218 ECase(EM_BPF);
219 #undef ECase
222 void ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS>::enumeration(
223 IO &IO, ELFYAML::ELF_ELFCLASS &Value) {
224 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
225 // Since the semantics of ELFCLASSNONE is "invalid", just don't accept it
226 // here.
227 ECase(ELFCLASS32);
228 ECase(ELFCLASS64);
229 #undef ECase
232 void ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA>::enumeration(
233 IO &IO, ELFYAML::ELF_ELFDATA &Value) {
234 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
235 // Since the semantics of ELFDATANONE is "invalid", just don't accept it
236 // here.
237 ECase(ELFDATA2LSB);
238 ECase(ELFDATA2MSB);
239 #undef ECase
242 void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
243 IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
244 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
245 ECase(ELFOSABI_NONE);
246 ECase(ELFOSABI_HPUX);
247 ECase(ELFOSABI_NETBSD);
248 ECase(ELFOSABI_GNU);
249 ECase(ELFOSABI_HURD);
250 ECase(ELFOSABI_SOLARIS);
251 ECase(ELFOSABI_AIX);
252 ECase(ELFOSABI_IRIX);
253 ECase(ELFOSABI_FREEBSD);
254 ECase(ELFOSABI_TRU64);
255 ECase(ELFOSABI_MODESTO);
256 ECase(ELFOSABI_OPENBSD);
257 ECase(ELFOSABI_OPENVMS);
258 ECase(ELFOSABI_NSK);
259 ECase(ELFOSABI_AROS);
260 ECase(ELFOSABI_FENIXOS);
261 ECase(ELFOSABI_CLOUDABI);
262 ECase(ELFOSABI_AMDGPU_HSA);
263 ECase(ELFOSABI_AMDGPU_PAL);
264 ECase(ELFOSABI_AMDGPU_MESA3D);
265 ECase(ELFOSABI_ARM);
266 ECase(ELFOSABI_C6000_ELFABI);
267 ECase(ELFOSABI_C6000_LINUX);
268 ECase(ELFOSABI_STANDALONE);
269 #undef ECase
272 void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
273 ELFYAML::ELF_EF &Value) {
274 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
275 assert(Object && "The IO context is not initialized");
276 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
277 #define BCaseMask(X, M) IO.maskedBitSetCase(Value, #X, ELF::X, ELF::M)
278 switch (Object->Header.Machine) {
279 case ELF::EM_ARM:
280 BCase(EF_ARM_SOFT_FLOAT);
281 BCase(EF_ARM_VFP_FLOAT);
282 BCaseMask(EF_ARM_EABI_UNKNOWN, EF_ARM_EABIMASK);
283 BCaseMask(EF_ARM_EABI_VER1, EF_ARM_EABIMASK);
284 BCaseMask(EF_ARM_EABI_VER2, EF_ARM_EABIMASK);
285 BCaseMask(EF_ARM_EABI_VER3, EF_ARM_EABIMASK);
286 BCaseMask(EF_ARM_EABI_VER4, EF_ARM_EABIMASK);
287 BCaseMask(EF_ARM_EABI_VER5, EF_ARM_EABIMASK);
288 break;
289 case ELF::EM_MIPS:
290 BCase(EF_MIPS_NOREORDER);
291 BCase(EF_MIPS_PIC);
292 BCase(EF_MIPS_CPIC);
293 BCase(EF_MIPS_ABI2);
294 BCase(EF_MIPS_32BITMODE);
295 BCase(EF_MIPS_FP64);
296 BCase(EF_MIPS_NAN2008);
297 BCase(EF_MIPS_MICROMIPS);
298 BCase(EF_MIPS_ARCH_ASE_M16);
299 BCase(EF_MIPS_ARCH_ASE_MDMX);
300 BCaseMask(EF_MIPS_ABI_O32, EF_MIPS_ABI);
301 BCaseMask(EF_MIPS_ABI_O64, EF_MIPS_ABI);
302 BCaseMask(EF_MIPS_ABI_EABI32, EF_MIPS_ABI);
303 BCaseMask(EF_MIPS_ABI_EABI64, EF_MIPS_ABI);
304 BCaseMask(EF_MIPS_MACH_3900, EF_MIPS_MACH);
305 BCaseMask(EF_MIPS_MACH_4010, EF_MIPS_MACH);
306 BCaseMask(EF_MIPS_MACH_4100, EF_MIPS_MACH);
307 BCaseMask(EF_MIPS_MACH_4650, EF_MIPS_MACH);
308 BCaseMask(EF_MIPS_MACH_4120, EF_MIPS_MACH);
309 BCaseMask(EF_MIPS_MACH_4111, EF_MIPS_MACH);
310 BCaseMask(EF_MIPS_MACH_SB1, EF_MIPS_MACH);
311 BCaseMask(EF_MIPS_MACH_OCTEON, EF_MIPS_MACH);
312 BCaseMask(EF_MIPS_MACH_XLR, EF_MIPS_MACH);
313 BCaseMask(EF_MIPS_MACH_OCTEON2, EF_MIPS_MACH);
314 BCaseMask(EF_MIPS_MACH_OCTEON3, EF_MIPS_MACH);
315 BCaseMask(EF_MIPS_MACH_5400, EF_MIPS_MACH);
316 BCaseMask(EF_MIPS_MACH_5900, EF_MIPS_MACH);
317 BCaseMask(EF_MIPS_MACH_5500, EF_MIPS_MACH);
318 BCaseMask(EF_MIPS_MACH_9000, EF_MIPS_MACH);
319 BCaseMask(EF_MIPS_MACH_LS2E, EF_MIPS_MACH);
320 BCaseMask(EF_MIPS_MACH_LS2F, EF_MIPS_MACH);
321 BCaseMask(EF_MIPS_MACH_LS3A, EF_MIPS_MACH);
322 BCaseMask(EF_MIPS_ARCH_1, EF_MIPS_ARCH);
323 BCaseMask(EF_MIPS_ARCH_2, EF_MIPS_ARCH);
324 BCaseMask(EF_MIPS_ARCH_3, EF_MIPS_ARCH);
325 BCaseMask(EF_MIPS_ARCH_4, EF_MIPS_ARCH);
326 BCaseMask(EF_MIPS_ARCH_5, EF_MIPS_ARCH);
327 BCaseMask(EF_MIPS_ARCH_32, EF_MIPS_ARCH);
328 BCaseMask(EF_MIPS_ARCH_64, EF_MIPS_ARCH);
329 BCaseMask(EF_MIPS_ARCH_32R2, EF_MIPS_ARCH);
330 BCaseMask(EF_MIPS_ARCH_64R2, EF_MIPS_ARCH);
331 BCaseMask(EF_MIPS_ARCH_32R6, EF_MIPS_ARCH);
332 BCaseMask(EF_MIPS_ARCH_64R6, EF_MIPS_ARCH);
333 break;
334 case ELF::EM_HEXAGON:
335 BCase(EF_HEXAGON_MACH_V2);
336 BCase(EF_HEXAGON_MACH_V3);
337 BCase(EF_HEXAGON_MACH_V4);
338 BCase(EF_HEXAGON_MACH_V5);
339 BCase(EF_HEXAGON_MACH_V55);
340 BCase(EF_HEXAGON_MACH_V60);
341 BCase(EF_HEXAGON_MACH_V62);
342 BCase(EF_HEXAGON_MACH_V65);
343 BCase(EF_HEXAGON_ISA_V2);
344 BCase(EF_HEXAGON_ISA_V3);
345 BCase(EF_HEXAGON_ISA_V4);
346 BCase(EF_HEXAGON_ISA_V5);
347 BCase(EF_HEXAGON_ISA_V55);
348 BCase(EF_HEXAGON_ISA_V60);
349 BCase(EF_HEXAGON_ISA_V62);
350 BCase(EF_HEXAGON_ISA_V65);
351 break;
352 case ELF::EM_AVR:
353 BCase(EF_AVR_ARCH_AVR1);
354 BCase(EF_AVR_ARCH_AVR2);
355 BCase(EF_AVR_ARCH_AVR25);
356 BCase(EF_AVR_ARCH_AVR3);
357 BCase(EF_AVR_ARCH_AVR31);
358 BCase(EF_AVR_ARCH_AVR35);
359 BCase(EF_AVR_ARCH_AVR4);
360 BCase(EF_AVR_ARCH_AVR51);
361 BCase(EF_AVR_ARCH_AVR6);
362 BCase(EF_AVR_ARCH_AVRTINY);
363 BCase(EF_AVR_ARCH_XMEGA1);
364 BCase(EF_AVR_ARCH_XMEGA2);
365 BCase(EF_AVR_ARCH_XMEGA3);
366 BCase(EF_AVR_ARCH_XMEGA4);
367 BCase(EF_AVR_ARCH_XMEGA5);
368 BCase(EF_AVR_ARCH_XMEGA6);
369 BCase(EF_AVR_ARCH_XMEGA7);
370 break;
371 case ELF::EM_RISCV:
372 BCase(EF_RISCV_RVC);
373 BCaseMask(EF_RISCV_FLOAT_ABI_SOFT, EF_RISCV_FLOAT_ABI);
374 BCaseMask(EF_RISCV_FLOAT_ABI_SINGLE, EF_RISCV_FLOAT_ABI);
375 BCaseMask(EF_RISCV_FLOAT_ABI_DOUBLE, EF_RISCV_FLOAT_ABI);
376 BCaseMask(EF_RISCV_FLOAT_ABI_QUAD, EF_RISCV_FLOAT_ABI);
377 BCase(EF_RISCV_RVE);
378 break;
379 case ELF::EM_AMDGPU:
380 BCaseMask(EF_AMDGPU_MACH_NONE, EF_AMDGPU_MACH);
381 BCaseMask(EF_AMDGPU_MACH_R600_R600, EF_AMDGPU_MACH);
382 BCaseMask(EF_AMDGPU_MACH_R600_R630, EF_AMDGPU_MACH);
383 BCaseMask(EF_AMDGPU_MACH_R600_RS880, EF_AMDGPU_MACH);
384 BCaseMask(EF_AMDGPU_MACH_R600_RV670, EF_AMDGPU_MACH);
385 BCaseMask(EF_AMDGPU_MACH_R600_RV710, EF_AMDGPU_MACH);
386 BCaseMask(EF_AMDGPU_MACH_R600_RV730, EF_AMDGPU_MACH);
387 BCaseMask(EF_AMDGPU_MACH_R600_RV770, EF_AMDGPU_MACH);
388 BCaseMask(EF_AMDGPU_MACH_R600_CEDAR, EF_AMDGPU_MACH);
389 BCaseMask(EF_AMDGPU_MACH_R600_CYPRESS, EF_AMDGPU_MACH);
390 BCaseMask(EF_AMDGPU_MACH_R600_JUNIPER, EF_AMDGPU_MACH);
391 BCaseMask(EF_AMDGPU_MACH_R600_REDWOOD, EF_AMDGPU_MACH);
392 BCaseMask(EF_AMDGPU_MACH_R600_SUMO, EF_AMDGPU_MACH);
393 BCaseMask(EF_AMDGPU_MACH_R600_BARTS, EF_AMDGPU_MACH);
394 BCaseMask(EF_AMDGPU_MACH_R600_CAICOS, EF_AMDGPU_MACH);
395 BCaseMask(EF_AMDGPU_MACH_R600_CAYMAN, EF_AMDGPU_MACH);
396 BCaseMask(EF_AMDGPU_MACH_R600_TURKS, EF_AMDGPU_MACH);
397 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX600, EF_AMDGPU_MACH);
398 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX601, EF_AMDGPU_MACH);
399 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX700, EF_AMDGPU_MACH);
400 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX701, EF_AMDGPU_MACH);
401 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX702, EF_AMDGPU_MACH);
402 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX703, EF_AMDGPU_MACH);
403 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX704, EF_AMDGPU_MACH);
404 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX801, EF_AMDGPU_MACH);
405 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX802, EF_AMDGPU_MACH);
406 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX803, EF_AMDGPU_MACH);
407 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX810, EF_AMDGPU_MACH);
408 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX900, EF_AMDGPU_MACH);
409 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX902, EF_AMDGPU_MACH);
410 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX904, EF_AMDGPU_MACH);
411 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX906, EF_AMDGPU_MACH);
412 BCaseMask(EF_AMDGPU_MACH_AMDGCN_GFX909, EF_AMDGPU_MACH);
413 BCase(EF_AMDGPU_XNACK);
414 BCase(EF_AMDGPU_SRAM_ECC);
415 break;
416 case ELF::EM_X86_64:
417 break;
418 default:
419 llvm_unreachable("Unsupported architecture");
421 #undef BCase
422 #undef BCaseMask
425 void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
426 IO &IO, ELFYAML::ELF_SHT &Value) {
427 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
428 assert(Object && "The IO context is not initialized");
429 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
430 ECase(SHT_NULL);
431 ECase(SHT_PROGBITS);
432 ECase(SHT_SYMTAB);
433 // FIXME: Issue a diagnostic with this information.
434 ECase(SHT_STRTAB);
435 ECase(SHT_RELA);
436 ECase(SHT_HASH);
437 ECase(SHT_DYNAMIC);
438 ECase(SHT_NOTE);
439 ECase(SHT_NOBITS);
440 ECase(SHT_REL);
441 ECase(SHT_SHLIB);
442 ECase(SHT_DYNSYM);
443 ECase(SHT_INIT_ARRAY);
444 ECase(SHT_FINI_ARRAY);
445 ECase(SHT_PREINIT_ARRAY);
446 ECase(SHT_GROUP);
447 ECase(SHT_SYMTAB_SHNDX);
448 ECase(SHT_RELR);
449 ECase(SHT_LOOS);
450 ECase(SHT_ANDROID_REL);
451 ECase(SHT_ANDROID_RELA);
452 ECase(SHT_ANDROID_RELR);
453 ECase(SHT_LLVM_ODRTAB);
454 ECase(SHT_LLVM_LINKER_OPTIONS);
455 ECase(SHT_LLVM_CALL_GRAPH_PROFILE);
456 ECase(SHT_LLVM_ADDRSIG);
457 ECase(SHT_GNU_ATTRIBUTES);
458 ECase(SHT_GNU_HASH);
459 ECase(SHT_GNU_verdef);
460 ECase(SHT_GNU_verneed);
461 ECase(SHT_GNU_versym);
462 ECase(SHT_HIOS);
463 ECase(SHT_LOPROC);
464 switch (Object->Header.Machine) {
465 case ELF::EM_ARM:
466 ECase(SHT_ARM_EXIDX);
467 ECase(SHT_ARM_PREEMPTMAP);
468 ECase(SHT_ARM_ATTRIBUTES);
469 ECase(SHT_ARM_DEBUGOVERLAY);
470 ECase(SHT_ARM_OVERLAYSECTION);
471 break;
472 case ELF::EM_HEXAGON:
473 ECase(SHT_HEX_ORDERED);
474 break;
475 case ELF::EM_X86_64:
476 ECase(SHT_X86_64_UNWIND);
477 break;
478 case ELF::EM_MIPS:
479 ECase(SHT_MIPS_REGINFO);
480 ECase(SHT_MIPS_OPTIONS);
481 ECase(SHT_MIPS_ABIFLAGS);
482 break;
483 default:
484 // Nothing to do.
485 break;
487 #undef ECase
490 void ScalarBitSetTraits<ELFYAML::ELF_PF>::bitset(IO &IO,
491 ELFYAML::ELF_PF &Value) {
492 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
493 BCase(PF_X);
494 BCase(PF_W);
495 BCase(PF_R);
498 void ScalarBitSetTraits<ELFYAML::ELF_SHF>::bitset(IO &IO,
499 ELFYAML::ELF_SHF &Value) {
500 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
501 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
502 BCase(SHF_WRITE);
503 BCase(SHF_ALLOC);
504 BCase(SHF_EXCLUDE);
505 BCase(SHF_EXECINSTR);
506 BCase(SHF_MERGE);
507 BCase(SHF_STRINGS);
508 BCase(SHF_INFO_LINK);
509 BCase(SHF_LINK_ORDER);
510 BCase(SHF_OS_NONCONFORMING);
511 BCase(SHF_GROUP);
512 BCase(SHF_TLS);
513 BCase(SHF_COMPRESSED);
514 switch (Object->Header.Machine) {
515 case ELF::EM_ARM:
516 BCase(SHF_ARM_PURECODE);
517 break;
518 case ELF::EM_HEXAGON:
519 BCase(SHF_HEX_GPREL);
520 break;
521 case ELF::EM_MIPS:
522 BCase(SHF_MIPS_NODUPES);
523 BCase(SHF_MIPS_NAMES);
524 BCase(SHF_MIPS_LOCAL);
525 BCase(SHF_MIPS_NOSTRIP);
526 BCase(SHF_MIPS_GPREL);
527 BCase(SHF_MIPS_MERGE);
528 BCase(SHF_MIPS_ADDR);
529 BCase(SHF_MIPS_STRING);
530 break;
531 case ELF::EM_X86_64:
532 BCase(SHF_X86_64_LARGE);
533 break;
534 default:
535 // Nothing to do.
536 break;
538 #undef BCase
541 void ScalarEnumerationTraits<ELFYAML::ELF_SHN>::enumeration(
542 IO &IO, ELFYAML::ELF_SHN &Value) {
543 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
544 ECase(SHN_UNDEF);
545 ECase(SHN_LORESERVE);
546 ECase(SHN_LOPROC);
547 ECase(SHN_HIPROC);
548 ECase(SHN_LOOS);
549 ECase(SHN_HIOS);
550 ECase(SHN_ABS);
551 ECase(SHN_COMMON);
552 ECase(SHN_XINDEX);
553 ECase(SHN_HIRESERVE);
554 ECase(SHN_HEXAGON_SCOMMON);
555 ECase(SHN_HEXAGON_SCOMMON_1);
556 ECase(SHN_HEXAGON_SCOMMON_2);
557 ECase(SHN_HEXAGON_SCOMMON_4);
558 ECase(SHN_HEXAGON_SCOMMON_8);
559 #undef ECase
560 IO.enumFallback<Hex32>(Value);
563 void ScalarEnumerationTraits<ELFYAML::ELF_STT>::enumeration(
564 IO &IO, ELFYAML::ELF_STT &Value) {
565 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
566 ECase(STT_NOTYPE);
567 ECase(STT_OBJECT);
568 ECase(STT_FUNC);
569 ECase(STT_SECTION);
570 ECase(STT_FILE);
571 ECase(STT_COMMON);
572 ECase(STT_TLS);
573 ECase(STT_GNU_IFUNC);
574 #undef ECase
575 IO.enumFallback<Hex8>(Value);
578 void ScalarEnumerationTraits<ELFYAML::ELF_STV>::enumeration(
579 IO &IO, ELFYAML::ELF_STV &Value) {
580 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
581 ECase(STV_DEFAULT);
582 ECase(STV_INTERNAL);
583 ECase(STV_HIDDEN);
584 ECase(STV_PROTECTED);
585 #undef ECase
588 void ScalarBitSetTraits<ELFYAML::ELF_STO>::bitset(IO &IO,
589 ELFYAML::ELF_STO &Value) {
590 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
591 assert(Object && "The IO context is not initialized");
592 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X)
593 switch (Object->Header.Machine) {
594 case ELF::EM_MIPS:
595 BCase(STO_MIPS_OPTIONAL);
596 BCase(STO_MIPS_PLT);
597 BCase(STO_MIPS_PIC);
598 BCase(STO_MIPS_MICROMIPS);
599 break;
600 default:
601 break; // Nothing to do
603 #undef BCase
604 #undef BCaseMask
607 void ScalarEnumerationTraits<ELFYAML::ELF_RSS>::enumeration(
608 IO &IO, ELFYAML::ELF_RSS &Value) {
609 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
610 ECase(RSS_UNDEF);
611 ECase(RSS_GP);
612 ECase(RSS_GP0);
613 ECase(RSS_LOC);
614 #undef ECase
617 void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration(
618 IO &IO, ELFYAML::ELF_REL &Value) {
619 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
620 assert(Object && "The IO context is not initialized");
621 #define ELF_RELOC(X, Y) IO.enumCase(Value, #X, ELF::X);
622 switch (Object->Header.Machine) {
623 case ELF::EM_X86_64:
624 #include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
625 break;
626 case ELF::EM_MIPS:
627 #include "llvm/BinaryFormat/ELFRelocs/Mips.def"
628 break;
629 case ELF::EM_HEXAGON:
630 #include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
631 break;
632 case ELF::EM_386:
633 case ELF::EM_IAMCU:
634 #include "llvm/BinaryFormat/ELFRelocs/i386.def"
635 break;
636 case ELF::EM_AARCH64:
637 #include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
638 break;
639 case ELF::EM_ARM:
640 #include "llvm/BinaryFormat/ELFRelocs/ARM.def"
641 break;
642 case ELF::EM_ARC:
643 #include "llvm/BinaryFormat/ELFRelocs/ARC.def"
644 break;
645 case ELF::EM_RISCV:
646 #include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
647 break;
648 case ELF::EM_LANAI:
649 #include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
650 break;
651 case ELF::EM_AMDGPU:
652 #include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
653 break;
654 case ELF::EM_BPF:
655 #include "llvm/BinaryFormat/ELFRelocs/BPF.def"
656 break;
657 default:
658 llvm_unreachable("Unsupported architecture");
660 #undef ELF_RELOC
661 IO.enumFallback<Hex32>(Value);
664 void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration(
665 IO &IO, ELFYAML::ELF_DYNTAG &Value) {
666 assert(IO.getContext() && "The IO context is not initialized");
668 // TODO: For simplicity we do not handle target specific flags. They are
669 // still supported and will be shown as a raw numeric values in the output.
670 #define MIPS_DYNAMIC_TAG(name, value)
671 #define HEXAGON_DYNAMIC_TAG(name, value)
672 #define PPC64_DYNAMIC_TAG(name, value)
673 // Also ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
674 #define DYNAMIC_TAG_MARKER(name, value)
676 #define STRINGIFY(X) (#X)
677 #define DYNAMIC_TAG(X, Y) IO.enumCase(Value, STRINGIFY(DT_##X), ELF::DT_##X);
678 #include "llvm/BinaryFormat/DynamicTags.def"
680 #undef MIPS_DYNAMIC_TAG
681 #undef HEXAGON_DYNAMIC_TAG
682 #undef PPC64_DYNAMIC_TAG
683 #undef DYNAMIC_TAG_MARKER
684 #undef STRINGIFY
685 #undef DYNAMIC_TAG
687 IO.enumFallback<Hex64>(Value);
690 void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG>::enumeration(
691 IO &IO, ELFYAML::MIPS_AFL_REG &Value) {
692 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
693 ECase(REG_NONE);
694 ECase(REG_32);
695 ECase(REG_64);
696 ECase(REG_128);
697 #undef ECase
700 void ScalarEnumerationTraits<ELFYAML::MIPS_ABI_FP>::enumeration(
701 IO &IO, ELFYAML::MIPS_ABI_FP &Value) {
702 #define ECase(X) IO.enumCase(Value, #X, Mips::Val_GNU_MIPS_ABI_##X)
703 ECase(FP_ANY);
704 ECase(FP_DOUBLE);
705 ECase(FP_SINGLE);
706 ECase(FP_SOFT);
707 ECase(FP_OLD_64);
708 ECase(FP_XX);
709 ECase(FP_64);
710 ECase(FP_64A);
711 #undef ECase
714 void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_EXT>::enumeration(
715 IO &IO, ELFYAML::MIPS_AFL_EXT &Value) {
716 #define ECase(X) IO.enumCase(Value, #X, Mips::AFL_##X)
717 ECase(EXT_NONE);
718 ECase(EXT_XLR);
719 ECase(EXT_OCTEON2);
720 ECase(EXT_OCTEONP);
721 ECase(EXT_LOONGSON_3A);
722 ECase(EXT_OCTEON);
723 ECase(EXT_5900);
724 ECase(EXT_4650);
725 ECase(EXT_4010);
726 ECase(EXT_4100);
727 ECase(EXT_3900);
728 ECase(EXT_10000);
729 ECase(EXT_SB1);
730 ECase(EXT_4111);
731 ECase(EXT_4120);
732 ECase(EXT_5400);
733 ECase(EXT_5500);
734 ECase(EXT_LOONGSON_2E);
735 ECase(EXT_LOONGSON_2F);
736 ECase(EXT_OCTEON3);
737 #undef ECase
740 void ScalarEnumerationTraits<ELFYAML::MIPS_ISA>::enumeration(
741 IO &IO, ELFYAML::MIPS_ISA &Value) {
742 IO.enumCase(Value, "MIPS1", 1);
743 IO.enumCase(Value, "MIPS2", 2);
744 IO.enumCase(Value, "MIPS3", 3);
745 IO.enumCase(Value, "MIPS4", 4);
746 IO.enumCase(Value, "MIPS5", 5);
747 IO.enumCase(Value, "MIPS32", 32);
748 IO.enumCase(Value, "MIPS64", 64);
751 void ScalarBitSetTraits<ELFYAML::MIPS_AFL_ASE>::bitset(
752 IO &IO, ELFYAML::MIPS_AFL_ASE &Value) {
753 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_ASE_##X)
754 BCase(DSP);
755 BCase(DSPR2);
756 BCase(EVA);
757 BCase(MCU);
758 BCase(MDMX);
759 BCase(MIPS3D);
760 BCase(MT);
761 BCase(SMARTMIPS);
762 BCase(VIRT);
763 BCase(MSA);
764 BCase(MIPS16);
765 BCase(MICROMIPS);
766 BCase(XPA);
767 #undef BCase
770 void ScalarBitSetTraits<ELFYAML::MIPS_AFL_FLAGS1>::bitset(
771 IO &IO, ELFYAML::MIPS_AFL_FLAGS1 &Value) {
772 #define BCase(X) IO.bitSetCase(Value, #X, Mips::AFL_FLAGS1_##X)
773 BCase(ODDSPREG);
774 #undef BCase
777 void MappingTraits<ELFYAML::FileHeader>::mapping(IO &IO,
778 ELFYAML::FileHeader &FileHdr) {
779 IO.mapRequired("Class", FileHdr.Class);
780 IO.mapRequired("Data", FileHdr.Data);
781 IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
782 IO.mapOptional("ABIVersion", FileHdr.ABIVersion, Hex8(0));
783 IO.mapRequired("Type", FileHdr.Type);
784 IO.mapRequired("Machine", FileHdr.Machine);
785 IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
786 IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
789 void MappingTraits<ELFYAML::ProgramHeader>::mapping(
790 IO &IO, ELFYAML::ProgramHeader &Phdr) {
791 IO.mapRequired("Type", Phdr.Type);
792 IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
793 IO.mapOptional("Sections", Phdr.Sections);
794 IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
795 IO.mapOptional("PAddr", Phdr.PAddr, Hex64(0));
796 IO.mapOptional("Align", Phdr.Align);
799 namespace {
801 struct NormalizedOther {
802 NormalizedOther(IO &)
803 : Visibility(ELFYAML::ELF_STV(0)), Other(ELFYAML::ELF_STO(0)) {}
804 NormalizedOther(IO &, uint8_t Original)
805 : Visibility(Original & 0x3), Other(Original & ~0x3) {}
807 uint8_t denormalize(IO &) { return Visibility | Other; }
809 ELFYAML::ELF_STV Visibility;
810 ELFYAML::ELF_STO Other;
813 } // end anonymous namespace
815 void MappingTraits<ELFYAML::Symbol>::mapping(IO &IO, ELFYAML::Symbol &Symbol) {
816 IO.mapOptional("Name", Symbol.Name, StringRef());
817 IO.mapOptional("Type", Symbol.Type, ELFYAML::ELF_STT(0));
818 IO.mapOptional("Section", Symbol.Section, StringRef());
819 IO.mapOptional("Index", Symbol.Index);
820 IO.mapOptional("Value", Symbol.Value, Hex64(0));
821 IO.mapOptional("Size", Symbol.Size, Hex64(0));
823 MappingNormalization<NormalizedOther, uint8_t> Keys(IO, Symbol.Other);
824 IO.mapOptional("Visibility", Keys->Visibility, ELFYAML::ELF_STV(0));
825 IO.mapOptional("Other", Keys->Other, ELFYAML::ELF_STO(0));
828 StringRef MappingTraits<ELFYAML::Symbol>::validate(IO &IO,
829 ELFYAML::Symbol &Symbol) {
830 if (Symbol.Index && Symbol.Section.data()) {
831 return "Index and Section cannot both be specified for Symbol";
833 if (Symbol.Index && *Symbol.Index == ELFYAML::ELF_SHN(ELF::SHN_XINDEX)) {
834 return "Large indexes are not supported";
836 if (Symbol.Index && *Symbol.Index < ELFYAML::ELF_SHN(ELF::SHN_LORESERVE)) {
837 return "Use a section name to define which section a symbol is defined in";
839 return StringRef();
842 void MappingTraits<ELFYAML::LocalGlobalWeakSymbols>::mapping(
843 IO &IO, ELFYAML::LocalGlobalWeakSymbols &Symbols) {
844 IO.mapOptional("Local", Symbols.Local);
845 IO.mapOptional("Global", Symbols.Global);
846 IO.mapOptional("Weak", Symbols.Weak);
849 static void commonSectionMapping(IO &IO, ELFYAML::Section &Section) {
850 IO.mapOptional("Name", Section.Name, StringRef());
851 IO.mapRequired("Type", Section.Type);
852 IO.mapOptional("Flags", Section.Flags, ELFYAML::ELF_SHF(0));
853 IO.mapOptional("Address", Section.Address, Hex64(0));
854 IO.mapOptional("Link", Section.Link, StringRef());
855 IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
856 IO.mapOptional("EntSize", Section.EntSize);
859 static void sectionMapping(IO &IO, ELFYAML::DynamicSection &Section) {
860 commonSectionMapping(IO, Section);
861 IO.mapOptional("Entries", Section.Entries);
864 static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) {
865 commonSectionMapping(IO, Section);
866 IO.mapOptional("Content", Section.Content);
867 IO.mapOptional("Size", Section.Size, Hex64(Section.Content.binary_size()));
870 static void sectionMapping(IO &IO, ELFYAML::NoBitsSection &Section) {
871 commonSectionMapping(IO, Section);
872 IO.mapOptional("Size", Section.Size, Hex64(0));
875 static void sectionMapping(IO &IO, ELFYAML::RelocationSection &Section) {
876 commonSectionMapping(IO, Section);
877 IO.mapOptional("Info", Section.RelocatableSec, StringRef());
878 IO.mapOptional("Relocations", Section.Relocations);
881 static void groupSectionMapping(IO &IO, ELFYAML::Group &Group) {
882 commonSectionMapping(IO, Group);
883 IO.mapOptional("Info", Group.Signature, StringRef());
884 IO.mapRequired("Members", Group.Members);
887 void MappingTraits<ELFYAML::SectionOrType>::mapping(
888 IO &IO, ELFYAML::SectionOrType &sectionOrType) {
889 IO.mapRequired("SectionOrType", sectionOrType.sectionNameOrType);
892 void MappingTraits<ELFYAML::SectionName>::mapping(
893 IO &IO, ELFYAML::SectionName &sectionName) {
894 IO.mapRequired("Section", sectionName.Section);
897 static void sectionMapping(IO &IO, ELFYAML::MipsABIFlags &Section) {
898 commonSectionMapping(IO, Section);
899 IO.mapOptional("Version", Section.Version, Hex16(0));
900 IO.mapRequired("ISA", Section.ISALevel);
901 IO.mapOptional("ISARevision", Section.ISARevision, Hex8(0));
902 IO.mapOptional("ISAExtension", Section.ISAExtension,
903 ELFYAML::MIPS_AFL_EXT(Mips::AFL_EXT_NONE));
904 IO.mapOptional("ASEs", Section.ASEs, ELFYAML::MIPS_AFL_ASE(0));
905 IO.mapOptional("FpABI", Section.FpABI,
906 ELFYAML::MIPS_ABI_FP(Mips::Val_GNU_MIPS_ABI_FP_ANY));
907 IO.mapOptional("GPRSize", Section.GPRSize,
908 ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
909 IO.mapOptional("CPR1Size", Section.CPR1Size,
910 ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
911 IO.mapOptional("CPR2Size", Section.CPR2Size,
912 ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE));
913 IO.mapOptional("Flags1", Section.Flags1, ELFYAML::MIPS_AFL_FLAGS1(0));
914 IO.mapOptional("Flags2", Section.Flags2, Hex32(0));
917 void MappingTraits<std::unique_ptr<ELFYAML::Section>>::mapping(
918 IO &IO, std::unique_ptr<ELFYAML::Section> &Section) {
919 ELFYAML::ELF_SHT sectionType;
920 if (IO.outputting())
921 sectionType = Section->Type;
922 else
923 IO.mapRequired("Type", sectionType);
925 switch (sectionType) {
926 case ELF::SHT_DYNAMIC:
927 if (!IO.outputting())
928 Section.reset(new ELFYAML::DynamicSection());
929 sectionMapping(IO, *cast<ELFYAML::DynamicSection>(Section.get()));
930 break;
931 case ELF::SHT_REL:
932 case ELF::SHT_RELA:
933 if (!IO.outputting())
934 Section.reset(new ELFYAML::RelocationSection());
935 sectionMapping(IO, *cast<ELFYAML::RelocationSection>(Section.get()));
936 break;
937 case ELF::SHT_GROUP:
938 if (!IO.outputting())
939 Section.reset(new ELFYAML::Group());
940 groupSectionMapping(IO, *cast<ELFYAML::Group>(Section.get()));
941 break;
942 case ELF::SHT_NOBITS:
943 if (!IO.outputting())
944 Section.reset(new ELFYAML::NoBitsSection());
945 sectionMapping(IO, *cast<ELFYAML::NoBitsSection>(Section.get()));
946 break;
947 case ELF::SHT_MIPS_ABIFLAGS:
948 if (!IO.outputting())
949 Section.reset(new ELFYAML::MipsABIFlags());
950 sectionMapping(IO, *cast<ELFYAML::MipsABIFlags>(Section.get()));
951 break;
952 default:
953 if (!IO.outputting())
954 Section.reset(new ELFYAML::RawContentSection());
955 sectionMapping(IO, *cast<ELFYAML::RawContentSection>(Section.get()));
959 StringRef MappingTraits<std::unique_ptr<ELFYAML::Section>>::validate(
960 IO &io, std::unique_ptr<ELFYAML::Section> &Section) {
961 const auto *RawSection = dyn_cast<ELFYAML::RawContentSection>(Section.get());
962 if (!RawSection || RawSection->Size >= RawSection->Content.binary_size())
963 return StringRef();
964 return "Section size must be greater or equal to the content size";
967 namespace {
969 struct NormalizedMips64RelType {
970 NormalizedMips64RelType(IO &)
971 : Type(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
972 Type2(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
973 Type3(ELFYAML::ELF_REL(ELF::R_MIPS_NONE)),
974 SpecSym(ELFYAML::ELF_REL(ELF::RSS_UNDEF)) {}
975 NormalizedMips64RelType(IO &, ELFYAML::ELF_REL Original)
976 : Type(Original & 0xFF), Type2(Original >> 8 & 0xFF),
977 Type3(Original >> 16 & 0xFF), SpecSym(Original >> 24 & 0xFF) {}
979 ELFYAML::ELF_REL denormalize(IO &) {
980 ELFYAML::ELF_REL Res = Type | Type2 << 8 | Type3 << 16 | SpecSym << 24;
981 return Res;
984 ELFYAML::ELF_REL Type;
985 ELFYAML::ELF_REL Type2;
986 ELFYAML::ELF_REL Type3;
987 ELFYAML::ELF_RSS SpecSym;
990 } // end anonymous namespace
992 void MappingTraits<ELFYAML::DynamicEntry>::mapping(IO &IO,
993 ELFYAML::DynamicEntry &Rel) {
994 assert(IO.getContext() && "The IO context is not initialized");
996 IO.mapRequired("Tag", Rel.Tag);
997 IO.mapRequired("Value", Rel.Val);
1000 void MappingTraits<ELFYAML::Relocation>::mapping(IO &IO,
1001 ELFYAML::Relocation &Rel) {
1002 const auto *Object = static_cast<ELFYAML::Object *>(IO.getContext());
1003 assert(Object && "The IO context is not initialized");
1005 IO.mapRequired("Offset", Rel.Offset);
1006 IO.mapOptional("Symbol", Rel.Symbol);
1008 if (Object->Header.Machine == ELFYAML::ELF_EM(ELF::EM_MIPS) &&
1009 Object->Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64)) {
1010 MappingNormalization<NormalizedMips64RelType, ELFYAML::ELF_REL> Key(
1011 IO, Rel.Type);
1012 IO.mapRequired("Type", Key->Type);
1013 IO.mapOptional("Type2", Key->Type2, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1014 IO.mapOptional("Type3", Key->Type3, ELFYAML::ELF_REL(ELF::R_MIPS_NONE));
1015 IO.mapOptional("SpecSym", Key->SpecSym, ELFYAML::ELF_RSS(ELF::RSS_UNDEF));
1016 } else
1017 IO.mapRequired("Type", Rel.Type);
1019 IO.mapOptional("Addend", Rel.Addend, (int64_t)0);
1022 void MappingTraits<ELFYAML::Object>::mapping(IO &IO, ELFYAML::Object &Object) {
1023 assert(!IO.getContext() && "The IO context is initialized already");
1024 IO.setContext(&Object);
1025 IO.mapTag("!ELF", true);
1026 IO.mapRequired("FileHeader", Object.Header);
1027 IO.mapOptional("ProgramHeaders", Object.ProgramHeaders);
1028 IO.mapOptional("Sections", Object.Sections);
1029 IO.mapOptional("Symbols", Object.Symbols);
1030 IO.mapOptional("DynamicSymbols", Object.DynamicSymbols);
1031 IO.setContext(nullptr);
1034 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_AFL_REG)
1035 LLVM_YAML_STRONG_TYPEDEF(uint8_t, MIPS_ABI_FP)
1036 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_EXT)
1037 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_ASE)
1038 LLVM_YAML_STRONG_TYPEDEF(uint32_t, MIPS_AFL_FLAGS1)
1040 } // end namespace yaml
1042 } // end namespace llvm