问题描述
要检查PIE中的Android 4.0(ICS)主可执行文件,我测试了Galaxy Nexus的范例程序。结果如下所示:
To examine PIE for main executables in Android 4.0 (ICS), I tested some sample programs in Galaxy Nexus. Results are shown below:
"-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
注:采用Android NDK R7为Android-14
notes: use Android NDK r7 for android-14
结果表示,(a)和(b)在没有-pie不是随机的,(c)和(d)与-pie崩溃。所以,我不能启用ASLR主可执行文件。崩溃日志如下:
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:
pid: 5306, tid: 5306 >>> ./memdump <<<
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 <unknown>
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
是不是馅饼在Android 4.0的支持主要的可执行文件?
Is not PIE for main executables supported in Android 4.0?
推荐答案
我想通了这个问题。 Android不支持PIE主可执行文件。该错误是由于Android的连接器(/bionic/linker/linker.cpp - link_image())。它总是加载在可执行的ELF程序到指定为标题的虚拟地址字段中的固定地址是动态的头,无论是二进制类型(ET_EXE或ET_DYN)的。在上面的例子中指定的地址是0x0000a020,所以SEGV_MAPERR被发生在地址。此外,Android的链接器假定二进制文件的实际类型ET_EXEregardress。这是一个耻辱: - &LT ;.谢谢你。
I have figured out the problem. Android does not support PIE for main executables. The error was due to the Android's linker (/bionic/linker/linker.cpp - link_image()). It always loads a DYNAMIC header in an executable ELF binary to a fixed address specified as the header's virtual address field, regardless of the binary TYPE (ET_EXE or ET_DYN). In the above example the specified address was 0x0000a020, so SEGV_MAPERR was occurred at the address. Moreover, the Android's linker assumes that the binary is "ET_EXE" regardress of its actual TYPE. It's a shame :-<. Thanks.
这篇关于是PIE(位置无关的可执行文件)的主要可执行文件中的Android 4.0(ICS)的支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!