<div dir="ltr">On Android there is a bit unusual situation when compiler makes PIC code but doesn't pass -pie to linker.<div>This is what LLVM and gcc both do without -flto.</div><div>With -flto GCC still produces PIC code but not LLVM.</div>
<div>The reason is that GCC passes -fpic to compiler invocation from plugin using temporary file with options for compiler.</div><div>I tried to implement similar solution with my first patch introducing gold plugin option.</div>
<div><br></div><div>Anyway addition of -pie would produce correct code for Android.</div><div>As I understand my last patch with -pie is ok except change with sanitizer?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2014-02-20 2:11 GMT+04:00 Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On 19 February 2014 09:37, Alexey Volkov <<a href="mailto:avolkov.intel@gmail.com">avolkov.intel@gmail.com</a>> wrote:<br>
> GCC doesn't parse -Wl options and also doesn't use -pie linker option for<br>
> PIC code generation on Android.<br>
> I see different handling of -fpic option on GCC and LLVM when running with<br>
> -flto:<br>
> GCC running with -fpic -flto will generate PIC code but LLVM with -fpic<br>
> -flto will not.<br>
> This happens both on Android and Linux.<br>
> Fixing this problem could solve original problem with -flto on Android.<br>
<br>
</div>If gcc doesn't forward -pie, how come the linker produces a position<br>
independent executable? If the expectation is that the linker on<br>
android *always* produces a pie or a shared library, then it looks<br>
like we just have a bug in the linker in that it is telling the gold<br>
plugin it is producing a regular executable when it is really<br>
producing a pie.<br>
<br>
If that is not the case, it seems that the correct thing to do would be to<br>
* Don't parse -Wl options in the driver (other than to blindly forward them).<br>
* Decide if we are building a pie or not based only on the driver options.<br>
* Forward that decision to the linker with the -pie option.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Volkov<div>Intel Corporation</div></div>
</div>