Question

I am moving some libraries from Android 4.3 to Android 4.4

The projects that used to compile in Android 4.3 now gives below error when compiled using Android 4.4 sources

/home/vishallocal/TI/android/kitkat/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/bits/stdio2.h:105: error: undefined reference to '__printf_chk' /home/vishallocal/TI/android/kitkat/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/bits/stdio2.h:105: error: undefined reference to '__printf_chk' /home/vishallocal/TI/android/kitkat/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/bits/stdio2.h:105: error: undefined reference to '__printf_chk' /home/vishallocal/TI/android/kitkat/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/sysroot/usr/include/bits/stdio2.h:105: error: undefined reference to '__printf_chk' collect2: error: ld returned 1 exit status

Any pointers on resolving this?

Was it helpful?

Solution

Fixed the issue by building the project with FORTIFY_SOURCE flag disabled

Added following lines to Android.mk LOCAL_CFLAGS += -U_FORTIFY_SOURCE

OTHER TIPS

I think your answer can be improved:

Fixed the issue by building the project with FORTIFY_SOURCE flag disabled

Added following lines to Android.mk LOCAL_CFLAGS += -U_FORTIFY_SOURCE

You probably want something like:

ifeq ($(APP_OPTIM),debug)
  LOCAL_CFLAGS += -U_FORTIFY_SOURCE
endif

Also, you might get a warning if using FORTIFY_SOURCE and -O0. Its safe to ignore the warning. You can dispatch the waring with -O1 or similar.

FORTIFY_SOURCE is available to applications in NDK R10 and above. Prior to that, FORTIFY_SOURCE was only used with system libraries. I'm not sure how to guard on "NDK R10" and above. See Fortify Sources and Stack Protectors (was: Is Fortify Source working with NDK) on the Android Security Discussions mailing list.

Also, if you disable FORTIFY_SOURCE in release builds, then it should trigger a security defect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top