为什么ARM的Linux的androideabi-GCC执行-fpic? [英] Why does arm-linux-androideabi-gcc enforce -fpic?

查看:202
本文介绍了为什么ARM的Linux的androideabi-GCC执行-fpic?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶地看到,海湾合作委员会实施code是位置无关,即使不是在命令行中明确规定这样的标志。

我怀疑它可能与来自Android的动态加载一定的期望做(对重定位类型和自由例如期望把code的地方就是了),但我不能肯定。

有谁能够解释为什么这确实是?​​

  $臂Linux的androideabi-GCC --version | GCC的grep
臂Linux的androideabi-GCC(海湾合作委员会)4.4.3$臂Linux的androideabi-GCC -v -S main.c中|&安培; grep的子卡
 /home1/local64/android-toolchain/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/cc1 -quiet -v -i preFIX /和home1 / local64 / Android的工具链/斌/ ../lib/gcc/arm-linux-androideabi/4.4.3/ -isysroot /home1/local64/android-toolchain/bin/../sysroot的main.c -mbionic -fpic -quiet -dumpbase main.c中-march =的ARMv5TE -mfloat-ABI =软-mfpu = VFP -auxbase主要-version -o main.s


解决方案

与Android 4.1开始,谷歌正在迫使全的 ASLR 克服常见的安全漏洞,请参阅的这篇文章了解更多详情。

位置无关code(PIC)需要这个工作,但也PIE(位置独立的可执行文件)了。

I was surprised to see that gcc enforces code to be position independent, even if such flag wasn't provided explicitly in the command line.

I suspect it might have to do with certain expectations from Android's dynamic loader (e.g. expectations on relocation types and freedom to put code wherever it wants) but I am not certain.

Can anybody explain why that really is?

$ arm-linux-androideabi-gcc --version | grep GCC
arm-linux-androideabi-gcc (GCC) 4.4.3

$ arm-linux-androideabi-gcc -v -S main.c |& grep fpic
 /home1/local64/android-toolchain/bin/../libexec/gcc/arm-linux-androideabi/4.4.3/cc1 -quiet -v -iprefix /home1/local64/android-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.4.3/ -isysroot /home1/local64/android-toolchain/bin/../sysroot main.c -mbionic -fpic -quiet -dumpbase main.c -march=armv5te -mfloat-abi=soft -mfpu=vfp -auxbase main -version -o main.s

解决方案

Starting with Android 4.1, Google is forcing full ASLR to overcome common security exploits, see this article for more details.

Position Independent Code (PIC) is required for this to work but also PIE (Position Independent Executable) too.

这篇关于为什么ARM的Linux的androideabi-GCC执行-fpic?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆