[PATCH] [lld] [MachO] Begin to flesh out normalizedToAtoms

Nick Kledzik kledzik at apple.com
Thu Jan 2 17:07:02 PST 2014


On Jan 2, 2014, at 4:41 PM, Joey Gouly <joey.gouly at gmail.com> wrote:\
> 
> 
> ================
> Comment at: lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp:282
> @@ -280,1 +281,3 @@
> +        io, sect.content);
> +    io.mapOptional("content",         content->normalizedContent);
>     io.mapOptional("relocations",     sect.relocations);
> ----------------
> kledzik at apple.com wrote:
>> I think you can just cast the address of sect.content to be of type ContentBytes and it should all just work with no need for NormalizedContent.
> mapOptional wants a reference to the content, so I cant use the address of content, and as far as I can tell, I can't change the type of a reference.
> 
> Unless I'm mistaken, I can't do this without copying.

This works for me:

Index: lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
===================================================================
--- lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp	(revision 198349)
+++ lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp	(working copy)
@@ -276,7 +276,8 @@
     io.mapOptional("attributes",      sect.attributes);
     io.mapOptional("alignment",       sect.alignment, 0U);
     io.mapRequired("address",         sect.address);
-    io.mapOptional("content",         sect.content);
+    ContentBytes &cont = *reinterpret_cast<ContentBytes*>(&sect.content);
+    io.mapOptional("content",         cont);
     io.mapOptional("relocations",     sect.relocations);
     io.mapOptional("indirect-syms",   sect.indirectSymbols);
   }







More information about the llvm-commits mailing list