From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22897 invoked by alias); 25 Apr 2006 00:04:33 -0000 Received: (qmail 22889 invoked by uid 22791); 25 Apr 2006 00:04:32 -0000 X-Spam-Check-By: sourceware.org Received: from smtp107.sbc.mail.mud.yahoo.com (HELO smtp107.sbc.mail.mud.yahoo.com) (68.142.198.206) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 25 Apr 2006 00:04:29 +0000 Received: (qmail 79289 invoked from network); 24 Apr 2006 23:10:58 -0000 Received: from unknown (HELO lucon.org) (hjjean@sbcglobal.net@75.0.171.244 with login) by smtp107.sbc.mail.mud.yahoo.com with SMTP; 24 Apr 2006 23:10:57 -0000 Received: by lucon.org (Postfix, from userid 1000) id 1E56964034; Mon, 24 Apr 2006 16:10:56 -0700 (PDT) Date: Tue, 25 Apr 2006 15:47:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Cc: matz@suse.de Subject: PATCH: Cache the result of _bfd_elf_check_kept_section Message-ID: <20060424231056.GA23563@lucon.org> References: <20060424175253.GA21687@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060424175253.GA21687@lucon.org> User-Agent: Mutt/1.4.2.1i Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00332.txt.bz2 On Mon, Apr 24, 2006 at 10:52:53AM -0700, H. J. Lu wrote: > This patch addresses the link speed issue by caching the result of > _bfd_elf_check_kept_section. > Apparently, I didn't include the correct patch. Here is the right one. H.J. --- 2006-04-24 Michael Matz H.J. Lu * elf-bfd.h (bfd_elf_section_data): Add kept_section. (elf_kept_section): New. * elf.c (_bfd_elf_new_section_hook): Initialize elf_kept_section to (asection *) -1L. * elflink.c (match_group_member): Correctly iterate group members. (_bfd_elf_check_kept_section): Cache the result in elf_kept_section. --- bfd/elf-bfd.h.2342 2006-03-16 12:37:42.000000000 -0800 +++ bfd/elf-bfd.h 2006-04-24 10:23:41.000000000 -0700 @@ -1168,6 +1168,10 @@ struct bfd_elf_section_data the linker. */ asection *next_in_group; + /* The pointer to the real kept section. It is computed from the + kept_section field in asection due to section group. */ + asection *kept_section; + /* A pointer used for various section optimizations. */ void *sec_info; }; @@ -1180,6 +1184,7 @@ struct bfd_elf_section_data #define elf_group_id(sec) (elf_section_data(sec)->group.id) #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group) #define elf_sec_group(sec) (elf_section_data(sec)->sec_group) +#define elf_kept_section(sec) (elf_section_data(sec)->kept_section) /* Return TRUE if section has been discarded. */ #define elf_discarded_section(sec) \ --- bfd/elf.c.2342 2006-04-21 16:15:41.000000000 -0700 +++ bfd/elf.c 2006-04-24 10:24:42.000000000 -0700 @@ -2481,6 +2481,7 @@ _bfd_elf_new_section_hook (bfd *abfd, as if (sdata == NULL) return FALSE; sec->used_by_bfd = sdata; + elf_kept_section (sec) = (asection *) -1L; } /* Indicate whether or not this section should use RELA relocations. */ --- bfd/elflink.c.2342 2006-04-05 11:10:51.000000000 -0700 +++ bfd/elflink.c 2006-04-24 10:28:31.000000000 -0700 @@ -6782,6 +6782,7 @@ match_group_member (asection *sec, asect if (bfd_elf_match_symbols_in_sections (s, sec)) return s; + s = elf_next_in_group (s); if (s == first) break; } @@ -6798,6 +6799,10 @@ _bfd_elf_check_kept_section (asection *s { asection *kept; + kept = elf_kept_section (sec); + if (kept != (asection *) -1L) + return kept; + kept = sec->kept_section; if (kept != NULL) { @@ -6806,6 +6811,13 @@ _bfd_elf_check_kept_section (asection *s if (kept != NULL && sec->size != kept->size) kept = NULL; } + + /* elf_kept_section (sec) is initialized to -1L. */ + if (kept == (asection *) -1L) + abort (); + + elf_kept_section (sec) = kept; + return kept; }