From: Alan Modra <amodra@bigpond.net.au>
To: "H. J. Lu" <hjl@gcc.gnu.org>
Cc: binutils@sources.redhat.com
Subject: Re: RFC: Short circuit bfd_map_over_sections
Date: Fri, 30 Apr 2004 04:15:00 -0000 [thread overview]
Message-ID: <20040430013650.GF2565@bubble.modra.org> (raw)
In-Reply-To: <20040430000133.GA27737@lucon.org>
On Thu, Apr 29, 2004 at 05:01:33PM -0700, H. J. Lu wrote:
> bfd_map_over_sections is used to call a function on each section in
> a bfd. However, there are many places where bfd_map_over_sections
> is called to find something. It isn't necessary to go through all
> sections once it is found. I'd like to modify bfd_map_over_sections to
I like the idea. The following trick might help too, allowing you to
find sections with the same name without going via bfd_map_over_sections.
I don't intend to apply this patch unless you (or others) find a use for
it.
Index: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.67
diff -u -p -r1.67 section.c
--- bfd/section.c 1 Dec 2003 06:33:01 -0000 1.67
+++ bfd/section.c 30 Apr 2004 01:26:16 -0000
@@ -945,13 +945,19 @@ bfd_make_section_anyway (bfd *abfd, cons
newsect = &sh->section;
if (newsect->name != NULL)
{
- /* We are making a section of the same name. It can't go in
- section_htab without generating a unique section name and
- that would be pointless; We don't need to traverse the
- hash table. */
- newsect = bfd_zalloc (abfd, sizeof (asection));
- if (newsect == NULL)
+ /* We are making a section of the same name. Put it in the
+ section hash table. Even though we can't find it directly by a
+ hash lookup, we'll be able to find the section by traversing
+ sh->root.next quicker than looking at all the bfd sections. */
+ struct section_hash_entry *new_sh;
+ new_sh = (struct section_hash_entry *)
+ bfd_section_hash_newfunc (NULL, &abfd->section_htab, name);
+ if (new_sh == NULL)
return NULL;
+
+ new_sh->root.next = sh->root.next;
+ sh->root.next = &new_sh->root;
+ newsect = &new_sh->section;
}
newsect->name = name;
--
Alan Modra
IBM OzLabs - Linux Technology Centre
next prev parent reply other threads:[~2004-04-30 1:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-30 0:12 H. J. Lu
2004-04-30 0:15 ` Ian Lance Taylor
2004-04-30 0:20 ` H. J. Lu
2004-04-30 0:29 ` Eric Christopher
2004-04-30 1:33 ` Ian Lance Taylor
2004-04-30 1:36 ` H. J. Lu
2004-04-30 7:29 ` Nick Clifton
2004-04-30 4:15 ` Alan Modra [this message]
2004-04-30 5:25 ` H. J. Lu
2004-04-30 17:53 ` PATCH: Add bfd_get_section_by_name_if H. J. Lu
2004-05-01 14:20 ` Alan Modra
2004-05-01 15:19 ` H. J. Lu
2004-05-02 13:32 ` Alan Modra
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=20040430013650.GF2565@bubble.modra.org \
--to=amodra@bigpond.net.au \
--cc=binutils@sources.redhat.com \
--cc=hjl@gcc.gnu.org \
/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).