This is the mail archive of the
mailing list for the binutils project.
Re: ld -r frustration
- From: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 27 Jul 2004 17:57:34 +0100
- Subject: Re: ld -r frustration
- Organization: GNU
- References: <20040727151103.GB15182@bubble.modra.org>
On Tue, 2004-07-27 at 16:11, Alan Modra wrote:
> Every so often I get a bug report about TOC overflow when linking on
> PowerPC64 Linux. With the automatic multiple TOC support in GNU ld,
> this ought not happen very often; You need a single object file to
> exceed the 64k TOC limit. However, people use "ld -r" to combine
> object files, sometimes very many object files. So they end up with
> a TOC section that's too big. "Too bad", I say. "Don't use ld -r".
> That's not the ideal solution, especially considering that tools
> like libtool use "ld -r" to work around command line limits when
> linking huge numbers of object files. What we really need is a
> "ld -r" that doesn't do any merging of sections, or a final link
> stage that can undo the effects of "ld -r". The latter would need
> quite a bit of work, and probably not be very robust. I'm leaning
> towards the idea of making "ld -r" behave like "ar cr" on PowerPC64.
> The only trick needed is that when using the resulting archive in a
> final link we want the linker to behave as if --whole-archive were in
> effect. ie. the archive needs to be tagged specially in some way that
> the linker can recognise. I could do that quite easily by twiddling
> the magic string at the start of an archive. What's more, you could
> handle the whole business of making "ld -r" invoke "ar cr" and twiddle
> the magic string in a shell script.
> Comments? Better ideas?
> The binutils hack will look something like the following (untested!)
Well on ELF you can just write out every section unchanged in a single
object file (ELF is quite happy to have multiple sections with the same
name, it's only GAS that doesn't know how to do this). IIRC the only
thing that needs merging is the symbol table.
It's then a genuine object file and you don't need to frob the linker at