summaryrefslogtreecommitdiffstats
path: root/llvm/tools/yaml2obj/yaml2macho.cpp
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-05-12 18:21:09 +0000
committerChris Bieneman <beanz@apple.com>2016-05-12 18:21:09 +0000
commitfc8892771e3610d84220221ecf074f471ec0a208 (patch)
treedb636f330030a53fd08a286cebf66be4af3eca30 /llvm/tools/yaml2obj/yaml2macho.cpp
parent26e6cea9068cd2184831c3a1f81987c265f50caa (diff)
downloadbcm5719-llvm-fc8892771e3610d84220221ecf074f471ec0a208.tar.gz
bcm5719-llvm-fc8892771e3610d84220221ecf074f471ec0a208.zip
[yaml2macho] Handle mach_header_64 reserved field
I've added the reserved field as an "optional" in YAML, but I've added asserts in the yaml2macho code to enforce that the field is present in mach_header_64, but not in mach_header. llvm-svn: 269320
Diffstat (limited to 'llvm/tools/yaml2obj/yaml2macho.cpp')
-rw-r--r--llvm/tools/yaml2obj/yaml2macho.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp
index d5d9642916f..8437475a411 100644
--- a/llvm/tools/yaml2obj/yaml2macho.cpp
+++ b/llvm/tools/yaml2obj/yaml2macho.cpp
@@ -30,6 +30,10 @@ public:
Obj.Header.magic == MachO::MH_CIGAM_64;
memset(reinterpret_cast<void *>(&Header64), 0,
sizeof(MachO::mach_header_64));
+ assert((is64Bit || Obj.Header.reserved == 0xDEADBEEFu) &&
+ "32-bit MachO has reserved in header");
+ assert((!is64Bit || Obj.Header.reserved != 0xDEADBEEFu) &&
+ "64-bit MachO has missing reserved in header");
}
Error writeMachO(raw_ostream &OS);
@@ -60,9 +64,11 @@ Error MachOWriter::writeHeader(raw_ostream &OS) {
Header.ncmds = Obj.Header.ncmds;
Header.sizeofcmds = Obj.Header.sizeofcmds;
Header.flags = Obj.Header.flags;
+ Header64.reserved = Obj.Header.reserved;
- if (is64Bit)
+ if (is64Bit) {
OS.write((const char *)&Header64, sizeof(MachO::mach_header_64));
+ }
else
OS.write((const char *)&Header, sizeof(MachO::mach_header));
OpenPOWER on IntegriCloud