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]

tweak elf_add_dt_needed_tag


This makes a small improvement to elf_add_dt_needed_tag that in some
cases avoids the search over .dynamic output contents for libraries
like libgcc_s.so that may appear multiple times on the command line.

	* elf-bfd.h (_bfd_elf_strtab_refcount): Declare.
	* elf-strtab.c (_bfd_elf_strtab_refcount): New function.
	* elflink.c (elf_add_dt_needed_tag): Use _bfd_elf_strtab_refcount.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.352
diff -u -p -r1.352 elf-bfd.h
--- bfd/elf-bfd.h	10 Jan 2013 09:49:08 -0000	1.352
+++ bfd/elf-bfd.h	11 Jan 2013 06:14:01 -0000
@@ -1938,6 +1938,8 @@ extern void _bfd_elf_strtab_addref
   (struct elf_strtab_hash *, bfd_size_type);
 extern void _bfd_elf_strtab_delref
   (struct elf_strtab_hash *, bfd_size_type);
+extern unsigned int _bfd_elf_strtab_refcount
+  (struct elf_strtab_hash *, bfd_size_type);
 extern void _bfd_elf_strtab_clear_refs
   (struct elf_strtab_hash *, bfd_size_type);
 #define _bfd_elf_strtab_clear_all_refs(tab) \
Index: bfd/elf-strtab.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-strtab.c,v
retrieving revision 1.16
diff -u -p -r1.16 elf-strtab.c
--- bfd/elf-strtab.c	9 Sep 2009 21:38:57 -0000	1.16
+++ bfd/elf-strtab.c	11 Jan 2013 06:14:01 -0000
@@ -201,6 +201,12 @@ _bfd_elf_strtab_delref (struct elf_strta
   --tab->array[idx]->refcount;
 }
 
+unsigned int
+_bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx)
+{
+  return tab->array[idx]->refcount;
+}
+
 void
 _bfd_elf_strtab_clear_refs (struct elf_strtab_hash *tab, bfd_size_type idx)
 {
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.460
diff -u -p -r1.460 elflink.c
--- bfd/elflink.c	10 Jan 2013 20:03:54 -0000	1.460
+++ bfd/elflink.c	11 Jan 2013 06:14:02 -0000
@@ -3091,19 +3091,17 @@ elf_add_dt_needed_tag (bfd *abfd,
 		       bfd_boolean do_it)
 {
   struct elf_link_hash_table *hash_table;
-  bfd_size_type oldsize;
   bfd_size_type strindex;
 
   if (!_bfd_elf_link_create_dynstrtab (abfd, info))
     return -1;
 
   hash_table = elf_hash_table (info);
-  oldsize = _bfd_elf_strtab_size (hash_table->dynstr);
   strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE);
   if (strindex == (bfd_size_type) -1)
     return -1;
 
-  if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr))
+  if (_bfd_elf_strtab_refcount (hash_table->dynstr, strindex) != 1)
     {
       asection *sdyn;
       const struct elf_backend_data *bed;

-- 
Alan Modra
Australia Development Lab, IBM


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