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

Alexey Volkov avolkov.intel at gmail.com
Fri Mar 28 08:16:06 PDT 2014


Hi Rafael,

Binutils community said that there is no bug in linker (
https://sourceware.org/ml/binutils/2014-03/msg00233.html)
Compiler shouldn't rely on output file type to determine what options it
needed.
Instead of linker output GCC uses section .gnu.lto_.opts in object files
with IR to pass compiler options.
Thus GCC sets pic on Android with LTO enabled.
I see in object files with LLVM IR attributes section with target specific
options:
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false"
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"unsafe-fp-math"="false" "use-soft-float"="false" }
Is it possible to add fpic to those options?

Also I see that other compiler options such as -O2, -Ofast, funroll-loops
are not passed through linker to LTO.
Thus compiler output with -flto seems to be the same with any optimization
options.
Do you have any plans to support these options in LTO?


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

> On 20 February 2014 09:00, Alexey Volkov <avolkov.intel at gmail.com> wrote:
> > 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.
>
> OK, so it does seem there is a bug in the android linker, right? It is
> produce a PIE executable but not informing the plugin of that unless
> it is given the -pie 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?
>
> And the more philosophical issue of  "should we parse -Wl?".
>
> Cheers,
> Rafael
>



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


More information about the llvm-commits mailing list