summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ObjectYAML/MachOYAML.h3
-rw-r--r--llvm/lib/ObjectYAML/MachOYAML.cpp4
-rw-r--r--llvm/tools/obj2yaml/macho2yaml.cpp2
3 files changed, 8 insertions, 1 deletions
diff --git a/llvm/include/llvm/ObjectYAML/MachOYAML.h b/llvm/include/llvm/ObjectYAML/MachOYAML.h
index bf1d274b885..5eaeb58739a 100644
--- a/llvm/include/llvm/ObjectYAML/MachOYAML.h
+++ b/llvm/include/llvm/ObjectYAML/MachOYAML.h
@@ -23,11 +23,14 @@ namespace llvm {
namespace MachOYAML {
struct FileHeader {
+ llvm::yaml::Hex32 magic;
llvm::yaml::Hex32 cputype;
llvm::yaml::Hex32 cpusubtype;
llvm::yaml::Hex32 filetype;
uint32_t ncmds;
+ uint32_t sizeofcmds;
llvm::yaml::Hex32 flags;
+ // TODO: Need to handle the reserved field in mach_header_64
};
struct Object {
diff --git a/llvm/lib/ObjectYAML/MachOYAML.cpp b/llvm/lib/ObjectYAML/MachOYAML.cpp
index 91d9583c98e..0ef716047c8 100644
--- a/llvm/lib/ObjectYAML/MachOYAML.cpp
+++ b/llvm/lib/ObjectYAML/MachOYAML.cpp
@@ -20,10 +20,12 @@ namespace yaml {
void MappingTraits<MachOYAML::FileHeader>::mapping(
IO &IO, MachOYAML::FileHeader &FileHdr) {
+ IO.mapRequired("magic", FileHdr.magic);
IO.mapRequired("cputype", FileHdr.cputype);
IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
IO.mapOptional("filetype", FileHdr.filetype);
IO.mapRequired("ncmds", FileHdr.ncmds);
+ IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
IO.mapRequired("flags", FileHdr.flags);
}
@@ -31,7 +33,7 @@ void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
MachOYAML::Object &Object) {
// If the context isn't already set, tag the document as !mach-o.
// For Fat files there will be a different tag so they can be differentiated.
- if(!IO.getContext()) {
+ if (!IO.getContext()) {
IO.setContext(&Object);
IO.mapTag("!mach-o", true);
}
diff --git a/llvm/tools/obj2yaml/macho2yaml.cpp b/llvm/tools/obj2yaml/macho2yaml.cpp
index dedfb631505..5acb8af7025 100644
--- a/llvm/tools/obj2yaml/macho2yaml.cpp
+++ b/llvm/tools/obj2yaml/macho2yaml.cpp
@@ -26,10 +26,12 @@ public:
Expected<MachOYAML::Object *> MachODumper::dump() {
auto Y = make_unique<MachOYAML::Object>();
+ Y->Header.magic = Obj.getHeader().magic;
Y->Header.cputype = Obj.getHeader().cputype;
Y->Header.cpusubtype = Obj.getHeader().cpusubtype;
Y->Header.filetype = Obj.getHeader().filetype;
Y->Header.ncmds = Obj.getHeader().ncmds;
+ Y->Header.sizeofcmds = Obj.getHeader().sizeofcmds;
Y->Header.flags = Obj.getHeader().flags;
return Y.release();
OpenPOWER on IntegriCloud