title: How to disable address space randomization for a binary on Linux?
body: <p>I'm working on a runtime system for parallel programs that can take advantage of a common address space layout across multiple processes, potentially spread over several (thousand) nodes. Many times, software built for this environment is run on Linux systems that have address space randomization enabled by default, and users may not want or be able to disable it system-wide (via <code>sysctl -w kernel.randomize_va_space=0</code> and the like). This imposes some limitations on the parallel programs, and can hurt performance. Thus, we want to figure out how to disable it for the binaries that we build. Security is not an issue, as this software is always running in controlled environments.</p>
  
  <p>I've found references to various flags and variables, like <code>ET_EXEC</code>, <code>EF_AS_NO_RANDOM</code> (apparently never merged?) and <code>PF_RANDOMIZE</code>, but I can't find any document that describes what I can do to set these flags. An ideal answer would tell me what compiler/assembler/linker flag will disable randomization for the resulting binary, and what versions of the tool-chain/kernel this works on. Next best would be a tool that does the same after a binary is built.</p>
  
  <p>Since I'm sure someone will suggest it, I'm already aware that we can make this change at runtime with <code>setarch -R</code>, but it's preferable to record this in the executable.</p>
  
  <p>It looks like <code>paxctl -rx</code> ought to do the trick, but it doesn't seem to apply to the current method used in kernels that don't include the PaX patches.</p>