public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H. J. Lu" <hjl@lucon.org>
To: binutils@sources.redhat.com
Cc: matz@suse.de
Subject: Re: PATCH: Cache the result of _bfd_elf_check_kept_section
Date: Tue, 25 Apr 2006 16:37:00 -0000	[thread overview]
Message-ID: <20060425032219.GA25146@lucon.org> (raw)
In-Reply-To: <20060425022744.GA24749@lucon.org>

On Mon, Apr 24, 2006 at 07:27:44PM -0700, H. J. Lu wrote:
> On Mon, Apr 24, 2006 at 04:10:56PM -0700, H. J. Lu wrote:
> > 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.
> > 
> 
> Here is a patch without adding a new field to ELF section.
> 
> 

I think the new field in ELF section is useful to avoid setting
kept_section to -1L.



H.J.
----
2006-04-24  Michael Matz  <matz@suse.de>
	    H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (bfd_elf_section_data): Add kept_section.
	(elf_kept_section): New.

	* 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.kept	2006-03-16 12:37:42.000000000 -0800
+++ bfd/elf-bfd.h	2006-04-24 20:11:00.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/elflink.c.kept	2006-04-24 15:36:18.000000000 -0700
+++ bfd/elflink.c	2006-04-24 20:18:03.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,7 +6799,14 @@ _bfd_elf_check_kept_section (asection *s
 {
   asection *kept;
 
+  kept = elf_kept_section (sec);
+  if (kept)
+    return kept;
+
   kept = sec->kept_section;
+  if (!kept)
+    return kept;
+
   if (kept != NULL)
     {
       if (elf_sec_group (sec) != NULL)
@@ -6806,6 +6814,12 @@ _bfd_elf_check_kept_section (asection *s
       if (kept != NULL && sec->size != kept->size)
 	kept = NULL;
     }
+
+  if (kept)
+    elf_kept_section (sec) = kept;
+  else
+    sec->kept_section = NULL;
+
   return kept;
 }
 

      reply	other threads:[~2006-04-25  3:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-24 20:12 PATCH: PR ld/2342: linkonce debug is broken H. J. Lu
2006-04-25 15:47 ` PATCH: Cache the result of _bfd_elf_check_kept_section H. J. Lu
2006-04-25 16:11   ` H. J. Lu
2006-04-25 16:37     ` H. J. Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060425032219.GA25146@lucon.org \
    --to=hjl@lucon.org \
    --cc=binutils@sources.redhat.com \
    --cc=matz@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).