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:11:00 -0000 [thread overview]
Message-ID: <20060425022744.GA24749@lucon.org> (raw)
In-Reply-To: <20060424231056.GA23563@lucon.org>
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.
H.J.
----
2006-04-24 Michael Matz <matz@suse.de>
H.J. Lu <hongjiu.lu@intel.com>
* elf.c (_bfd_elf_new_section_hook): Initialize kept_section to
(asection *) -1L.
(assign_section_numbers): Check kept_section before calling
_bfd_elf_check_kept_section.
* elflink.c (elf_link_input_bfd): Likewise.
* elflink.c (elf_link_add_object_symbols): Also check if
kept_section isn't (asection *) -1L before using it.
(elf_link_input_bfd): Likewise.
(match_group_member): Correctly iterate group members.
(_bfd_elf_check_kept_section): Cache the result in
elf_kept_section.
--- bfd/elf.c.kept 2006-04-24 19:09:01.000000000 -0700
+++ bfd/elf.c 2006-04-24 19:16:14.000000000 -0700
@@ -2481,6 +2481,8 @@ _bfd_elf_new_section_hook (bfd *abfd, as
if (sdata == NULL)
return FALSE;
sec->used_by_bfd = sdata;
+ /* Initialized it with -1L so that it can be cached. */
+ sec->kept_section = (asection *) -1L;
}
/* Indicate whether or not this section should use RELA relocations. */
@@ -3131,7 +3133,11 @@ assign_section_numbers (bfd *abfd, struc
s, s->owner);
/* Point to the kept section if it has the same
size as the discarded one. */
- kept = _bfd_elf_check_kept_section (s);
+ if (s->kept_section != NULL
+ && s->kept_section != (asection *) -1L)
+ kept = _bfd_elf_check_kept_section (s);
+ else
+ kept = NULL;
if (kept == NULL)
{
bfd_set_error (bfd_error_bad_value);
--- bfd/elflink.c.kept 2006-04-24 15:36:18.000000000 -0700
+++ bfd/elflink.c 2006-04-24 19:22:22.000000000 -0700
@@ -3587,7 +3587,8 @@ elf_link_add_object_symbols (bfd *abfd,
sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
if (sec == NULL)
sec = bfd_abs_section_ptr;
- else if (sec->kept_section)
+ else if (sec->kept_section
+ && sec->kept_section != (asection *) -1L)
{
/* Symbols from discarded section are undefined, and have
default visibility. */
@@ -6782,6 +6783,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;
}
@@ -6806,6 +6808,13 @@ _bfd_elf_check_kept_section (asection *s
if (kept != NULL && sec->size != kept->size)
kept = NULL;
}
+
+ /* kept_section is initialized to -1L. */
+ if (kept == (asection *) -1L)
+ abort ();
+
+ sec->kept_section = kept;
+
return kept;
}
@@ -7157,7 +7166,9 @@ elf_link_input_bfd (struct elf_final_lin
is that we warn in non-debug sections, and
debug sections tend to come after other
sections. */
- if (action & PRETEND)
+ if ((action & PRETEND)
+ && sec->kept_section
+ && sec->kept_section != (asection *) -1L)
{
asection *kept;
@@ -7334,7 +7345,8 @@ elf_link_input_bfd (struct elf_final_lin
case of discarded link-once and discarded
SEC_MERGE sections, use the kept section. */
if (bfd_is_abs_section (osec)
- && sec->kept_section != NULL
+ && sec->kept_section
+ && sec->kept_section != (asection *) -1L
&& sec->kept_section->output_section != NULL)
{
osec = sec->kept_section->output_section;
next prev parent reply other threads:[~2006-04-25 2:27 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 [this message]
2006-04-25 16:37 ` H. J. Lu
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=20060425022744.GA24749@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).