2

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?

jww
  • 97,681
  • 90
  • 411
  • 885
vishalm
  • 477
  • 5
  • 12
  • Use recursive grep to figure out where this is/was used and defined. Did you move object files between versions rather than moving cleaned source? Are you using non-public internal functionality in your code? – Chris Stratton Apr 10 '14 at 03:12
  • I moved just the source... googling around, looks like FORTIFY_CHECK is causing printf to call this – vishalm Apr 10 '14 at 03:39
  • Figured out a solution: compiling the project by disabling FORTIFY_SOURCE fixes the problem – vishalm Apr 10 '14 at 03:59

2 Answers2

2

Fixed the issue by building the project with FORTIFY_SOURCE flag disabled

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

vishalm
  • 477
  • 5
  • 12
0

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.

jww
  • 97,681
  • 90
  • 411
  • 885