[RFC PATCH] Enabling ld -r ELF .stab/.stabstr optimization
Ian Lance Taylor
ian@airs.com
Tue Oct 1 08:38:00 GMT 2002
Alan Modra <amodra@bigpond.net.au> writes:
> On Wed, Sep 25, 2002 at 10:03:29PM -0700, Earl Chew wrote:
> > Here is a patch to enable .stab/.stabstr optimization in the presence
> > of ld -r. This patch was generated against binutils-2.10.1 --- sorry
> > the baseline is a little dated, but that's what I'm running.
> >
> > * bfd/elflink.h (elf_link_add_object_symbols): optimize .stabstr
> > even if relocatable
> > * ld/ldlang.c (wild_doit): discard debugging sections that have
> > been marked SEC_EXCLUDE
>
> I'm a little nervous about this change, although I haven't thought of
> any particular problem. Suggestion: Modify ld so that -r sets
> link_info.traditional_format, and implement a -fno-traditional-format
> option. That way "ld -r" behaviour is unchanged unless you write
> "ld -r -fno-traditional-format". Oh, and cofflink.c should have a
> similar change to your elflink.h change.
I think that having -r imply -ftraditional-format would have other
unexpected effects. --traditional-format implies more things than
just optimizing .stabs sections.
Having -r optimize stabs sections will work poorly if the resulting
object is indeed linked with other objects, as opportunities for
optimizing stabs in the resulting executable between different -r
objects will be lost. This will hurt a certain style of building
large programs, in which each directory contributes a single .o file
built using -r.
Therefore I believe we do need a new option here, but I don't think it
should be related to --traditional-format. Instead, we need something
horrible like --optimize-stabs (the default for a final link) and
--no-optimize-stabs (the default for a relocateable link). Then
--traditional-format should imply --no-optimize-stabs.
Ian
More information about the Binutils
mailing list