mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-09 21:50:50 +00:00
[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
This commit is contained in:
parent
2c98ad1c24
commit
54530096e5
@ -95,6 +95,7 @@ template <> struct MappingTraits<MachOYAML::Section> {
|
||||
template <> struct ScalarEnumerationTraits<MachO::LoadCommandType> {
|
||||
static void enumeration(IO &io, MachO::LoadCommandType &value) {
|
||||
#include "llvm/Support/MachO.def"
|
||||
io.enumFallback<Hex32>(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -510,11 +510,11 @@ public:
|
||||
|
||||
template <typename FBT, typename T>
|
||||
void enumFallback(T &Val) {
|
||||
if ( matchEnumFallback() ) {
|
||||
if (matchEnumFallback()) {
|
||||
// FIXME: Force integral conversion to allow strong typedefs to convert.
|
||||
FBT Res = (uint64_t)Val;
|
||||
FBT Res = static_cast<typename FBT::BaseType>(Val);
|
||||
yamlize(*this, Res, true);
|
||||
Val = (uint64_t)Res;
|
||||
Val = static_cast<T>(static_cast<typename FBT::BaseType>(Res));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1168,6 +1168,7 @@ private:
|
||||
bool operator==(const _base &rhs) const { return value == rhs; } \
|
||||
bool operator<(const _type &rhs) const { return value < rhs.value; } \
|
||||
_base value; \
|
||||
typedef _base BaseType; \
|
||||
};
|
||||
|
||||
///
|
||||
|
51
test/ObjectYAML/MachO/bogus_load_command.yaml
Normal file
51
test/ObjectYAML/MachO/bogus_load_command.yaml
Normal file
@ -0,0 +1,51 @@
|
||||
# RUN: yaml2obj -format=macho %s | obj2yaml | FileCheck %s
|
||||
|
||||
--- !mach-o
|
||||
FileHeader:
|
||||
magic: 0xFEEDFACF
|
||||
cputype: 0x01000007
|
||||
cpusubtype: 0x80000003
|
||||
filetype: 0x00000002
|
||||
ncmds: 2
|
||||
sizeofcmds: 56
|
||||
flags: 0x00218085
|
||||
reserved: 0x00000000
|
||||
LoadCommands:
|
||||
- cmd: 0xDEADBEEF
|
||||
cmdsize: 32
|
||||
ZeroPadBytes: 24
|
||||
- cmd: 0xDEADBEEF
|
||||
cmdsize: 24
|
||||
PayloadBytes:
|
||||
- 0x01
|
||||
- 0x02
|
||||
- 0x03
|
||||
- 0x04
|
||||
- 0x05
|
||||
- 0x06
|
||||
- 0x07
|
||||
- 0x08
|
||||
- 0x09
|
||||
- 0x0A
|
||||
- 0x0B
|
||||
- 0x0C
|
||||
...
|
||||
|
||||
#CHECK: - cmd: 0xDEADBEEF
|
||||
#CHECK: cmdsize: 32
|
||||
#CHECK: ZeroPadBytes:
|
||||
#CHECK: - cmd: 0xDEADBEEF
|
||||
#CHECK: cmdsize: 24
|
||||
#CHECK: PayloadBytes:
|
||||
#CHECK: - 0x01
|
||||
#CHECK: - 0x02
|
||||
#CHECK: - 0x03
|
||||
#CHECK: - 0x04
|
||||
#CHECK: - 0x05
|
||||
#CHECK: - 0x06
|
||||
#CHECK: - 0x07
|
||||
#CHECK: - 0x08
|
||||
#CHECK: - 0x09
|
||||
#CHECK: - 0x0A
|
||||
#CHECK: - 0x0B
|
||||
#CHECK: - 0x0C
|
Loading…
Reference in New Issue
Block a user