This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Fix linker plugin support for gnu linker
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Sat, 08 Jan 2011 12:10:52 +0000
- Subject: Re: PATCH: Fix linker plugin support for gnu linker
- References: <20110105155220.GA26924@intel.com>
"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
the correct C library sequence (-lc -lidt in the case of idt64.ld),
so LIB_SPEC is "". The only options that GCC passes are therefore:
-pass-through=-lgcc -pass-through=-lgcc
It seems to be necessary to pass:
-Wl,-plugin-opt=-pass-through=-lc
-Wl,-plugin-opt=-pass-through=-lidt
-Wl,-plugin-opt=-pass-through=-lgcc
in addition to -Tidt64.ld. Is that right, or am I missing something?
If the former, and if the -T problem with the 2-stage patch could be
fixed, perhaps 2-stage linking might solve this problem for free.
Richard