I'm recompiling some executable for Android 5.0 as it requires executables to be PIE
. I was able to recompile it for ARM
with just adding some arguments while configuring (with standalone toolchain):
export CFLAGS="-I/softdev/arm-libs/include -fPIE"
export CPPLAGS="$CPPFLAGS -fPIE"
export CXXLAGS="$CXXFLAGS -fPIE"
export LDFLAGS="-L/softdev/arm-libs/lib -static -fPIE -pie"
No error for ARM:
configure:3406: arm-linux-androideabi-gcc -o conftest -I/softdev/arm-libs/include -fPIE -L/softdev/arm-libs/lib -static -fPIE -pie conftest.c >&5
configure:3410: $? = 0
But i was unable to do the same for x86
as i'm getting error:
export CFLAGS="-I/softdev/x86-libs/include -fPIE"
export CPPLAGS="$CPPFLAGS -fPIE"
export CXXLAGS="$CXXFLAGS -fPIE"
export LDFLAGS="-L/softdev/x86-libs/lib -static -fPIE -pie"
error:
configure:3336: i686-linux-android-gcc -I/softdev/x86-libs/include -fPIE -L/softdev/x86-libs/lib -static -fPIE -pie conftest.c >&5
/softdev/x86-toolchain-gcc4.8/bin/../lib/gcc/i686-linux-android/4.8/../../../../i686-linux-android/bin/ld: fatal error: -pie and -static are incompatible
collect2: error: ld returned 1 exit status
configure:3340: $? = 1
I need executables to be linked statically. What's wrong and how can i fix it?
PS. Also tried using x86 standalone toolchain from android ndk r9d and r10c:
./make-standalone-toolchain.sh --toolchain=x86-4.8 --arch=x86 --install-dir=/softdev/x86-toolchain-gcc4.8-r9d --ndk-dir=/softdev/android-ndk-r9d/ --system=darwin-x86_64
-static
option). – Antechoirfile -k
to check the binary type, andreadelf -l
to check INTERP section of ELF (if you have one, it is not the real static binary), andldd
to check linked libraries. I think your arm binary may be not real static binary. – Antechoir-static
sometime generates dynamic ELF. Usefile -k
andreadelf -l
(with|grep -A 2 INTERP
) to check this; update the post with their output. – Antechoir