This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Store ELF section index for input file
On Sat, Mar 19, 2005 at 08:14:00PM +1030, Alan Modra wrote:
> On Thu, Mar 17, 2005 at 12:58:27PM -0800, H. J. Lu wrote:
> > @@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
> > const struct elf_backend_data *bed;
> > int index;
> >
> > - if (elf_section_data (asect) != NULL
> > - && elf_section_data (asect)->this_idx != 0)
> > - return elf_section_data (asect)->this_idx;
> > + if (elf_section_data (asect) != NULL)
> > + {
> > + index = elf_section_data (asect)->this_idx;
> > + if (index != 0)
> > + {
> > + Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
> > + if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
> > + return index;
> > + }
> > + }
>
> Please explain why this change is necessary.
>
_bfd_elf_section_from_bfd_section is called on input sections. When
there are more than 64K input sections, linear search over a linked
list can be very very slow. Since this_idx isn't used for input section
and for input section, its bfd section is created from its ELF
section index, we can use this_idx to store the ELF section index. The
result is the linking time went from
966.01s user 0.81s system 99% cpu 16:06.87 total
to
45.61s user 0.81s system 99% cpu 46.448 total
It is 20X speed up. I tested it with Linux kernel, binutils, gcc and
glibc on ia32, ia64 and x86_64. There are no regressions.
BTW, it only solves the 64K input section problem. The 64K output
sections is still very slow. bfd_section has a pointer to its BFD
owner. Can we add a pointer to bfd_section, used_by_ld, which will
be used by ld for lang_output_section_statement_type?
H.J.