I trying to use ARM code from Android, using JNI. After i downloaded everything (NDK, toolchain) i opened the example NDK project called hello-jni. After build, it worked well. Now i try to use some ARM. I found a hello-world ARM example:
.align 2
.global armFunction
.type armFunction, %function
armFunction:
stmfd sp!, {fp,ip,lr}
mov r3, r0, asl #3
add r0, r3, r0, asl #1
ldmfd sp!, {fp,ip,lr}
bx lr
.size armFunction, .-armFunction
I modified the C source code, added a function:
jint
Java_com_example_hellojni_HelloJni_factorialJNI(
JNIEnv* env, jobject object, jint input) {
return armFunction(input);
}
i modified the Android.mk file too:
LOCAL_SRC_FILES := hello-jni.c multiple.S
After that i build the native code using ndk-build, i got an error:
c:\android\hello-jni\ndk-build
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
Gdbsetup : libs/armeabi-v7a/gdb.setup
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Gdbserver : [x86-4.6] libs/x86/gdbserver
Gdbsetup : libs/x86/gdb.setup
Gdbserver : [mipsel-linux-android-4.6] libs/mips/gdbserver
Gdbsetup : libs/mips/gdb.setup
"Compile arm : hello-jni <= hello-jni.c
"Compile arm : hello-jni <= multiple.S
SharedLibrary : libhello-jni.so
Install : libhello-jni.so => libs/armeabi-v7a/libhello-jni.so
"Compile arm : hello-jni <= hello-jni.c
"Compile arm : hello-jni <= multiple.S
SharedLibrary : libhello-jni.so
Install : libhello-jni.so => libs/armeabi/libhello-jni.so
"Compile x86 : hello-jni <= hello-jni.c
"Compile x86 : hello-jni <= multiple.S
jni/multiple.S: Assembler messages:
jni/multiple.S:6: Error: no such instruction: `stmfd sp!,{fp,ip,lr}'
jni/multiple.S:7: Error: too many memory references for `mov'
jni/multiple.S:8: Error: too many memory references for `add'
jni/multiple.S:9: Error: no such instruction: `ldmfd sp!,{fp,ip,lr}'
jni/multiple.S:10: Error: no such instruction: `bx lr'
make: *** [obj/local/x86/objs-debug/hello-jni/multiple.o] Error 1
Why those instructions are not working? Should i just compile the ARM code seperately? I thought, the ndk-build will build it.
--edit my application.mk file:
APP_ABI := all
APP_ABI := armeabiin your Application.mk - krsteeve