llvm.org GIT mirror llvm / 5453009
[obj2yaml][yaml2obj] Adding enumFallback for MachO load commands This adds support for handling unknown load commands, and a bogus_load_command tests. Unknown or unsupported load commands can be specified in YAML by their hex value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270239 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 3 years ago
3 changed file(s) with 56 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
9494 template <> struct ScalarEnumerationTraits {
9595 static void enumeration(IO &io, MachO::LoadCommandType &value) {
9696 #include "llvm/Support/MachO.def"
97 io.enumFallback(value);
9798 }
9899 };
99100
509509
510510 template
511511 void enumFallback(T &Val) {
512 if ( matchEnumFallback() ) {
512 if (matchEnumFallback()) {
513513 // FIXME: Force integral conversion to allow strong typedefs to convert.
514 FBT Res = (uint64_t)Val;
514 FBT Res = static_cast(Val);
515515 yamlize(*this, Res, true);
516 Val = (uint64_t)Res;
516 Val = static_cast(static_cast(Res));
517517 }
518518 }
519519
11671167 bool operator==(const _base &rhs) const { return value == rhs; } \
11681168 bool operator<(const _type &rhs) const { return value < rhs.value; } \
11691169 _base value; \
1170 typedef _base BaseType; \
11701171 };
11711172
11721173 ///
0 # RUN: yaml2obj -format=macho %s | obj2yaml | FileCheck %s
1
2 --- !mach-o
3 FileHeader:
4 magic: 0xFEEDFACF
5 cputype: 0x01000007
6 cpusubtype: 0x80000003
7 filetype: 0x00000002
8 ncmds: 2
9 sizeofcmds: 56
10 flags: 0x00218085
11 reserved: 0x00000000
12 LoadCommands:
13 - cmd: 0xDEADBEEF
14 cmdsize: 32
15 ZeroPadBytes: 24
16 - cmd: 0xDEADBEEF
17 cmdsize: 24
18 PayloadBytes:
19 - 0x01
20 - 0x02
21 - 0x03
22 - 0x04
23 - 0x05
24 - 0x06
25 - 0x07
26 - 0x08
27 - 0x09
28 - 0x0A
29 - 0x0B
30 - 0x0C
31 ...
32
33 #CHECK: - cmd: 0xDEADBEEF
34 #CHECK: cmdsize: 32
35 #CHECK: ZeroPadBytes:
36 #CHECK: - cmd: 0xDEADBEEF
37 #CHECK: cmdsize: 24
38 #CHECK: PayloadBytes:
39 #CHECK: - 0x01
40 #CHECK: - 0x02
41 #CHECK: - 0x03
42 #CHECK: - 0x04
43 #CHECK: - 0x05
44 #CHECK: - 0x06
45 #CHECK: - 0x07
46 #CHECK: - 0x08
47 #CHECK: - 0x09
48 #CHECK: - 0x0A
49 #CHECK: - 0x0B
50 #CHECK: - 0x0C