PIE is a useful security feature, which randomize the address space hence it significantly more difficult for an attacker to exploit bugs in a program.Android 5.0 now requires all dynamically linked executable to support PIE (position-independent executable). This enhances Android’s address space layout randomization (ASLR) implementation. So if command line application complied with out PIE support will through the following error when we try to run them.

Error: only position independent executables (PIE) are supported.

To solve this error, we need to include, LDFLAGS= -fPIE -pie in the Makefile and pass this flag as argument while compiling. See below for example.

LDFLAGS= -fPIE -pie 
$(CROSS_COMPILE)$(GCC) $(CFLAGS) $(LDFLAGS) -o example example.c $(INCLUDE)

In case of android.mk file, add the to the below line in Android.mk file.

LOCAL_CFLAGS += -fPIE -pie
LOCAL_LDFLAG  += -fPIE -pie