<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>   Options when creating a main executable</div><div>     -pie        This makes a special kind of main executable that is position</div><div>                 independent (PIE).  On Mac OS X 10.5 and later, the OS the OS</div><div>                 will load a PIE at a random address each time it is executed.</div><div>                 You cannot create a PIE from .o files compiled with -mdy-</div><div>                 namic-no-pic.  That means the codegen is less optimal, but</div><div>                 the address randomization adds some security. When targeting</div><div>                 Mac OS X 10.7 or later PIE is the default for main executa-</div><div>                 bles.</div><div><br></div><div>     -no_pie     Do not make a position independent executable (PIE).  This is</div><div>                 the default, when targeting 10.6 and earlier.</div><div><br></div><div><div>On Dec 9, 2011, at 11:02 AM, Kostya Serebryany wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">+llvmdev<div><br></div><div>Question to MacOS gurus: is there a way to disable ASLR (address space layout randomization) on Darwin at link time </div><div>instead of doing setenv("DYLD_NO_PIE", "1", 1); and reexec? </div>
<div><br></div><div>Thanks, </div><div><br></div><div>--kcc <br><br><div class="gmail_quote">On Fri, Dec 9, 2011 at 4:28 AM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com">glider@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">The attached patch introduces the disable_aslr option (off by default)<br>
and the corresponding AsanDisableAslr function that should disable the<br>
address space randomization.<br>
This is now implemented for Mac OS 10.6 only.<br>
In order to do this we add DYLD_NO_PIE=1 to the env and restart the program.<br>
<br>
Next steps to be done are:<br>
 -- check for MH_PIE bit -- if it is 0, we don't need to disable anything;<br>
 -- use posix_spawnattr_setflags() to set the _POSIX_SPAWN_DISABLE_ASLR on 10.7<br>
 -- disable ASLR on Linux, if needed.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alexander Potapenko<br>
Software Engineer<br>
Google Moscow<br>
</font></span></blockquote></div><br></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>