error: only position independent executables (PIE) are supported

error: only position independent executables (PIE) are supported,第1张

概述PIE,positionindependentexecutables.android4.1上开始支持PIE,所以4.1之前的版本不能使用PIE的executable,而之前开发的app一般都是非PIE的。Android4.1PIE(PositionIndependentExecutable)supportRead-onlyrelocations/immediatebinding


PIE, position independent executables.

androID 4.1上开始支持PIE,所以4.1之前的版本不能使用PIE的executable,而之前开发的app一般都是非PIE的。

AndroID 4.1        PIE (position Independent Executable) support        Read-only relocations / immediate binding (-Wl,-z,relro -Wl,-z,Now)        dmesg_restrict enabled (avoID leaking kernel addresses)        kptr_restrict enabled (avoID leaking kernel addresses)

在androID L后,linker.cpp中,

//bionic\linker\linker.cppstatic ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(Addr) linker_base) {  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);  //不是PIE的直接报错返回,而之前的版本中都没有  if (elf_hdr->e_type != ET_DYN) {    __libc_format_fd(2, "error: only position independent executables (PIE) are supported.\n");    exit(EXIT_FAILURE);  }}

所以在androID L后,非PIE的exe执行都会报错error: only position independent executables (PIE) are supported.

1.但是如果在androID 4.1之前的版本运行PIE, 也是有办法的:
The Chromium project released a wrapper that allows PIE binarIEs to run on pre-JB AndroID releases。

具体的使用方法见http://stackoverflow.com/questions/24818902/running-a-native-library-on-android-l-error-only-position-independent-executab,

其中run_pIE在androID L中的external\chromium_org\tools\androID\run_pIE中可找到,下面是run_pIE.c中的注释,说明run_pIE主要是为了在linker不支持PIE的早期版本中运行PIE。

// This is a wrapper to run position independent executables on AndroID ICS,// where the linker doesn't support PIE. This requires the PIE binarIEs to be// built with CFLAGS +=-fvisibility=default -fPIE, and LDFLAGS += -rdynamic -pIE// such that the main() symbol remains exported and can be dlsym-ed.

2.那么在androID L之后的版本运行非PIE,有没有办法?
目前是没有解决方案,除非你把bionic的linker替换,具体参考下面的文章,使用其中修改编译过的linker, http://forum.xda-developers.com/google-nexus-5/development/fix-bypassing-pie-security-check-t2797731

总结

以上是内存溢出为你收集整理的error: only position independent executables (PIE) are supported全部内容,希望文章能够帮你解决error: only position independent executables (PIE) are supported所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1006291.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存