title: How to disable address randomization (ASLR) from an ELF file?
body: <p><strong>Solved:</strong>
  The solution was calling personality(0x40000). See details below in the comments.</p>
  
  <p>Where does the ASLR flag resides within an ELF file? I need to disable ASLR for a specific library (.so).
  I've tried using objdump but I couldn't find out how to do so.</p>
  
  <p>I can't use /proc because it doesn't appear to work on my Android 4.4.4,
  so I'm trying to modify the binary.</p>
  
  <p><strong>Edit:</strong>
  I've compiled the following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void* getEIP()
  {
      return __builtin_return_address(0) - 0x5;
  }
  
  int main(int argc, char** argv)
  {
      printf("EIP located at: %p\n", getEIP());
      return 0;
  }
  </code></pre>
  
  <p>without ASLR (PIE):</p>
  
  <pre><code>arm-linux-androideabi-gcc.exe code.c -o noPIE --sysroot=%NDK%\platforms\android-3\arch-arm
  </code></pre>
  
  <p>with ASLR (PIE):</p>
  
  <pre><code>arm-linux-androideabi-gcc.exe -fPIE -pie code.c -o withPIE --sysroot=%NDK%\platforms\android-3\arch-arm
  </code></pre>
  
  <p>The noPIE binary indeed isn't being randomized, even though:</p>
  
  <pre><code># cat /proc/sys/kernel/randomize_va_space
  2
  </code></pre>