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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Feb 19 14:11:52 PST 2014


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



More information about the llvm-commits mailing list