<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Committed r273627 which should prevent this warning.<div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 23, 2016, at 3:57 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" class="">chisophugis@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 23, 2016 at 3:01 PM, Chris Bieneman <span dir="ltr" class=""><<a href="mailto:beanz@apple.com" target="_blank" class="">beanz@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jun 23, 2016, at 2:40 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">It seems like this commit violates strict aliasing (which is UB).</div><div class=""><br class=""></div><div class=""><div class="">/home/sean/pg/llvm-project/llvm-project/llvm/lib/ObjectYAML/MachOYAML.cpp:184:75: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]</div><div class=""> "cmd", (MachO::LoadCommandType &)LoadCommand.Data.load_command_data.cmd);</div><div class=""> ^</div><div class="">Can you fix it? A safe fix is to have a local variable of MachO::LoadCommandType and memcpy'ing the data in/out of it as needed.</div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">I’m pretty sure this is actually a gcc bug. LoadCommandType is a uint32_t</div></div></div></blockquote><div class=""><br class=""></div><div class="">Not quite; it is an enum (albeit one with explicit underlying type). I'm not sure about the rules for enums with explicit underlying type. This post gives a pretty convincing argument that in fact it is treated as a different type from an aliasing perspective: <a href="http://stackoverflow.com/a/24634262" class="">http://stackoverflow.com/a/24634262</a></div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="">, so the cast is from uint32_t to uint32_t, which shouldn’t violate aliasing rules.</div><div class=""><br class=""></div><div class="">When I build with -Wstrict-aliasing and ubsan using clang I don’t see any issues.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Regardless, this causes us to have a non-warning-free build. Could you fix it?</div><div class=""><br class=""></div><div class="">-- Sean Silva</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">-Chris</div></font></span><div class=""><div class="h5"><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, May 17, 2016 at 12:44 PM, Chris Bieneman via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Author: cbieneman<br class="">
Date: Tue May 17 14:44:06 2016<br class="">
New Revision: 269808<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=269808&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=269808&view=rev</a><br class="">
Log:<br class="">
Reapply r269782 "[obj2yaml] [yaml2obj] Support for MachO load command structures""<br class="">
<br class="">
This adds support for all the MachO *_command structures. The load_command payloads still are not represented, but that will come next.<br class="">
<br class="">
Modified:<br class="">
llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h<br class="">
llvm/trunk/include/llvm/Support/MachO.def<br class="">
llvm/trunk/include/llvm/Support/MachO.h<br class="">
llvm/trunk/lib/ObjectYAML/MachOYAML.cpp<br class="">
llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml<br class="">
llvm/trunk/tools/obj2yaml/macho2yaml.cpp<br class="">
llvm/trunk/tools/yaml2obj/yaml2macho.cpp<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h (original)<br class="">
+++ llvm/trunk/include/llvm/ObjectYAML/MachOYAML.h Tue May 17 14:44:06 2016<br class="">
@@ -35,19 +35,18 @@ struct FileHeader {<br class="">
<br class="">
struct LoadCommand {<br class="">
virtual ~LoadCommand();<br class="">
- MachO::LoadCommandType cmd;<br class="">
- uint32_t cmdsize;<br class="">
+ llvm::MachO::macho_load_command Data;<br class="">
};<br class="">
<br class="">
struct Object {<br class="">
FileHeader Header;<br class="">
- std::vector<std::unique_ptr<LoadCommand>> LoadCommands;<br class="">
+ std::vector<LoadCommand> LoadCommands;<br class="">
};<br class="">
<br class="">
} // namespace llvm::MachOYAML<br class="">
} // namespace llvm<br class="">
<br class="">
-LLVM_YAML_IS_SEQUENCE_VECTOR(std::unique_ptr<llvm::MachOYAML::LoadCommand>)<br class="">
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::MachOYAML::LoadCommand)<br class="">
<br class="">
namespace llvm {<br class="">
namespace yaml {<br class="">
@@ -60,12 +59,11 @@ template <> struct MappingTraits<MachOYA<br class="">
static void mapping(IO &IO, MachOYAML::Object &Object);<br class="">
};<br class="">
<br class="">
-template <> struct MappingTraits<std::unique_ptr<MachOYAML::LoadCommand>> {<br class="">
- static void mapping(IO &IO,<br class="">
- std::unique_ptr<MachOYAML::LoadCommand> &LoadCommand);<br class="">
+template <> struct MappingTraits<MachOYAML::LoadCommand> {<br class="">
+ static void mapping(IO &IO, MachOYAML::LoadCommand &LoadCommand);<br class="">
};<br class="">
<br class="">
-#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \<br class="">
+#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \<br class="">
io.enumCase(value, #LCName, MachO::LCName);<br class="">
<br class="">
template <> struct ScalarEnumerationTraits<MachO::LoadCommandType> {<br class="">
@@ -74,7 +72,52 @@ template <> struct ScalarEnumerationTrai<br class="">
}<br class="">
};<br class="">
<br class="">
-#undef HANDLE_LOAD_COMMAND<br class="">
+// This trait is used for 16-byte chars in Mach structures used for strings<br class="">
+typedef char char_16[16];<br class="">
+<br class="">
+template <> struct ScalarTraits<char_16> {<br class="">
+ static void output(const char_16 &Val, void *, llvm::raw_ostream &Out);<br class="">
+<br class="">
+ static StringRef input(StringRef Scalar, void *, char_16 &Val);<br class="">
+ static bool mustQuote(StringRef S);<br class="">
+};<br class="">
+<br class="">
+// This trait is used for UUIDs. It reads and writes them matching otool's<br class="">
+// formatting style.<br class="">
+typedef uint8_t uuid_t[16];<br class="">
+<br class="">
+template <> struct ScalarTraits<uuid_t> {<br class="">
+ static void output(const uuid_t &Val, void *, llvm::raw_ostream &Out);<br class="">
+<br class="">
+ static StringRef input(StringRef Scalar, void *, uuid_t &Val);<br class="">
+ static bool mustQuote(StringRef S);<br class="">
+};<br class="">
+<br class="">
+// Load Command struct mapping traits<br class="">
+<br class="">
+#define LOAD_COMMAND_STRUCT(LCStruct) \<br class="">
+ template <> struct MappingTraits<MachO::LCStruct> { \<br class="">
+ static void mapping(IO &IO, MachO::LCStruct &LoadCommand); \<br class="">
+ };<br class="">
+<br class="">
+#include "llvm/Support/MachO.def"<br class="">
+<br class="">
+// Extra structures used by load commands<br class="">
+template <> struct MappingTraits<MachO::dylib> {<br class="">
+ static void mapping(IO &IO, MachO::dylib &LoadCommand);<br class="">
+};<br class="">
+<br class="">
+template <> struct MappingTraits<MachO::fvmlib> {<br class="">
+ static void mapping(IO &IO, MachO::fvmlib &LoadCommand);<br class="">
+};<br class="">
+<br class="">
+template <> struct MappingTraits<MachO::section> {<br class="">
+ static void mapping(IO &IO, MachO::section &LoadCommand);<br class="">
+};<br class="">
+<br class="">
+template <> struct MappingTraits<MachO::section_64> {<br class="">
+ static void mapping(IO &IO, MachO::section_64 &LoadCommand);<br class="">
+};<br class="">
<br class="">
} // namespace llvm::yaml<br class="">
<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/Support/MachO.def<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MachO.def?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MachO.def?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/Support/MachO.def (original)<br class="">
+++ llvm/trunk/include/llvm/Support/MachO.def Tue May 17 14:44:06 2016<br class="">
@@ -11,9 +11,7 @@<br class="">
//<br class="">
//,,,----------------------------------------------------------------------,,,//<br class="">
<br class="">
-#ifndef HANDLE_LOAD_COMMAND<br class="">
-#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct)<br class="">
-#endif<br class="">
+#ifdef HANDLE_LOAD_COMMAND<br class="">
<br class="">
HANDLE_LOAD_COMMAND(LC_SEGMENT, 0x00000001u, segment_command)<br class="">
HANDLE_LOAD_COMMAND(LC_SYMTAB, 0x00000002u, symtab_command)<br class="">
@@ -65,3 +63,44 @@ HANDLE_LOAD_COMMAND(LC_LINKER_OPTION, 0x<br class="">
HANDLE_LOAD_COMMAND(LC_LINKER_OPTIMIZATION_HINT, 0x0000002Eu, linkedit_data_command)<br class="">
HANDLE_LOAD_COMMAND(LC_VERSION_MIN_TVOS, 0x0000002Fu, version_min_command)<br class="">
HANDLE_LOAD_COMMAND(LC_VERSION_MIN_WATCHOS, 0x00000030u, version_min_command)<br class="">
+<br class="">
+#endif<br class="">
+<br class="">
+#ifdef LOAD_COMMAND_STRUCT<br class="">
+<br class="">
+LOAD_COMMAND_STRUCT(dyld_info_command)<br class="">
+LOAD_COMMAND_STRUCT(dylib_command)<br class="">
+LOAD_COMMAND_STRUCT(dylinker_command)<br class="">
+LOAD_COMMAND_STRUCT(dysymtab_command)<br class="">
+LOAD_COMMAND_STRUCT(encryption_info_command)<br class="">
+LOAD_COMMAND_STRUCT(encryption_info_command_64)<br class="">
+LOAD_COMMAND_STRUCT(entry_point_command)<br class="">
+LOAD_COMMAND_STRUCT(fvmfile_command)<br class="">
+LOAD_COMMAND_STRUCT(fvmlib_command)<br class="">
+LOAD_COMMAND_STRUCT(ident_command)<br class="">
+LOAD_COMMAND_STRUCT(linkedit_data_command)<br class="">
+LOAD_COMMAND_STRUCT(linker_option_command)<br class="">
+LOAD_COMMAND_STRUCT(load_command)<br class="">
+LOAD_COMMAND_STRUCT(prebind_cksum_command)<br class="">
+LOAD_COMMAND_STRUCT(prebound_dylib_command)<br class="">
+LOAD_COMMAND_STRUCT(routines_command)<br class="">
+LOAD_COMMAND_STRUCT(routines_command_64)<br class="">
+LOAD_COMMAND_STRUCT(rpath_command)<br class="">
+LOAD_COMMAND_STRUCT(segment_command)<br class="">
+LOAD_COMMAND_STRUCT(segment_command_64)<br class="">
+LOAD_COMMAND_STRUCT(source_version_command)<br class="">
+LOAD_COMMAND_STRUCT(sub_client_command)<br class="">
+LOAD_COMMAND_STRUCT(sub_framework_command)<br class="">
+LOAD_COMMAND_STRUCT(sub_library_command)<br class="">
+LOAD_COMMAND_STRUCT(sub_umbrella_command)<br class="">
+LOAD_COMMAND_STRUCT(symseg_command)<br class="">
+LOAD_COMMAND_STRUCT(symtab_command)<br class="">
+LOAD_COMMAND_STRUCT(thread_command)<br class="">
+LOAD_COMMAND_STRUCT(twolevel_hints_command)<br class="">
+LOAD_COMMAND_STRUCT(uuid_command)<br class="">
+LOAD_COMMAND_STRUCT(version_min_command)<br class="">
+<br class="">
+#endif<br class="">
+<br class="">
+#undef HANDLE_LOAD_COMMAND<br class="">
+#undef LOAD_COMMAND_STRUCT<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/Support/MachO.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MachO.h?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MachO.h?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/Support/MachO.h (original)<br class="">
+++ llvm/trunk/include/llvm/Support/MachO.h Tue May 17 14:44:06 2016<br class="">
@@ -1677,6 +1677,13 @@ namespace llvm {<br class="">
const uint32_t x86_EXCEPTION_STATE_COUNT =<br class="">
sizeof(x86_exception_state_t) / sizeof(uint32_t);<br class="">
<br class="">
+ // Define a union of all load command structs<br class="">
+ #define LOAD_COMMAND_STRUCT(LCStruct) LCStruct LCStruct##_data;<br class="">
+<br class="">
+ union macho_load_command {<br class="">
+ #include "llvm/Support/MachO.def"<br class="">
+ };<br class="">
+<br class="">
} // end namespace MachO<br class="">
} // end namespace llvm<br class="">
<br class="">
<br class="">
Modified: llvm/trunk/lib/ObjectYAML/MachOYAML.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/MachOYAML.cpp?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/MachOYAML.cpp?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/ObjectYAML/MachOYAML.cpp (original)<br class="">
+++ llvm/trunk/lib/ObjectYAML/MachOYAML.cpp Tue May 17 14:44:06 2016<br class="">
@@ -13,6 +13,9 @@<br class="">
<br class="">
#include "llvm/ObjectYAML/MachOYAML.h"<br class="">
#include "llvm/Support/Casting.h"<br class="">
+#include "llvm/Support/Format.h"<br class="">
+<br class="">
+#include <string.h> // For memcpy and memset.<br class="">
<br class="">
namespace llvm {<br class="">
<br class="">
@@ -20,6 +23,52 @@ MachOYAML::LoadCommand::~LoadCommand() {<br class="">
<br class="">
namespace yaml {<br class="">
<br class="">
+void ScalarTraits<char_16>::output(const char_16 &Val, void *,<br class="">
+ llvm::raw_ostream &Out) {<br class="">
+ Out << Val;<br class="">
+}<br class="">
+<br class="">
+StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {<br class="">
+ size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();<br class="">
+ memcpy((void *)Val, Scalar.data(), CopySize);<br class="">
+<br class="">
+ if (Scalar.size() < 16) {<br class="">
+ memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());<br class="">
+ }<br class="">
+<br class="">
+ return StringRef();<br class="">
+}<br class="">
+<br class="">
+bool ScalarTraits<char_16>::mustQuote(StringRef S) { return needsQuotes(S); }<br class="">
+<br class="">
+void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *,<br class="">
+ llvm::raw_ostream &Out) {<br class="">
+ for (int Idx = 0; Idx < 16; ++Idx) {<br class="">
+ Out << format("%02" PRIX32, Val[Idx]);<br class="">
+ if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)<br class="">
+ Out << "-";<br class="">
+ }<br class="">
+}<br class="">
+<br class="">
+StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {<br class="">
+ size_t OutIdx = 0;<br class="">
+ for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {<br class="">
+ if (Scalar[Idx] == '-' || OutIdx >= 16)<br class="">
+ continue;<br class="">
+ unsigned long long TempInt;<br class="">
+ if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))<br class="">
+ return "invalid number";<br class="">
+ if (TempInt > 0xFF)<br class="">
+ return "out of range number";<br class="">
+ Val[OutIdx] = static_cast<uint8_t>(TempInt);<br class="">
+ ++Idx; // increment idx an extra time because we're consuming 2 chars<br class="">
+ ++OutIdx;<br class="">
+ }<br class="">
+ return StringRef();<br class="">
+}<br class="">
+<br class="">
+bool ScalarTraits<uuid_t>::mustQuote(StringRef S) { return needsQuotes(S); }<br class="">
+<br class="">
void MappingTraits<MachOYAML::FileHeader>::mapping(<br class="">
IO &IO, MachOYAML::FileHeader &FileHdr) {<br class="">
IO.mapRequired("magic", FileHdr.magic);<br class="">
@@ -46,12 +95,310 @@ void MappingTraits<MachOYAML::Object>::m<br class="">
IO.setContext(nullptr);<br class="">
}<br class="">
<br class="">
-void MappingTraits<std::unique_ptr<MachOYAML::LoadCommand>>::mapping(<br class="">
- IO &IO, std::unique_ptr<MachOYAML::LoadCommand> &LoadCommand) {<br class="">
- if (!IO.outputting())<br class="">
- LoadCommand.reset(new MachOYAML::LoadCommand());<br class="">
- IO.mapRequired("cmd", LoadCommand->cmd);<br class="">
- IO.mapRequired("cmdsize", LoadCommand->cmdsize);<br class="">
+void MappingTraits<MachOYAML::LoadCommand>::mapping(<br class="">
+ IO &IO, MachOYAML::LoadCommand &LoadCommand) {<br class="">
+ IO.mapRequired(<br class="">
+ "cmd", (MachO::LoadCommandType &)LoadCommand.Data.load_command_data.cmd);<br class="">
+ IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);<br class="">
+<br class="">
+#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \<br class="">
+ case MachO::LCName: \<br class="">
+ MappingTraits<MachO::LCStruct>::mapping(IO, \<br class="">
+ LoadCommand.Data.LCStruct##_data); \<br class="">
+ break;<br class="">
+<br class="">
+ switch (LoadCommand.Data.load_command_data.cmd) {<br class="">
+#include "llvm/Support/MachO.def"<br class="">
+ }<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::dyld_info_command>::mapping(<br class="">
+ IO &IO, MachO::dyld_info_command &LoadCommand) {<br class="">
+ IO.mapRequired("rebase_off", LoadCommand.rebase_off);<br class="">
+ IO.mapRequired("rebase_size", LoadCommand.rebase_size);<br class="">
+ IO.mapRequired("bind_off", LoadCommand.bind_size);<br class="">
+ IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);<br class="">
+ IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);<br class="">
+ IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_size);<br class="">
+ IO.mapRequired("export_off", LoadCommand.export_off);<br class="">
+ IO.mapRequired("export_size", LoadCommand.export_size);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {<br class="">
+ IO.mapRequired("name", DylibStruct.name);<br class="">
+ IO.mapRequired("timestamp", DylibStruct.timestamp);<br class="">
+ IO.mapRequired("current_version", DylibStruct.current_version);<br class="">
+ IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::dylib_command>::mapping(<br class="">
+ IO &IO, MachO::dylib_command &LoadCommand) {<br class="">
+ IO.mapRequired("dylib", LoadCommand.dylib);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::dylinker_command>::mapping(<br class="">
+ IO &IO, MachO::dylinker_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("name", LoadCommand.name);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::dysymtab_command>::mapping(<br class="">
+ IO &IO, MachO::dysymtab_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);<br class="">
+ IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);<br class="">
+ IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);<br class="">
+ IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);<br class="">
+ IO.mapRequired("iundefsym", LoadCommand.iundefsym);<br class="">
+ IO.mapRequired("nundefsym", LoadCommand.nundefsym);<br class="">
+ IO.mapRequired("tocoff", LoadCommand.tocoff);<br class="">
+ IO.mapRequired("ntoc", LoadCommand.ntoc);<br class="">
+ IO.mapRequired("modtaboff", LoadCommand.modtaboff);<br class="">
+ IO.mapRequired("nmodtab", LoadCommand.nmodtab);<br class="">
+ IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);<br class="">
+ IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);<br class="">
+ IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);<br class="">
+ IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);<br class="">
+ IO.mapRequired("extreloff", LoadCommand.extreloff);<br class="">
+ IO.mapRequired("nextrel", LoadCommand.nextrel);<br class="">
+ IO.mapRequired("locreloff", LoadCommand.locreloff);<br class="">
+ IO.mapRequired("nlocrel", LoadCommand.nlocrel);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::encryption_info_command>::mapping(<br class="">
+ IO &IO, MachO::encryption_info_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("cryptoff", LoadCommand.cryptoff);<br class="">
+ IO.mapRequired("cryptsize", LoadCommand.cryptsize);<br class="">
+ IO.mapRequired("cryptid", LoadCommand.cryptid);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::encryption_info_command_64>::mapping(<br class="">
+ IO &IO, MachO::encryption_info_command_64 &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("cryptoff", LoadCommand.cryptoff);<br class="">
+ IO.mapRequired("cryptsize", LoadCommand.cryptsize);<br class="">
+ IO.mapRequired("cryptid", LoadCommand.cryptid);<br class="">
+ IO.mapRequired("pad", LoadCommand.pad);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::entry_point_command>::mapping(<br class="">
+ IO &IO, MachO::entry_point_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("entryoff", LoadCommand.entryoff);<br class="">
+ IO.mapRequired("stacksize", LoadCommand.stacksize);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::fvmfile_command>::mapping(<br class="">
+ IO &IO, MachO::fvmfile_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("name", LoadCommand.name);<br class="">
+ IO.mapRequired("header_addr", LoadCommand.header_addr);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {<br class="">
+ IO.mapRequired("name", FVMLib.name);<br class="">
+ IO.mapRequired("minor_version", FVMLib.minor_version);<br class="">
+ IO.mapRequired("header_addr", FVMLib.header_addr);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::fvmlib_command>::mapping(<br class="">
+ IO &IO, MachO::fvmlib_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("fvmlib", LoadCommand.fvmlib);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::ident_command>::mapping(<br class="">
+ IO &IO, MachO::ident_command &LoadCommand) {}<br class="">
+<br class="">
+void MappingTraits<MachO::linkedit_data_command>::mapping(<br class="">
+ IO &IO, MachO::linkedit_data_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("dataoff", LoadCommand.dataoff);<br class="">
+ IO.mapRequired("datasize", LoadCommand.datasize);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::linker_option_command>::mapping(<br class="">
+ IO &IO, MachO::linker_option_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("count", LoadCommand.count);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::prebind_cksum_command>::mapping(<br class="">
+ IO &IO, MachO::prebind_cksum_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("cksum", LoadCommand.cksum);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::load_command>::mapping(<br class="">
+ IO &IO, MachO::load_command &LoadCommand) {}<br class="">
+<br class="">
+void MappingTraits<MachO::prebound_dylib_command>::mapping(<br class="">
+ IO &IO, MachO::prebound_dylib_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("name", LoadCommand.name);<br class="">
+ IO.mapRequired("nmodules", LoadCommand.nmodules);<br class="">
+ IO.mapRequired("linked_modules", LoadCommand.linked_modules);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::routines_command>::mapping(<br class="">
+ IO &IO, MachO::routines_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("init_address", LoadCommand.init_address);<br class="">
+ IO.mapRequired("init_module", LoadCommand.init_module);<br class="">
+ IO.mapRequired("reserved1", LoadCommand.reserved1);<br class="">
+ IO.mapRequired("reserved2", LoadCommand.reserved2);<br class="">
+ IO.mapRequired("reserved3", LoadCommand.reserved3);<br class="">
+ IO.mapRequired("reserved4", LoadCommand.reserved4);<br class="">
+ IO.mapRequired("reserved5", LoadCommand.reserved5);<br class="">
+ IO.mapRequired("reserved6", LoadCommand.reserved6);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::routines_command_64>::mapping(<br class="">
+ IO &IO, MachO::routines_command_64 &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("init_address", LoadCommand.init_address);<br class="">
+ IO.mapRequired("init_module", LoadCommand.init_module);<br class="">
+ IO.mapRequired("reserved1", LoadCommand.reserved1);<br class="">
+ IO.mapRequired("reserved2", LoadCommand.reserved2);<br class="">
+ IO.mapRequired("reserved3", LoadCommand.reserved3);<br class="">
+ IO.mapRequired("reserved4", LoadCommand.reserved4);<br class="">
+ IO.mapRequired("reserved5", LoadCommand.reserved5);<br class="">
+ IO.mapRequired("reserved6", LoadCommand.reserved6);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::rpath_command>::mapping(<br class="">
+ IO &IO, MachO::rpath_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("path", LoadCommand.path);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {<br class="">
+ IO.mapRequired("sectname", Section.sectname);<br class="">
+ IO.mapRequired("segname", Section.segname);<br class="">
+ IO.mapRequired("addr", Section.addr);<br class="">
+ IO.mapRequired("size", Section.size);<br class="">
+ IO.mapRequired("offset", Section.offset);<br class="">
+ IO.mapRequired("align", Section.align);<br class="">
+ IO.mapRequired("reloff", Section.reloff);<br class="">
+ IO.mapRequired("nreloc", Section.nreloc);<br class="">
+ IO.mapRequired("flags", Section.flags);<br class="">
+ IO.mapRequired("reserved1", Section.reserved1);<br class="">
+ IO.mapRequired("reserved2", Section.reserved2);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::section_64>::mapping(IO &IO,<br class="">
+ MachO::section_64 &Section) {<br class="">
+ IO.mapRequired("sectname", Section.sectname);<br class="">
+ IO.mapRequired("segname", Section.segname);<br class="">
+ IO.mapRequired("addr", Section.addr);<br class="">
+ IO.mapRequired("size", Section.size);<br class="">
+ IO.mapRequired("offset", Section.offset);<br class="">
+ IO.mapRequired("align", Section.align);<br class="">
+ IO.mapRequired("reloff", Section.reloff);<br class="">
+ IO.mapRequired("nreloc", Section.nreloc);<br class="">
+ IO.mapRequired("flags", Section.flags);<br class="">
+ IO.mapRequired("reserved1", Section.reserved1);<br class="">
+ IO.mapRequired("reserved2", Section.reserved2);<br class="">
+ IO.mapRequired("reserved3", Section.reserved3);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::segment_command>::mapping(<br class="">
+ IO &IO, MachO::segment_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("segname", LoadCommand.segname);<br class="">
+ IO.mapRequired("vmaddr", LoadCommand.vmaddr);<br class="">
+ IO.mapRequired("vmsize", LoadCommand.vmsize);<br class="">
+ IO.mapRequired("fileoff", LoadCommand.fileoff);<br class="">
+ IO.mapRequired("filesize", LoadCommand.filesize);<br class="">
+ IO.mapRequired("maxprot", LoadCommand.maxprot);<br class="">
+ IO.mapRequired("initprot", LoadCommand.initprot);<br class="">
+ IO.mapRequired("nsects", LoadCommand.nsects);<br class="">
+ IO.mapRequired("flags", LoadCommand.flags);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::segment_command_64>::mapping(<br class="">
+ IO &IO, MachO::segment_command_64 &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("segname", LoadCommand.segname);<br class="">
+ IO.mapRequired("vmaddr", LoadCommand.vmaddr);<br class="">
+ IO.mapRequired("vmsize", LoadCommand.vmsize);<br class="">
+ IO.mapRequired("fileoff", LoadCommand.fileoff);<br class="">
+ IO.mapRequired("filesize", LoadCommand.filesize);<br class="">
+ IO.mapRequired("maxprot", LoadCommand.maxprot);<br class="">
+ IO.mapRequired("initprot", LoadCommand.initprot);<br class="">
+ IO.mapRequired("nsects", LoadCommand.nsects);<br class="">
+ IO.mapRequired("flags", LoadCommand.flags);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::source_version_command>::mapping(<br class="">
+ IO &IO, MachO::source_version_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("version", LoadCommand.version);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::sub_client_command>::mapping(<br class="">
+ IO &IO, MachO::sub_client_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("client", LoadCommand.client);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::sub_framework_command>::mapping(<br class="">
+ IO &IO, MachO::sub_framework_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("umbrella", LoadCommand.umbrella);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::sub_library_command>::mapping(<br class="">
+ IO &IO, MachO::sub_library_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("sub_library", LoadCommand.sub_library);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::sub_umbrella_command>::mapping(<br class="">
+ IO &IO, MachO::sub_umbrella_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::symseg_command>::mapping(<br class="">
+ IO &IO, MachO::symseg_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("offset", LoadCommand.offset);<br class="">
+ IO.mapRequired("size", LoadCommand.size);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::symtab_command>::mapping(<br class="">
+ IO &IO, MachO::symtab_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("symoff", LoadCommand.symoff);<br class="">
+ IO.mapRequired("nsyms", LoadCommand.nsyms);<br class="">
+ IO.mapRequired("stroff", LoadCommand.stroff);<br class="">
+ IO.mapRequired("strsize", LoadCommand.strsize);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::thread_command>::mapping(<br class="">
+ IO &IO, MachO::thread_command &LoadCommand) {}<br class="">
+<br class="">
+void MappingTraits<MachO::twolevel_hints_command>::mapping(<br class="">
+ IO &IO, MachO::twolevel_hints_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("offset", LoadCommand.offset);<br class="">
+ IO.mapRequired("nhints", LoadCommand.nhints);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::uuid_command>::mapping(<br class="">
+ IO &IO, MachO::uuid_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("cmdsize", LoadCommand.cmdsize);<br class="">
+ IO.mapRequired("uuid", LoadCommand.uuid);<br class="">
+}<br class="">
+<br class="">
+void MappingTraits<MachO::version_min_command>::mapping(<br class="">
+ IO &IO, MachO::version_min_command &LoadCommand) {<br class="">
+<br class="">
+ IO.mapRequired("version", LoadCommand.version);<br class="">
+ IO.mapRequired("sdk", LoadCommand.sdk);<br class="">
}<br class="">
<br class="">
} // namespace llvm::yaml<br class="">
<br class="">
Modified: llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml (original)<br class="">
+++ llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml Tue May 17 14:44:06 2016<br class="">
@@ -13,69 +13,246 @@ FileHeader:<br class="">
LoadCommands:<br class="">
- cmd: LC_SEGMENT_64<br class="">
cmdsize: 72<br class="">
+ segname: __PAGEZERO<br class="">
+ vmaddr: 0<br class="">
+ vmsize: 4294967296<br class="">
+ fileoff: 0<br class="">
+ filesize: 0<br class="">
+ maxprot: 0<br class="">
+ initprot: 0<br class="">
+ nsects: 0<br class="">
+ flags: 0<br class="">
- cmd: LC_SEGMENT_64<br class="">
cmdsize: 552<br class="">
+ segname: __TEXT<br class="">
+ vmaddr: 4294967296<br class="">
+ vmsize: 8192<br class="">
+ fileoff: 0<br class="">
+ filesize: 8192<br class="">
+ maxprot: 7<br class="">
+ initprot: 5<br class="">
+ nsects: 6<br class="">
+ flags: 0<br class="">
- cmd: LC_SEGMENT_64<br class="">
cmdsize: 312<br class="">
+ segname: __DATA<br class="">
+ vmaddr: 4294975488<br class="">
+ vmsize: 4096<br class="">
+ fileoff: 8192<br class="">
+ filesize: 4096<br class="">
+ maxprot: 7<br class="">
+ initprot: 3<br class="">
+ nsects: 3<br class="">
+ flags: 0<br class="">
- cmd: LC_SEGMENT_64<br class="">
cmdsize: 72<br class="">
+ segname: __LINKEDIT<br class="">
+ vmaddr: 4294979584<br class="">
+ vmsize: 4096<br class="">
+ fileoff: 12288<br class="">
+ filesize: 2508<br class="">
+ maxprot: 7<br class="">
+ initprot: 1<br class="">
+ nsects: 0<br class="">
+ flags: 0<br class="">
- cmd: LC_DYLD_INFO_ONLY<br class="">
cmdsize: 48<br class="">
+ rebase_off: 12288<br class="">
+ rebase_size: 8<br class="">
+ bind_off: 96<br class="">
+ weak_bind_off: 0<br class="">
+ weak_bind_size: 0<br class="">
+ lazy_bind_off: 624<br class="">
+ export_off: 13016<br class="">
+ export_size: 48<br class="">
- cmd: LC_SYMTAB<br class="">
cmdsize: 24<br class="">
+ symoff: 13080<br class="">
+ nsyms: 30<br class="">
+ stroff: 13700<br class="">
+ strsize: 1096<br class="">
- cmd: LC_DYSYMTAB<br class="">
cmdsize: 80<br class="">
+ ilocalsym: 0<br class="">
+ nlocalsym: 9<br class="">
+ iextdefsym: 9<br class="">
+ nextdefsym: 2<br class="">
+ iundefsym: 11<br class="">
+ nundefsym: 19<br class="">
+ tocoff: 0<br class="">
+ ntoc: 0<br class="">
+ modtaboff: 0<br class="">
+ nmodtab: 0<br class="">
+ extrefsymoff: 0<br class="">
+ nextrefsyms: 0<br class="">
+ indirectsymoff: 13560<br class="">
+ nindirectsyms: 35<br class="">
+ extreloff: 0<br class="">
+ nextrel: 0<br class="">
+ locreloff: 0<br class="">
+ nlocrel: 0<br class="">
- cmd: LC_LOAD_DYLINKER<br class="">
cmdsize: 32<br class="">
+ name: 12<br class="">
- cmd: LC_UUID<br class="">
cmdsize: 24<br class="">
+ cmdsize: 24<br class="">
+ uuid: 461A1B28-822F-3F38-B670-645419E636F5<br class="">
- cmd: LC_VERSION_MIN_MACOSX<br class="">
cmdsize: 16<br class="">
+ version: 658176<br class="">
+ sdk: 658176<br class="">
- cmd: LC_SOURCE_VERSION<br class="">
cmdsize: 16<br class="">
+ version: 0<br class="">
- cmd: LC_MAIN<br class="">
cmdsize: 24<br class="">
+ entryoff: 4448<br class="">
+ stacksize: 0<br class="">
- cmd: LC_LOAD_DYLIB<br class="">
cmdsize: 48<br class="">
+ dylib:<br class="">
+ name: 24<br class="">
+ timestamp: 2<br class="">
+ current_version: 7864576<br class="">
+ compatibility_version: 65536<br class="">
- cmd: LC_LOAD_DYLIB<br class="">
cmdsize: 56<br class="">
+ dylib:<br class="">
+ name: 24<br class="">
+ timestamp: 2<br class="">
+ current_version: 80349697<br class="">
+ compatibility_version: 65536<br class="">
- cmd: LC_FUNCTION_STARTS<br class="">
cmdsize: 16<br class="">
+ dataoff: 13064<br class="">
+ datasize: 16<br class="">
- cmd: LC_DATA_IN_CODE<br class="">
cmdsize: 16<br class="">
+ dataoff: 13080<br class="">
+ datasize: 0<br class="">
...<br class="">
<br class="">
<br class="">
-# CHECK: LoadCommands:<br class="">
-# CHECK: - cmd: LC_SEGMENT_64<br class="">
-# CHECK: cmdsize: 72<br class="">
-# CHECK: - cmd: LC_SEGMENT_64<br class="">
-# CHECK: cmdsize: 552<br class="">
-# CHECK: - cmd: LC_SEGMENT_64<br class="">
-# CHECK: cmdsize: 312<br class="">
-# CHECK: - cmd: LC_SEGMENT_64<br class="">
-# CHECK: cmdsize: 72<br class="">
-# CHECK: - cmd: LC_DYLD_INFO_ONLY<br class="">
-# CHECK: cmdsize: 48<br class="">
-# CHECK: - cmd: LC_SYMTAB<br class="">
-# CHECK: cmdsize: 24<br class="">
-# CHECK: - cmd: LC_DYSYMTAB<br class="">
-# CHECK: cmdsize: 80<br class="">
-# CHECK: - cmd: LC_LOAD_DYLINKER<br class="">
-# CHECK: cmdsize: 32<br class="">
-# CHECK: - cmd: LC_UUID<br class="">
-# CHECK: cmdsize: 24<br class="">
-# CHECK: - cmd: LC_VERSION_MIN_MACOSX<br class="">
-# CHECK: cmdsize: 16<br class="">
-# CHECK: - cmd: LC_SOURCE_VERSION<br class="">
-# CHECK: cmdsize: 16<br class="">
-# CHECK: - cmd: LC_MAIN<br class="">
-# CHECK: cmdsize: 24<br class="">
-# CHECK: - cmd: LC_LOAD_DYLIB<br class="">
-# CHECK: cmdsize: 48<br class="">
-# CHECK: - cmd: LC_LOAD_DYLIB<br class="">
-# CHECK: cmdsize: 56<br class="">
-# CHECK: - cmd: LC_FUNCTION_STARTS<br class="">
-# CHECK: cmdsize: 16<br class="">
-# CHECK: - cmd: LC_DATA_IN_CODE<br class="">
-# CHECK: cmdsize: 16<br class="">
+<br class="">
+#CHECK: LoadCommands:<br class="">
+#CHECK: - cmd: LC_SEGMENT_64<br class="">
+#CHECK: cmdsize: 72<br class="">
+#CHECK: segname: __PAGEZERO<br class="">
+#CHECK: vmaddr: 0<br class="">
+#CHECK: vmsize: 4294967296<br class="">
+#CHECK: fileoff: 0<br class="">
+#CHECK: filesize: 0<br class="">
+#CHECK: maxprot: 0<br class="">
+#CHECK: initprot: 0<br class="">
+#CHECK: nsects: 0<br class="">
+#CHECK: flags: 0<br class="">
+#CHECK: - cmd: LC_SEGMENT_64<br class="">
+#CHECK: cmdsize: 552<br class="">
+#CHECK: segname: __TEXT<br class="">
+#CHECK: vmaddr: 4294967296<br class="">
+#CHECK: vmsize: 8192<br class="">
+#CHECK: fileoff: 0<br class="">
+#CHECK: filesize: 8192<br class="">
+#CHECK: maxprot: 7<br class="">
+#CHECK: initprot: 5<br class="">
+#CHECK: nsects: 6<br class="">
+#CHECK: flags: 0<br class="">
+#CHECK: - cmd: LC_SEGMENT_64<br class="">
+#CHECK: cmdsize: 312<br class="">
+#CHECK: segname: __DATA<br class="">
+#CHECK: vmaddr: 4294975488<br class="">
+#CHECK: vmsize: 4096<br class="">
+#CHECK: fileoff: 8192<br class="">
+#CHECK: filesize: 4096<br class="">
+#CHECK: maxprot: 7<br class="">
+#CHECK: initprot: 3<br class="">
+#CHECK: nsects: 3<br class="">
+#CHECK: flags: 0<br class="">
+#CHECK: - cmd: LC_SEGMENT_64<br class="">
+#CHECK: cmdsize: 72<br class="">
+#CHECK: segname: __LINKEDIT<br class="">
+#CHECK: vmaddr: 4294979584<br class="">
+#CHECK: vmsize: 4096<br class="">
+#CHECK: fileoff: 12288<br class="">
+#CHECK: filesize: 2508<br class="">
+#CHECK: maxprot: 7<br class="">
+#CHECK: initprot: 1<br class="">
+#CHECK: nsects: 0<br class="">
+#CHECK: flags: 0<br class="">
+#CHECK: - cmd: LC_DYLD_INFO_ONLY<br class="">
+#CHECK: cmdsize: 48<br class="">
+#CHECK: rebase_off: 12288<br class="">
+#CHECK: rebase_size: 8<br class="">
+#CHECK: bind_off: 96<br class="">
+#CHECK: weak_bind_off: 0<br class="">
+#CHECK: weak_bind_size: 0<br class="">
+#CHECK: lazy_bind_off: 624<br class="">
+#CHECK: export_off: 13016<br class="">
+#CHECK: export_size: 48<br class="">
+#CHECK: - cmd: LC_SYMTAB<br class="">
+#CHECK: cmdsize: 24<br class="">
+#CHECK: symoff: 13080<br class="">
+#CHECK: nsyms: 30<br class="">
+#CHECK: stroff: 13700<br class="">
+#CHECK: strsize: 1096<br class="">
+#CHECK: - cmd: LC_DYSYMTAB<br class="">
+#CHECK: cmdsize: 80<br class="">
+#CHECK: ilocalsym: 0<br class="">
+#CHECK: nlocalsym: 9<br class="">
+#CHECK: iextdefsym: 9<br class="">
+#CHECK: nextdefsym: 2<br class="">
+#CHECK: iundefsym: 11<br class="">
+#CHECK: nundefsym: 19<br class="">
+#CHECK: tocoff: 0<br class="">
+#CHECK: ntoc: 0<br class="">
+#CHECK: modtaboff: 0<br class="">
+#CHECK: nmodtab: 0<br class="">
+#CHECK: extrefsymoff: 0<br class="">
+#CHECK: nextrefsyms: 0<br class="">
+#CHECK: indirectsymoff: 13560<br class="">
+#CHECK: nindirectsyms: 35<br class="">
+#CHECK: extreloff: 0<br class="">
+#CHECK: nextrel: 0<br class="">
+#CHECK: locreloff: 0<br class="">
+#CHECK: nlocrel: 0<br class="">
+#CHECK: - cmd: LC_LOAD_DYLINKER<br class="">
+#CHECK: cmdsize: 32<br class="">
+#CHECK: name: 12<br class="">
+#CHECK: - cmd: LC_UUID<br class="">
+#CHECK: cmdsize: 24<br class="">
+#CHECK: cmdsize: 24<br class="">
+#CHECK: uuid: 461A1B28-822F-3F38-B670-645419E636F5<br class="">
+#CHECK: - cmd: LC_VERSION_MIN_MACOSX<br class="">
+#CHECK: cmdsize: 16<br class="">
+#CHECK: version: 658176<br class="">
+#CHECK: sdk: 658176<br class="">
+#CHECK: - cmd: LC_SOURCE_VERSION<br class="">
+#CHECK: cmdsize: 16<br class="">
+#CHECK: version: 0<br class="">
+#CHECK: - cmd: LC_MAIN<br class="">
+#CHECK: cmdsize: 24<br class="">
+#CHECK: entryoff: 4448<br class="">
+#CHECK: stacksize: 0<br class="">
+#CHECK: - cmd: LC_LOAD_DYLIB<br class="">
+#CHECK: cmdsize: 48<br class="">
+#CHECK: dylib:<br class="">
+#CHECK: name: 24<br class="">
+#CHECK: timestamp: 2<br class="">
+#CHECK: current_version: 7864576<br class="">
+#CHECK: compatibility_version: 65536<br class="">
+#CHECK: - cmd: LC_LOAD_DYLIB<br class="">
+#CHECK: cmdsize: 56<br class="">
+#CHECK: dylib:<br class="">
+#CHECK: name: 24<br class="">
+#CHECK: timestamp: 2<br class="">
+#CHECK: current_version: 80349697<br class="">
+#CHECK: compatibility_version: 65536<br class="">
+#CHECK: - cmd: LC_FUNCTION_STARTS<br class="">
+#CHECK: cmdsize: 16<br class="">
+#CHECK: dataoff: 13064<br class="">
+#CHECK: datasize: 16<br class="">
+#CHECK: - cmd: LC_DATA_IN_CODE<br class="">
+#CHECK: cmdsize: 16<br class="">
+#CHECK: dataoff: 13080<br class="">
+#CHECK: datasize: 0<br class="">
<br class="">
Modified: llvm/trunk/tools/obj2yaml/macho2yaml.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/macho2yaml.cpp?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/macho2yaml.cpp?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/tools/obj2yaml/macho2yaml.cpp (original)<br class="">
+++ llvm/trunk/tools/obj2yaml/macho2yaml.cpp Tue May 17 14:44:06 2016<br class="">
@@ -9,9 +9,9 @@<br class="">
<br class="">
#include "Error.h"<br class="">
#include "obj2yaml.h"<br class="">
-#include "llvm/Support/ErrorHandling.h"<br class="">
#include "llvm/Object/MachOUniversal.h"<br class="">
#include "llvm/ObjectYAML/MachOYAML.h"<br class="">
+#include "llvm/Support/ErrorHandling.h"<br class="">
<br class="">
using namespace llvm;<br class="">
<br class="">
@@ -24,6 +24,14 @@ public:<br class="">
Expected<std::unique_ptr<MachOYAML::Object>> dump();<br class="">
};<br class="">
<br class="">
+#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \<br class="">
+ case MachO::LCName: \<br class="">
+ memcpy((void *) & (LC.Data.LCStruct##_data), LoadCmd.Ptr, \<br class="">
+ sizeof(MachO::LCStruct)); \<br class="">
+ if (Obj.isLittleEndian() != sys::IsLittleEndianHost) \<br class="">
+ MachO::swapStruct(LC.Data.LCStruct##_data); \<br class="">
+ break;<br class="">
+<br class="">
Expected<std::unique_ptr<MachOYAML::Object>> MachODumper::dump() {<br class="">
auto Y = make_unique<MachOYAML::Object>();<br class="">
Y->Header.magic = Obj.getHeader().magic;<br class="">
@@ -35,10 +43,17 @@ Expected<std::unique_ptr<MachOYAML::Obje<br class="">
Y->Header.flags = Obj.getHeader().flags;<br class="">
Y->Header.reserved = 0;<br class="">
<br class="">
- for (auto load_command : Obj.load_commands()) {<br class="">
- auto LC = make_unique<MachOYAML::LoadCommand>();<br class="">
- LC->cmd = static_cast<MachO::LoadCommandType>(load_command.C.cmd);<br class="">
- LC->cmdsize = load_command.C.cmdsize;<br class="">
+ for (auto LoadCmd : Obj.load_commands()) {<br class="">
+ MachOYAML::LoadCommand LC;<br class="">
+ switch (LoadCmd.C.cmd) {<br class="">
+ default:<br class="">
+ memcpy((void *)&(LC.Data.load_command_data), LoadCmd.Ptr,<br class="">
+ sizeof(MachO::load_command));<br class="">
+ if (Obj.isLittleEndian() != sys::IsLittleEndianHost)<br class="">
+ MachO::swapStruct(LC.Data.load_command_data);<br class="">
+ break;<br class="">
+#include "llvm/Support/MachO.def"<br class="">
+ }<br class="">
Y->LoadCommands.push_back(std::move(LC));<br class="">
}<br class="">
<br class="">
<br class="">
Modified: llvm/trunk/tools/yaml2obj/yaml2macho.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2macho.cpp?rev=269808&r1=269807&r2=269808&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2macho.cpp?rev=269808&r1=269807&r2=269808&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/tools/yaml2obj/yaml2macho.cpp (original)<br class="">
+++ llvm/trunk/tools/yaml2obj/yaml2macho.cpp Tue May 17 14:44:06 2016<br class="">
@@ -79,17 +79,32 @@ Error MachOWriter::writeHeader(raw_ostre<br class="">
<br class="">
Error MachOWriter::writeLoadCommands(raw_ostream &OS) {<br class="">
for (auto &LC : Obj.LoadCommands) {<br class="">
- MachO::load_command LCTemp;<br class="">
- LCTemp.cmd = LC->cmd;<br class="">
- LCTemp.cmdsize = LC->cmdsize;<br class="">
- OS.write(reinterpret_cast<const char *>(&LCTemp),<br class="">
- sizeof(MachO::load_command));<br class="">
- auto remaining_size = LC->cmdsize - sizeof(MachO::load_command);<br class="">
- if (remaining_size > 0) {<br class="">
+ size_t BytesWritten = 0;<br class="">
+#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \<br class="">
+ case MachO::LCName: \<br class="">
+ OS.write(reinterpret_cast<const char *>(&(LC.Data.LCStruct##_data)), \<br class="">
+ sizeof(MachO::LCStruct)); \<br class="">
+ BytesWritten = sizeof(MachO::LCStruct); \<br class="">
+ break;<br class="">
+<br class="">
+ switch (LC.Data.load_command_data.cmd) {<br class="">
+ default:<br class="">
+ OS.write(reinterpret_cast<const char *>(&(LC.Data.load_command_data)),<br class="">
+ sizeof(MachO::load_command));<br class="">
+ BytesWritten = sizeof(MachO::load_command);<br class="">
+ break;<br class="">
+#include "llvm/Support/MachO.def"<br class="">
+ }<br class="">
+<br class="">
+ auto BytesRemaining =<br class="">
+ LC.Data.load_command_data.cmdsize - BytesWritten;<br class="">
+ if (BytesRemaining > 0) {<br class="">
// TODO: Replace all this once the load command data is present in yaml.<br class="">
- std::vector<char> fill_data;<br class="">
- fill_data.insert(fill_data.begin(), remaining_size, 0);<br class="">
- OS.write(fill_data.data(), remaining_size);<br class="">
+ // For now I fill with 0xDEADBEEF because it is easy to spot on a hex<br class="">
+ // viewer.<br class="">
+ std::vector<uint32_t> FillData;<br class="">
+ FillData.insert(FillData.begin(), BytesRemaining / 4 + 1, 0xDEADBEEFu);<br class="">
+ OS.write(reinterpret_cast<char *>(FillData.data()), BytesRemaining);<br class="">
}<br class="">
}<br class="">
return Error::success();<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>