error: only position independent executables (PIE) are supported.

时间:2022-06-07
本文章向大家介绍error: only position independent executables (PIE) are supported.,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
root@hlte:/data/local # ./tcpdump -p -s 0                                       
error: only position independent executables (PIE) are supported.

由于使用了NDK编译的可执行文件在应用中调用,在4.4及之前的版本上一直没出问题。最近由于要测试在Android L上的运行情况发现,当运行该可执行文件时,报上面的错误。

PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。解决办法是在Android.mk中加入如下flag就行。

LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE

基于tcpdump的Android智能移动终端数据包捕获完整解决方案

Android tcpdump抓包应用实现

Android通过tcpdump抓包