请问作者大大现在支持Android x86_64吗
我编译了一个Android x86_64的静态库,在64位的模拟器上运行出现闪退(lib下只有x86_64的库)
同样的代码只使用ARM64的库在模拟器上是可以的(lib下只有arm64-v8)的库
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
set(DobbyHome /Users/chago/Documents/Project/Dobby-master)
include_directories(
${DobbyHome}/include
${DobbyHome}/builtin-plugin
${DobbyHome}/builtin-plugin/SymbolResolver
${DobbyHome}/builtin-plugin/AndroidRestriction
${DobbyHome}/external/logging
)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# ${DobbyHome}/builtin-plugin/AndroidRestriction/android_restriction_demo.cc
# ${DobbyHome}/builtin-plugin/ApplicationEventMonitor/posix_file_descriptor_operation_monitor.cc
# ${DobbyHome}/builtin-plugin/ApplicationEventMonitor/dynamic_loader_monitor.cc
# Provides a relative path to your source file(s).
native-lib.cpp)
macro(SET_OPTION option value)
set(${option} ${value} CACHE INTERNAL "" FORCE)
endmacro()
SET_OPTION(DOBBY_DEBUG ON)
SET_OPTION(DOBBY_GENERATE_SHARED OFF)
SET_OPTION(DynamicBinaryInstrument ON)
SET_OPTION(NearBranch ON)
SET_OPTION(Plugin.SymbolResolver ON)
add_subdirectory(${DobbyHome} dobby)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
dobby
# Links the target library to the log library
# included in the NDK.
${log-lib} )
#include "dobby.h"
#include
#include
uint64_t getIntNum(){
int i,j;
for(i = 1; i <= 9; i++) //外层循环控制行
{
for(j = 1; j <= i; j++) //内层循环控制列
{
printf("%d*%d=%-4d",i,j,i*j);
}
printf("\n");
}
return 1024;
}
extern "C" JNIEXPORT jstring JNICALL
Java_com_example_testDObby_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
void CallBack(RegisterContext *reg_ctx, const HookEntryInfo *info){
}
__attribute__ ((constructor)) static void __my_init_func(void){
DobbyInstrument(reinterpret_cast(getIntNum), CallBack);
}
ndk.abiFilters 'x86_64'
12-02 12:46:36.002 294-294/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-02 12:46:36.002 294-294/? A/DEBUG: Build fingerprint: 'OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447841200:user/release-keys'
12-02 12:46:36.002 294-294/? A/DEBUG: Revision: '0'
12-02 12:46:36.002 294-294/? A/DEBUG: ABI: 'x86_64'
12-02 12:46:36.002 294-294/? A/DEBUG: pid: 7664, tid: 7664, name: ample.testDObby >>> com.example.testDObby <<<
12-02 12:46:36.002 294-294/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
12-02 12:46:36.003 294-294/? A/DEBUG: rax 0000000000000000 rbx 0000000000000000 rcx 00007f6d16afb0f8 rdx 0000000000000000
12-02 12:46:36.003 294-294/? A/DEBUG: rsi 0000000000000000 rdi 0000000000000003
12-02 12:46:36.003 294-294/? A/DEBUG: r8 0000000000000012 r9 0000000000000003 r10 001ada63c21637b2 r11 0000000000000202
12-02 12:46:36.003 294-294/? A/DEBUG: r12 00007f6d16afa1f8 r13 00007f6d079dbf88 r14 0000000000000002 r15 00007f6d186fba00
12-02 12:46:36.003 294-294/? A/DEBUG: cs 0000000000000033 ss 000000000000002b
12-02 12:46:36.003 294-294/? A/DEBUG: rip 00007f6d0799dcb9 rbp 00007ffda4d31eb0 rsp 00007ffda4d31e30 eflags 0000000000010202
12-02 12:46:36.004 294-294/? A/DEBUG: backtrace:
12-02 12:46:36.004 294-294/? A/DEBUG: #00 pc 000000000001dcb9 /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so (_Z30GenerateNormalTrampolineBuffermm+105)
12-02 12:46:36.004 294-294/? A/DEBUG: #01 pc 000000000001dbd4 /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so (_ZN16InterceptRouting24GenerateTrampolineBufferEPvS0_+180)
12-02 12:46:36.004 294-294/? A/DEBUG: #02 pc 000000000001e93a /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so (_ZN30DynamicBinaryInstrumentRouting35BuildDynamicBinaryInstrumentRoutingEv+202)
12-02 12:46:36.004 294-294/? A/DEBUG: #03 pc 000000000001e85c /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so (_ZN30DynamicBinaryInstrumentRouting8DispatchEv+44)
12-02 12:46:36.004 294-294/? A/DEBUG: #04 pc 000000000001d216 /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so (DobbyInstrument+486)
12-02 12:46:36.004 294-294/? A/DEBUG: #05 pc 000000000001c579 /data/app/com.example.testDObby-1/lib/x86_64/libnative-lib.so
12-02 12:46:36.004 294-294/? A/DEBUG: #06 pc 00000000000049d1 /system/bin/linker64 (__dl__ZN6soinfo17call_constructorsEv.part.134+593)
12-02 12:46:36.004 294-294/? A/DEBUG: #07 pc 000000000000c424 /system/bin/linker64 (__dl__Z9do_dlopenPKciPK17android_dlextinfo+452)
12-02 12:46:36.004 294-294/? A/DEBUG: #08 pc 0000000000003722 /system/bin/linker64 (__dl_dlopen+34)
12-02 12:46:36.004 294-294/? A/DEBUG: #09 pc 000000000039723b /system/lib64/libart.so (_ZN3art9JavaVMExt17LoadNativeLibraryEP7_JNIEnvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEP8_jobjectPS9_+699)
12-02 12:46:36.004 294-294/? A/DEBUG: #10 pc 0000000000452c32 /system/lib64/libart.so (_ZN3artL18Runtime_nativeLoadEP7_JNIEnvP7_jclassP8_jstringP8_jobjectS5_+306)
12-02 12:46:36.004 294-294/? A/DEBUG: #11 pc 000000000224ab98 /system/framework/x86_64/boot.oat (offset 0x1f56000)
12-02 12:46:36.018 294-294/? A/DEBUG: Tombstone written to: /data/tombstones/tombstone_02
12-02 12:46:36.018 294-294/? E/DEBUG: AM write failed: Broken pipe