From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13217 invoked by alias); 19 Mar 2005 17:57:07 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 13122 invoked from network); 19 Mar 2005 17:57:03 -0000 Received: from unknown (HELO sccrmhc11.comcast.net) (204.127.202.55) by sourceware.org with SMTP; 19 Mar 2005 17:57:03 -0000 Received: from lucon.org ([24.6.212.230]) by comcast.net (sccrmhc11) with ESMTP id <2005031917570301100ss1uve>; Sat, 19 Mar 2005 17:57:03 +0000 Received: by lucon.org (Postfix, from userid 1000) id 5C87597B72; Sat, 19 Mar 2005 09:57:01 -0800 (PST) Date: Sat, 19 Mar 2005 19:02:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: Re: PATCH: Store ELF section index for input file Message-ID: <20050319175700.GA19299@lucon.org> References: <20050317195051.GA9484@lucon.org> <20050317205827.GA10787@lucon.org> <20050319094400.GI21148@bubble.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050319094400.GI21148@bubble.modra.org> User-Agent: Mutt/1.4.1i X-SW-Source: 2005-03/txt/msg00576.txt.bz2 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.