PATCH: Fix linker plugin support for gnu linker

H.J. Lu hjl.tools@gmail.com
Sun Jan 9 01:50:00 GMT 2011


On Sat, Jan 8, 2011 at 7:44 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>> On Sat, Jan 8, 2011 at 6:46 AM, Richard Sandiford
>> <rdsandiford@googlemail.com> wrote:
>>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>>> On Sat, Jan 8, 2011 at 4:10 AM, Richard Sandiford
>>>> <rdsandiford@googlemail.com> wrote:
>>>>> "H.J. Lu" <hongjiu.lu@intel.com> writes:
>>>>>> This patch fixes linker plugin support for gnu linker with 2 stage
>>>>>> linking and supports mixed LTO objects:
>>>>>>
>>>>>> http://www.kernel.org/pub/linux/devel/gcc/lto/mixed-IR/mixed-IR.pdf
>>>>>>
>>>>>> Any objections?
>>>>>
>>>>> One problem with the patch as written is that it doesn't cope with
>>>>> the kind of embedded setup in which the startup file is specified
>>>>> in a linker script.  E.g. on mipsisa64-elf, GCC doesn't know what
>>>>> system you're targetting, and therefore doesn't what startup files or
>>>>> board-specific libraries are needed.  You instead link with something
>>>>> like -Tidt64.ld.  idt64.ld then contains:
>>>>>
>>>>> STARTUP(crt0.o)
>>>>>
>>>>> -T options are parsed immediately in-place, and don't show up in the
>>>>> cmdline_options.  Things like STARTUP don't either.  This means that
>>>>> crt0.o is dropped by the second stage link.
>>>>>
>>>>> The handling of -T also means that the system libraries:
>>>>>
>>>>> GROUP(-lc -lidt -lgcc)
>>>>>
>>>>> don't show up in the second link.  However, that brings up a broader
>>>>> question (which might already have been answered, sorry).  The current
>>>>> process -- that is, the process before the 2-stage patch -- seems to
>>>>> rely on the GCC driver passing the equivalent of:
>>>>>
>>>>>  -pass-through=-lgcc -pass-through=-lc -pass-through=-lgcc
>>>>>
>>>>> to the plugin.  But on targets like mipsisa64-elf, GCC doesn't know
>>>>
>>>> hjl/lto-mixed branch ignores  -pass-through=XXX passed from gcc driver.
>>>
>>> Right, that's what I meant.  The fact that the 2-pass link doesn't
>>> need those options means that it would solve the problem for free.
>>> But at the moment it doesn't work because it ignores the linker script's
>>> GROUP as well.
>>
...
>> I just need to handle STARTUP properly.
>
> And GROUP. :-)
>
>> If you can provide a native testcase on Linux/x86-64, I will fix it.
>
> Sorry, I don't have time to reproduce this on x86_64.  I'm just trying
> to provide feeback to the patch submission.

Please try commit bf235c35e8c2a386b13f034a8d3269b569b47acb
and let me know if it works for you.

Thanks.

-- 
H.J.



More information about the Binutils mailing list