虚拟机——D:Genymobile-virtual-devicesGoogle Nexus 9 - 5.1.0 - API 22 - 2048x1536
ndk-build——E:Andriodandroid-ndk-r10d
adb.exe——E:Andriodandroid-sdk_r24.3.3-windowsandroid-sdk-windowsplatform-tools
F:projectandroid estsocketjni 中包含文件:Android.mk, cli.c,serv.c
Android.mk 文件 内容如下:
#------------------------------------------------------
#error: only position independent executables (PIE) are supported.
#PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。
#因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。
# F:projectandroid estsocketjni
# jni> ndk-build
# jni> ndk-build -B APP_ABI=x86
adb pull <remote> <local>
adb push <local> <remote>
# F:projectandroid estsocketlibs
# adb push cli /data/data/
# adb push serv /data/data/
# adb shell
# cd /data/data/
# chmod 777 serv
# chmod 777 cli
# ./serv
# ./cli
#------------------------------------------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -O3 -fvisibility=hidden
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_MODULE := serv
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES :=
serv.c
LOCAL_LDLIBS := -lz -llog -L$(SYSROOT)/usr/lib
cmd-strip = $(TOOLCHAIN_PREFIX)strip $1
include $(BUILD_EXECUTABLE)
#include $(BUILD_SHARED_LIBRARY)
#LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -O3 -fvisibility=hidden
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_MODULE := cli
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES :=
cli.c
LOCAL_LDLIBS := -lz -llog -L$(SYSROOT)/usr/lib
cmd-strip = $(TOOLCHAIN_PREFIX)strip $1
include $(BUILD_EXECUTABLE)
#include $(BUILD_SHARED_LIBRARY)
相关热门文章
给主人留下些什么吧!~~
评论热议