android PIE error: only position independent executables (PIE) are supported解决方法
2016-04-21 09:25
579 查看
最近由于要测试在Android L上的运行情况发现,当运行某些可执行文件时,报如下错误:
error: only position independent executables (PIE) are supported.
PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。解决办法非常简单,在Android.mk中加入如下flag就行。
如果是自己定制系统且需要兼容之前的程序,可以去除PIE的校验。
可以修改/system/bin/linker文件。
google官方增加PIE验证的log:
https://android.googlesource.com/platform/bionic/+/2aebf5429bb1241a3298b5b642d38f73124c2026%5E!/#F0
如下:
可以修改android源码的bionic/linker/linker.cpp文件
屏蔽如下代码:
error: only position independent executables (PIE) are supported.
PIE这个安全机制从4.1引入,但是Android L之前的系统版本并不会去检验可执行文件是否基于PIE编译出的。因此不会报错。但是Android L已经开启验证,如果调用的可执行文件不是基于PIE方式编译的,则无法运行。解决办法非常简单,在Android.mk中加入如下flag就行。
LOCAL_CFLAGS += -fPIE -pie LOCAL_LDFLAGS += -fPIE -pie
如果是自己定制系统且需要兼容之前的程序,可以去除PIE的校验。
可以修改/system/bin/linker文件。
google官方增加PIE验证的log:
https://android.googlesource.com/platform/bionic/+/2aebf5429bb1241a3298b5b642d38f73124c2026%5E!/#F0
如下:
可以修改android源码的bionic/linker/linker.cpp文件
屏蔽如下代码:
ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base); if (elf_hdr->e_type != ET_DYN) { __libc_format_fd(2, "error: only position independent executables (PIE) are supported.\n"); exit(EXIT_FAILURE); }
相关文章推荐
- Android_实用技术(1)—— Notification的创建流程和使用方法
- Android——Eclipse编程代码提示
- Android 基础(一)、androidmanifest.xml
- Android编程实用代码合集
- android之使用signapk打包成系统应用,获取系统权限
- android WindowManager解析与骗取QQ密码案例分析
- ViewAnimator之ViewSwitcher的简单功能和用法(仿Android系统的Launcher界面)
- Android ndk报错error: format not a string literal and no format arguments [-Werror=format-security]
- Android日期时间选择对话框
- [调试] 打印类名方法名行数的Log日志
- Fragment生命周期
- Android之RadioGroup+ViewPager制作的底部导航栏
- Android SharedPreferences详解
- android基础---->音频和视频的使用
- 第十二章 、Bitmap的加载和Cache
- 第十一章、Android的线程和线程池
- 第十章、Android的消息机制
- 让我们一起来做最漂亮的Android界面吧!
- 第九章、 四大组件的工作过程
- Android全局异常统一处理