This is the mail archive of the
mailing list for the binutils project.
Re: Relocatable linking of weak symbols with LTO
- From: Joshua Conner <jconner at nvidia dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 29 Mar 2013 14:30:04 -0700
- Subject: Re: Relocatable linking of weak symbols with LTO
- References: <5155E36D dot 4030400 at nvidia dot com> <CAMe9rOqY2CO9qc6Lkp4hwHO1q9-ZH90nFpmboQCq2TQKpDqfrQ at mail dot gmail dot com>
OK, thanks. I submitted bug 15323.
On 3/29/13 12:25 PM, H.J. Lu wrote:
On Fri, Mar 29, 2013 at 11:54 AM, Joshua Conner <email@example.com> wrote:
I have a weak function that is input to an incremental link with -flto -r.
Then, when I re-link the output with another object file in which the same
function is declared non-weak, I get an error message:
`foo' referenced in section `.text.startup' of test-intermediate: defined in
discarded section `.text' of test.o (symbol from plugin)
collect2: error: ld returned 1 exit status
Here's the command lines I'm executing:
gcc -flto -g -O2 -c -o test-weak.o test-weak.c # declares foo as weak
gcc -flto -g -O2 -c -o test.o test.c # declares foo, not as weak
gcc -flto -g -O2 -r -o test-intermediate test-weak.o -nostdlib
gcc -flto -g -O2 -o test test-intermediate test.o
I can work around this with -fno-use-linker-plugin, but I would like to get
the benefit of whole-program optimization. Is this just a limitation of the
linker plugin, that once I perform an incremental link with a weak symbol I
can't then try to overload it?
Thanks for any insight you can provide -
Please open a binutils bug.