- 论坛徽章:
- 0
|
本帖最后由 huzj_zju 于 2015-04-09 16:16 编辑
如题,LZ试图在Ubuntu环境下利用NDK生产一个.so库,但是在eclipse里却不能编译通过:
报错如下:
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/hzj/workspace/Timing_attack/libs/armeabi/libcyclecount.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/hzj/workspace/Timing_attack/libs/armeabi/libcyclecount.so: /home/hzj/workspace/Timing_attack/libs/armeabi/libcyclecount.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at get_timing.Encrypt.<clinit>(Encrypt.java:15)
看上去是由于库的位数不对引起的。
通过file命令发现.so文件是32位的:
libcyclecount.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, stripped
但是我的Ubuntu系统是64位的,jdk显示是64位的:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
NDK文件也显示是64位的:
r10b (64-bit)
所以,为什么会产生32位的.so文件呢,怎么解决呢??
还有一个问题
LZ在NDK过程中由class产生的.h文件中函数名如下:
JNIEXPORT jint JNICALL Java_get_1timing_Encrypt_get_1cyclecount(JNIEnv *env, jclass obj)
java程序中native调用:
public native static int get_cyclecount();
可见系统自动将函数名中添加了两个1,这是正常现象么? |
|