[PATCH] Introduce new gold plugin option "relocation-pic"

Alexey Volkov avolkov.intel at gmail.com
Thu Feb 20 06:00:49 PST 2014


On Android there is a bit unusual situation when compiler makes PIC code
but doesn't pass -pie to linker.
This is what LLVM and gcc both do without -flto.
With -flto GCC still produces PIC code but not LLVM.
The reason is that GCC passes -fpic to compiler invocation from plugin
using temporary file with options for compiler.
I tried to implement similar solution with my first patch introducing gold
plugin option.

Anyway addition of -pie would produce correct code for Android.
As I understand my last patch with -pie is ok except change with sanitizer?


2014-02-20 2:11 GMT+04:00 Rafael EspĂ­ndola <rafael.espindola at gmail.com>:

> On 19 February 2014 09:37, Alexey Volkov <avolkov.intel at gmail.com> wrote:
> > GCC doesn't parse -Wl options and also doesn't use -pie linker option for
> > PIC code generation on Android.
> > I see different handling of -fpic option on GCC and LLVM when running
> with
> > -flto:
> > GCC running with -fpic -flto will generate PIC code but LLVM with -fpic
> > -flto will not.
> > This happens both on Android and Linux.
> > Fixing this problem could solve original problem with -flto on Android.
>
> If gcc doesn't forward -pie, how come the linker produces a position
> independent executable? If the expectation is that the linker on
> android *always* produces a pie or a shared library, then it looks
> like we just have a bug in the linker in that it is telling the gold
> plugin it is producing a regular executable when it is really
> producing a pie.
>
> If that is not the case, it seems that the correct thing to do would be to
> * Don't parse -Wl options in the driver (other than to blindly forward
> them).
> * Decide if we are building a pie or not based only on the driver options.
> * Forward that decision to the linker with the -pie option.
>
> Cheers,
> Rafael
>



-- 
Alexey Volkov
Intel Corporation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140220/2bb2f2d3/attachment.html>


More information about the llvm-commits mailing list