NDK r8c's 4.6 ld fails on Snow Leopard with missing memmem symbol error

Showing 1-2 of 2 messages
NDK r8c's 4.6 ld fails on Snow Leopard with missing memmem symbol error Jevin 12/4/12 10:18 AM
memmem is not supported below 10.7.[0] The NDK is advertised as supporting OS X all the way down to 10.4.8. Can the NDK team comment on what the minimum supported OS X is? It looks like binutils expects that some systems don't have memmem. They provide their own in libiberty/memmem.c. I suspect that the NDK team could either build the NDK on an old Snow Leopard host without memmem and binutils will use the libiberty implementation. Alternatively, it may be possible to massage the binutils build system to always use the libiberty memmem.

Failure without workaround:
build@magnolia:/opt/android-ndk/samples/hello-neon $ /opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libhelloneon.so -shared --sysroot=/opt/android-ndk/platforms/android-4/arch-arm ./obj/local/armeabi/objs/helloneon/helloneon.o ./obj/local/armeabi/libcpufeatures.a   -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -L/opt/android-ndk/platforms/android-4/arch-arm/usr/lib -llog -lc -lm -o ./obj/local/armeabi/libhelloneon.so
collect2: ld terminated with signal 5 [Trace/BPT trap]
dyld: lazy symbol binding failed: Symbol not found: _memmem
  Referenced from: /opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _memmem
  Referenced from: /opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld
  Expected in: /usr/lib/libSystem.B.dylib
build@magnolia:/opt/android-ndk/samples/hello-neon $


I was able to come up with a possible workaround for this particular problem. I made a new shared library that implements memmem(). I use DYLD_INSERT_LIBRARIES to get the memmem.dylib to load into the process and DYLD_FORCE_FLAT_NAMESPACE=1 to let ld find _memmem inside memmem.dylib instead of libSystem.B.dylib where it wants to look for it. I'm not sure if any other symbols need the same treatment.

No failure with workaround:
build@magnolia:/opt/android-ndk/samples/hello-neon $ DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=$HOME/memmem/memmem.dylib /opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld --sysroot=/opt/android-ndk/platforms/android-4/arch-arm --eh-frame-hdr -shared -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi -Bsymbolic -z noexecstack -z relro -z now -o ./obj/local/armeabi/libhelloneon.so /opt/android-ndk/platforms/android-4/arch-arm/usr/lib/crtbegin_so.o -L/opt/android-ndk/platforms/android-4/arch-arm/usr/lib -L/opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6 -L/opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc -L/opt/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/lib -L/opt/android-ndk/platforms/android-4/arch-arm/usr/lib -soname libhelloneon.so ./obj/local/armeabi/objs/helloneon/helloneon.o ./obj/local/armeabi/libcpufeatures.a --no-undefined -z noexecstack -z relro -z now -llog -v -lstdc++ -lm -lc -lgcc -lc -ldl -lgcc /opt/android-ndk/platforms/android-4/arch-arm/usr/lib/crtend_so.o
GNU gold (GNU Binutils 2.21) 1.10
build@magnolia:/opt/android-ndk/samples/hello-neon $

Re: NDK r8c's 4.6 ld fails on Snow Leopard with missing memmem symbol error Alba G. Corral 12/18/12 1:35 PM
Hi Kevin, i Have problems with this issue, where can i Find your new shared library to use in my Leopard OS?
I don't understand well your fix
Thanks!

El martes, 4 de diciembre de 2012 19:18:05 UTC+1, Jevin escribió: