Is PIE (Position-independent executable) for main executables supported in Android 4.0 (ICS)?
<p>To examine PIE for main executables in Android 4.0 (ICS), I tested some sample programs in Galaxy Nexus. Results are shown below:</p>

<pre><code>    "-fPIE" "-pie"   TYPE        address
--------------------------------------------
(a)    -       -    ET_EXE     0x00008000
(b)    x       -    ET_EXE     0x00008000
(c)    -       x    ET_DYN   program crashed
(d)    x       x    ET_DYN   program crashed
</code></pre>

<p>notes: use Android NDK r7 for android-14</p>

<p>The results says that (a) and (b) without "-pie" is not randomized, (c) and (d) with "-pie" crash. So, I cannot enable ASLR for main executables. Crash logs are shown below:</p>

<pre><code>pid: 5306, tid: 5306  &gt;&gt;&gt; ./memdump &lt;&lt;&lt;
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000a020
 r0 70000001  r1 b00094fc  r2 00000000  r3 0000a020
 r4 b000a078  r5 ffffffff  r6 0000a020  r7 be933b98
 r8 b0009910  r9 00000000  10 00000000  fp b0006d3b
 ip 0000200f  sp be933b58  lr 00001f50  pc b00041c0  cpsr 00000030
 d0  0000000000000000  d1  0000000000000000
 d2  0000000000000000  d3  0000000000000000
 d4  0000000000000000  d5  0000000000000000
 d6  0000000000000000  d7  0000000000000000
 d8  0000000000000000  d9  0000000000000000
 d10 0000000000000000  d11 0000000000000000
 d12 0000000000000000  d13 0000000000000000
 d14 0000000000000000  d15 0000000000000000
 d16 0000000000000000  d17 0000000000000000
 d18 0000000000000000  d19 0000000000000000
d20 0000000000000000  d21 0000000000000000
d22 0000000000000000  d23 0000000000000000
d24 0000000000000000  d25 0000000000000000
d26 0000000000000000  d27 0000000000000000
d28 0000000000000000  d29 0000000000000000
d30 0000000000000000  d31 0000000000000000
scr 00000000

        #00  pc b00041c0  /system/bin/linker
        #01  lr 00001f50  &lt;unknown&gt;

code around pc:
b00041a0 6858e00a 208cf8d4 f8c41885 e00350d8 
b00041b0 0895685a 50dcf8c4 e0013308 44794924 
b00041c0 2d00681d af49f47f 30acf8d4 f8d4b113 
b00041d0 b96110b0 7174f240 9100481e 44784a1e 
b00041e0 491f4b1e 447b447a 68094479 f8d4e7b1 

code around lr:
00001f30 ffffffff ffffffff ffffffff ffffffff 
00001f40 ffffffff ffffffff ffffffff ffffffff 
00001f50 ffffffff ffffffff ffffffff ffffffff 
00001f60 ffffffff ffffffff ffffffff ffffffff 
00001f70 ffffffff ffffffff ffffffff ffffffff 

stack:
   be933b18  00000000  
   be933b1c  00000000  
   be933b20  00000000  
   be933b24  00000000  
   be933b28  00000000  
   be933b2c  00000000  
   be933b30  00000000  
   be933b34  00000000  
   be933b38  00000000  
   be933b3c  00000000  
   be933b40  00000000  
   be933b44  00000000  
   be933b48  00000000  
   be933b4c  00000000  
   be933b50  df0027ad  
   be933b54  00000000  
#00 be933b58  00000000  
    be933b5c  00000000  
    be933b60  b000a078  
    be933b64  b000a078  
    be933b68  be933cf1  
    be933b6c  00000118  
    be933b70  b000a078  
    be933b74  b000a078  
    be933b78  b00094f0  
    be933b7c  00000002  
    be933b80  be933b98  
    be933b84  b0009910  
    be933b88  00000000  
    be933b8c  00000000  
    be933b90  b0006d3b  /system/bin/linker
    be933b94  b00047ed  /system/bin/linker
    be933b98  00000000  
    be933b9c  00000000  
</code></pre>

<p>Is not PIE for main executables supported in Android 4.0?</p>
