- 論壇徽章:
- 0
|
本帖最后由 huzj_zju 于 2015-04-09 16:16 編輯
如題,LZ試圖在Ubuntu環(huán)境下利用NDK生產(chǎn)一個.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)
看上去是由于庫的位數(shù)不對引起的。
通過file命令發(fā)現(xiàn).so文件是32位的:
libcyclecount.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, stripped
但是我的Ubuntu系統(tǒng)是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)
所以,為什么會產(chǎn)生32位的.so文件呢,怎么解決呢??
還有一個問題
LZ在NDK過程中由class產(chǎn)生的.h文件中函數(shù)名如下:
JNIEXPORT jint JNICALL Java_get_1timing_Encrypt_get_1cyclecount(JNIEnv *env, jclass obj)
java程序中native調(diào)用:
public native static int get_cyclecount();
可見系統(tǒng)自動將函數(shù)名中添加了兩個1,這是正,F(xiàn)象么? |
|