Preparing your app for Android L ?

While using native executables in our existing Android apps we observed that those executables were no more working with Android L. We came to know that Android has introduced one more security feature starting from Android L i.e

Executable must be PIE (Position independent executable).



To compile a library adhering to above security feature you just need to follow these steps:

Set following LDFLAGS or linker flags : -pie -fPIE Add --with-pic option while configuring the library.

Some libraries might use different configure options to compile the codeÂ with PIC (Position Independent Code) so to check all available configure options for PICÂ you can use this command:

./configure -h | grep -i pic

If there is no PIC option in configure script then you can try passing -fPIC option with your CFLAGS.

Now, compile the project (make, make install) and it should generate PIE.

To check if you’ve successfully generated a Position Independent Executable (PIE)

You can use “hardening-includes” package on Ubuntu or Debian.

Install “hardening-includes”: apt-get install hardening-includes Usage: hardening-check [path-to-executable] which will results in an output similar to this: Position Independent Executable: yes Stack protected: yes Fortify Source functions: no, only unprotected functions found! Read-only relocations: yes Immediate binding: yes

“Position Independent Executable” must be yes for Android L compatible executables.

I’ve compiled couple of projects which are Android L compatible, follow the steps in README to compile them yourself.

curl – Android L compatible

FFmpeg – Android L compatible

For more information about various compilation options read my other post Cross Compiling FFmpeg with x264 for Android