This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Optimize add_archive_element call


On Fri, Dec 10, 2010 at 2:37 PM, Alan Modra <amodra@gmail.com> wrote:
> On Fri, Dec 10, 2010 at 05:48:44AM -0800, H.J. Lu wrote:
>> 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?
>
> Why not get rid of subsbfd entirely?
>
> ? ? ? ? ?if (! (*info->callbacks->add_archive_element)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(info, element, symdef->name, &element))
>

Like this?

-- 
H.J.
---
bfd/

2010-12-10  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (elf_link_add_archive_symbols): Remove subsbfd.

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..a8aac7c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5011,7 +5011,6 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_i
nfo *info)
 	{
 	  struct elf_link_hash_entry *h;
 	  bfd *element;
-	  bfd *subsbfd = NULL;
 	  struct bfd_link_hash_entry *undefs_tail;
 	  symindex mark;

@@ -5075,11 +5074,9 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_
info *info)
 	  undefs_tail = info->hash->undefs_tail;

 	  if (! (*info->callbacks->add_archive_element)
-				(info, element, symdef->name, &subsbfd))
+				(info, element, symdef->name, &element))
 	    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 (element, 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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]