<p dir="ltr">Strange, Gmail displayed only the first part of the patch.</p>
<p dir="ltr">Please don't use macho dump on new tests, readobj is far more readable. </p>
<p dir="ltr">Please explicitly test what happens when there is a directive in the assembly. Also test with a ios, osx and bare metal mach-o triples.</p>
<p dir="ltr">Cheers, Rafael </p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jul 23, 2015, at 7:29 PM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>> wrote:</div><br><div><p dir="ltr">Testcase? </p></div></blockquote>There is a test case in the patch itself (test/MC/MachO/darwin-version-min-load-command.s). And it is my intention to give every object file a VERSION_MIN load command. It is desired/required (depending on how strong you wish) to have this load command on darwin so the linker can prevent or warn you when linking in object files that are not compatible (for example, linking object built for 10.10 when you want to be 10.5 compatible or linking iPhone simulator objects into OS X binary).</div><div><br></div><div>Thanks</div><div><br></div><div>Steven<br><blockquote type="cite"><div><p dir="ltr">In particular, is it the intention that an assembly file with no directives will get this load command?</p>
<div class="gmail_quote">On Jul 23, 2015 9:51 PM, "Steven Wu" <<a href="mailto:stevenwu@apple.com" target="_blank">stevenwu@apple.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jim<br>
<br>
Here is a patch that forces all the MachO objects on Darwin to have version_min load command. When MCObjectStreamer is created, it will inferred the default version_min from target triple. When there is a version_min directive in the assembly input, it will overwrite the default. By doing so, it will not affect the assembly source that already have version_min directive, but force a version_min load command on the others.<br>
<br>
The only relevant part of the change is following and the rest is just updating the test for correct load command number and offset in the file:<br>
<br>
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp<br>
index 53cd131..116ef09 100644<br>
--- a/lib/MC/MCMachOStreamer.cpp<br>
+++ b/lib/MC/MCMachOStreamer.cpp<br>
@@ -493,6 +493,16 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,<br>
                                       bool LabelSections) {<br>
   MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE,<br>
                                            DWARFMustBeAtTheEnd, LabelSections);<br>
+  const Triple &TT = Context.getObjectFileInfo()->getTargetTriple();<br>
+  if (TT.isOSDarwin()) {<br>
+    unsigned Major, Minor, Update;<br>
+    TT.getOSVersion(Major, Minor, Update);<br>
+    // If there is a version specified, Major will be non-zero.<br>
+    if (Major)<br>
+      S->EmitVersionMin((TT.isMacOSX() ?<br>
+                        MCVM_OSXVersionMin : MCVM_IOSVersionMin),<br>
+                        Major, Minor, Update);<br>
+  }<br>
   if (RelaxAll)<br>
     S->getAssembler().setRelaxAll(true);<br>
   return S;<br>
<br>
Thanks<br>
<br>
Steven<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div>
</div></blockquote></div><br></div></div>