This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Optimize add_archive_element call
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Fri, 10 Dec 2010 05:48:44 -0800
- Subject: PATCH: Optimize add_archive_element call
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
Before we call add_archive_element, we set subsbfd to NULL and
check if it is changed after add_archive_element returns. This
patch sets subsbfd to the unchanged value and avoids the check.
OK to install?
Thanks.
H.J.
---
bfd/
2010-12-10 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (elf_link_add_archive_symbols): Optimize for
add_archive_element.
ld/
2010-12-10 H.J. Lu <hongjiu.lu@intel.com>
* ldlang.c (load_symbols): Optimize for add_archive_element.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 32575d9..ec04351 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5011,7 +5011,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
{
struct elf_link_hash_entry *h;
bfd *element;
- bfd *subsbfd = NULL;
+ bfd *subsbfd;
struct bfd_link_hash_entry *undefs_tail;
symindex mark;
@@ -5074,12 +5074,13 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
undefs_tail = info->hash->undefs_tail;
+ subsbfd = element;
if (! (*info->callbacks->add_archive_element)
(info, element, symdef->name, &subsbfd))
goto error_return;
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (! bfd_link_add_symbols (subsbfd ? subsbfd : element, info))
+ if (! bfd_link_add_symbols (subsbfd, info))
goto error_return;
/* If there are any new undefined symbols, we need to make
diff --git a/ld/ldlang.c b/ld/ldlang.c
index e804a53..03a11bd 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2717,15 +2717,14 @@ load_symbols (lang_input_statement_type *entry,
loaded = FALSE;
}
- subsbfd = NULL;
+ subsbfd = member;
if (! ((*link_info.callbacks->add_archive_element)
(&link_info, member, "--whole-archive", &subsbfd)))
abort ();
/* Potentially, the add_archive_element hook may have set a
substitute BFD for us. */
- if (! bfd_link_add_symbols (subsbfd ? subsbfd : member,
- &link_info))
+ if (! bfd_link_add_symbols (member, &link_info))
{
einfo (_("%F%B: could not read symbols: %E\n"), member);
loaded = FALSE;