I just did a quick test using te.c:
int main( int argc, const char* argv[] ) { return 0; }
Running arm-linux-androideabi-gcc -o conftest -static -FPIE -pie te.c does not cause errors. However file -k conftest prints
conftest: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped
readelf -l conftest outputs File type Elf - DYN (shared object file) Entry point 0x500 There are 7 program headers starting at offset 52
Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x00000034 0x00000034 0x000e0 0x000e0 R 0x4 INTERP 0x000114 0x00000114 0x00000114 0x00013 0x00013 R 0x1 [Requesting program interpreter: /system/bin/linker] ...
The presence of PHDR and INTERP headers indicates that -pie silently overrides -static in the hand compiler. Why I do not know this, but I would consider it a mistake that does not give a warning when -static and -pie are used together. Instead of programmers like you, the false impression is that these two options can be used together on the hand.
Just to clarify the only behavioral difference here is that x86 compiler errors when viewed as -static and -pie, while the arm version silently ignores -static if --pie. If only one is specified, the behavior is the same for both compilers.
wheredidthatnamecomefrom Feb 01 '15 at 3:55 2015-02-01 03:55
source share