Introduction to Android NDK

Android NDK static registration dynamic registration:

Android NDK static registration dynamic registration_so static registration is not safe_Codeoooo's Blog-CSDN Blog

1. How to compile native programs

        Application.mk (ARM hardware instruction set/engineering compilation script/stl support, etc.)

        Android.mk (compilation options/header files/source files and dependent libraries, etc.)

        local_path(call my-dir)

        include $(clear_vars)

        local_arm_mode:= arm instruction mode

        local_module:=module name

        local_src_files:=source files

        build_executable (executable file)

        build_shared_library (dynamic link library)

        build_static_library (static link library))

2. The startup process of the native program

        The entry function of the native program  

        Loading of dynamic library/initialization of program parameters argc and argv

        Static link/dynamic link (dynamic link program/dynamic link library)

        Static link (crtbedin_static.o/crend_android.o)

        Dynamic link (crtbegin_dynamic.o/crtend_android.o/loader(system/bin/linker))

        The static linker does not need to load additional dynamic libraries (init/adbd/linker) at startup

        The static link is the same as the entry function of the dynamic link program, and the dynamic link program needs to perform additional initialization through the linker before executing the entry function

When is the main function executed?

        Static link (libc_init_static)/dynamic linker (libc_init_dynamic)

3. Reverse analysis of native C++ programs

        Reverse of C++ classes

        A class in C++ can be understood as a structure in C language. Each member variable is a structure field. The code of each member function is optimized outside the class, and they do not occupy storage space.

        Android NDK support for C++ features (app_stl)

        system

        gabi++(rtti)=>gabi++_static/gabi_shared

        stlport(rtti/stl)=>stlport_static/stlport_shared

        gnustl(c++异常/rtti/stl)=>gnustl_static/gnustl_shared

4. Android NDK JNI API reverse analysis

        Android NDK provides those functions

        Linux C/C++

        Android NDK<=>JNI interface<=>java

        JNINativeInterfasce (jni local interface)

        JNIInvokeInterface (jni call interface)

Porting/protecting core code

How to statically analyze Android NDK programs

     file=>load file=>parse c header file=>jni.h=>structures

Guess you like

Origin blog.csdn.net/qq_41369057/article/details/131227849