public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFC: Store ELF section index for input file
@ 2005-03-17 22:03 H. J. Lu
  2005-03-17 23:06 ` PATCH: " H. J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: H. J. Lu @ 2005-03-17 22:03 UTC (permalink / raw)
  To: binutils

When there are many sections in input file,
_bfd_elf_make_section_from_shdr can be very slow. Can we store ELF
section index in bfd section for input file? With this patch, the link
time of my testcase went from

966.01s user 0.81s system 99% cpu 16:06.87 total

to

49.03s user 0.76s system 99% cpu 49.816 total


H.J.
--- bfd/elf-bfd.h.fast	2005-03-03 13:35:31.000000000 -0800
+++ bfd/elf-bfd.h	2005-03-17 11:14:18.656521092 -0800
@@ -629,7 +629,7 @@ struct elf_backend_data
   /* A function to handle unusual section types when creating BFD
      sections from ELF sections.  */
   bfd_boolean (*elf_backend_section_from_shdr)
-    (bfd *, Elf_Internal_Shdr *, const char *);
+    (bfd *, Elf_Internal_Shdr *, const char *, int);
 
   /* A function to convert machine dependent section header flags to
      BFD internal section header flags.  */
@@ -1060,7 +1060,8 @@ struct bfd_elf_section_data
   unsigned int rel_count2;
 
   /* The ELF section number of this section.  Only used for an output
-     file.  */
+     file.  Also used for an input file as the index into the ELF
+     section array, elf_elfsections.  */
   int this_idx;
 
   /* The ELF section number of the reloc section indicated by
@@ -1416,7 +1417,7 @@ extern bfd_boolean bfd_elf_mkcorefile
 extern Elf_Internal_Shdr *bfd_elf_find_section
   (bfd *, char *);
 extern bfd_boolean _bfd_elf_make_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 extern bfd_boolean _bfd_elf_make_section_from_phdr
   (bfd *, Elf_Internal_Phdr *, int, const char *);
 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
--- bfd/elf.c.fast	2005-03-16 15:14:41.000000000 -0800
+++ bfd/elf.c	2005-03-17 11:19:25.464861663 -0800
@@ -673,7 +673,8 @@ bfd_elf_is_group_section (bfd *abfd ATTR
 bfd_boolean
 _bfd_elf_make_section_from_shdr (bfd *abfd,
 				 Elf_Internal_Shdr *hdr,
-				 const char *name)
+				 const char *name,
+				 int shindex)
 {
   asection *newsect;
   flagword flags;
@@ -692,6 +693,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 
   hdr->bfd_section = newsect;
   elf_section_data (newsect)->this_hdr = *hdr;
+  elf_section_data (newsect)->this_idx = shindex;
 
   /* Always use the real type/flags.  */
   elf_section_type (newsect) = hdr->sh_type;
@@ -1730,10 +1732,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_FINI_ARRAY:	/* .fini_array section.  */
     case SHT_PREINIT_ARRAY:	/* .preinit_array section.  */
     case SHT_GNU_LIBLIST:	/* .gnu.liblist section.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_DYNAMIC:	/* Dynamic linking information.  */
-      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
 	{
@@ -1784,7 +1786,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
          linker.  */
       if ((hdr->sh_flags & SHF_ALLOC) != 0
 	  && (abfd->flags & DYNAMIC) != 0
-	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						shindex))
 	return FALSE;
 
       /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
@@ -1828,7 +1831,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
       /* Besides being a symbol table, we also treat this as a regular
 	 section, so that objcopy can handle it.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_SYMTAB_SHNDX:	/* Symbol section indices when >64k sections */
       if (elf_symtab_shndx (abfd) == shindex)
@@ -1864,7 +1867,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	  elf_elfsections (abfd)[shindex] = hdr;
 	  /* We also treat this as a regular section, so that objcopy
 	     can handle it.  */
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 	}
 
       /* If the string table isn't one of the above, then treat it as a
@@ -1889,7 +1893,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 		}
 	    }
 	}
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_REL:
     case SHT_RELA:
@@ -1906,7 +1910,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	    ((*_bfd_error_handler)
 	     (_("%B: invalid link %lu for reloc section %s (index %u)"),
 	      abfd, hdr->sh_link, name, shindex));
-	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
 	  }
 
 	/* For some incomprehensible reason Oracle distributes
@@ -1953,7 +1958,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	   can't use it as a reloc section if it points to the null
 	   section.  */
 	if (hdr->sh_link != elf_onesymtab (abfd) || hdr->sh_info == SHN_UNDEF)
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 
 	if (! bfd_section_from_shdr (abfd, hdr->sh_info))
 	  return FALSE;
@@ -1990,19 +1996,19 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_GNU_verdef:
       elf_dynverdef (abfd) = shindex;
       elf_tdata (abfd)->dynverdef_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_versym:
       elf_dynversym (abfd) = shindex;
       elf_tdata (abfd)->dynversym_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_verneed:
       elf_dynverref (abfd) = shindex;
       elf_tdata (abfd)->dynverref_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_SHLIB:
@@ -2015,7 +2021,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
       name = group_signature (abfd, hdr);
       if (name == NULL)
 	return FALSE;
-      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (hdr->contents != NULL)
 	{
@@ -2041,7 +2047,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name);
+      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
+						 shindex);
     }
 
   return TRUE;
--- bfd/elfxx-ia64.c.fast	2005-03-16 15:14:41.000000000 -0800
+++ bfd/elfxx-ia64.c	2005-03-17 11:23:28.057503044 -0800
@@ -193,8 +193,6 @@ static void elfNN_ia64_relax_ldxmov
   PARAMS((bfd_byte *contents, bfd_vma off));
 static bfd_boolean is_unwind_section_name
   PARAMS ((bfd *abfd, const char *));
-static bfd_boolean elfNN_ia64_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elfNN_ia64_section_flags
   PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elfNN_ia64_fake_sections
@@ -1271,13 +1269,14 @@ is_unwind_section_name (abfd, name)
 }
 
 /* Handle an IA-64 specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.  */
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
-elfNN_ia64_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elfNN_ia64_section_from_shdr (bfd *abfd,
+			      Elf_Internal_Shdr *hdr,
+			      const char *name,
+			      int shindex)
 {
   asection *newsect;
 
@@ -1301,7 +1300,7 @@ elfNN_ia64_section_from_shdr (abfd, hdr,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* PATCH: Store ELF section index for input file
  2005-03-17 22:03 RFC: Store ELF section index for input file H. J. Lu
@ 2005-03-17 23:06 ` H. J. Lu
  2005-03-19 18:57   ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: H. J. Lu @ 2005-03-17 23:06 UTC (permalink / raw)
  To: binutils

On Thu, Mar 17, 2005 at 11:50:51AM -0800, H. J. Lu wrote:
> When there are many sections in input file,
> _bfd_elf_make_section_from_shdr can be very slow. Can we store ELF
> section index in bfd section for input file? With this patch, the link
> time of my testcase went from
> 
> 966.01s user 0.81s system 99% cpu 16:06.87 total
> 
> to
> 
> 49.03s user 0.76s system 99% cpu 49.816 total
> 

I didn't get "make check" failures on ia32, x86_64 and ia64 with this
patch applied. The link time of my testcase is

45.61s user 0.81s system 99% cpu 46.448 total


H.J.
------
2005-03-17  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (elf_backend_data): Add int to
	elf_backend_section_from_shdr.
	(bfd_elf_section_data): Update this_idx to indicate it will be
	used for input file.
	(_bfd_elf_make_section_from_shdr): Add int.
	* elfxx-mips.h (_bfd_mips_elf_section_from_shdr): Likewise.

	* elf.c (_bfd_elf_make_section_from_shdr): Take section index
	and use it to set this_idx in bfd_elf_section_data.
	(bfd_section_from_shdr): Pass shindex to
	_bfd_elf_make_section_from_shdr.
	(_bfd_elf_section_from_bfd_section): Use this_idx in
	bfd_elf_section_data to find section index.

	* elf32-arm.c (elf32_arm_section_from_shdr): Take section
	index and pass it to _bfd_elf_make_section_from_shdr.
	* elf32-i370.c(i370_elf_section_from_shdr): Likewise.
	* elf32-ppc.c (ppc_elf_section_from_shdr): Likewise.
	* elf32-sh64.c (sh64_backend_section_from_shdr): Likewise.
	* elf32-v850.c (v850_elf_section_from_shdr): Likewise.
	* elf64-alpha.c (elf64_alpha_section_from_shdr): Likewise.
	* elf64-hppa.c (elf64_hppa_section_from_shdr): Likewise.
	* elf64-x86-64.c (elf64_x86_64_section_from_shdr): Likewise.
	* elfxx-ia64.c (elfNN_ia64_section_from_shdr): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Likewise.

--- bfd/elf-bfd.h.fast	2005-03-03 13:35:31.000000000 -0800
+++ bfd/elf-bfd.h	2005-03-17 12:32:59.465961028 -0800
@@ -629,7 +629,7 @@ struct elf_backend_data
   /* A function to handle unusual section types when creating BFD
      sections from ELF sections.  */
   bfd_boolean (*elf_backend_section_from_shdr)
-    (bfd *, Elf_Internal_Shdr *, const char *);
+    (bfd *, Elf_Internal_Shdr *, const char *, int);
 
   /* A function to convert machine dependent section header flags to
      BFD internal section header flags.  */
@@ -1060,7 +1060,8 @@ struct bfd_elf_section_data
   unsigned int rel_count2;
 
   /* The ELF section number of this section.  Only used for an output
-     file.  */
+     file.  Also used for an input file as the index into the ELF
+     section array, elf_elfsections.  */
   int this_idx;
 
   /* The ELF section number of the reloc section indicated by
@@ -1416,7 +1417,7 @@ extern bfd_boolean bfd_elf_mkcorefile
 extern Elf_Internal_Shdr *bfd_elf_find_section
   (bfd *, char *);
 extern bfd_boolean _bfd_elf_make_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 extern bfd_boolean _bfd_elf_make_section_from_phdr
   (bfd *, Elf_Internal_Phdr *, int, const char *);
 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
--- bfd/elf.c.fast	2005-03-17 12:32:59.271986095 -0800
+++ bfd/elf.c	2005-03-17 12:32:59.470960382 -0800
@@ -673,7 +673,8 @@ bfd_elf_is_group_section (bfd *abfd ATTR
 bfd_boolean
 _bfd_elf_make_section_from_shdr (bfd *abfd,
 				 Elf_Internal_Shdr *hdr,
-				 const char *name)
+				 const char *name,
+				 int shindex)
 {
   asection *newsect;
   flagword flags;
@@ -692,6 +693,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 
   hdr->bfd_section = newsect;
   elf_section_data (newsect)->this_hdr = *hdr;
+  elf_section_data (newsect)->this_idx = shindex;
 
   /* Always use the real type/flags.  */
   elf_section_type (newsect) = hdr->sh_type;
@@ -1730,10 +1732,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_FINI_ARRAY:	/* .fini_array section.  */
     case SHT_PREINIT_ARRAY:	/* .preinit_array section.  */
     case SHT_GNU_LIBLIST:	/* .gnu.liblist section.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_DYNAMIC:	/* Dynamic linking information.  */
-      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
 	{
@@ -1784,7 +1786,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
          linker.  */
       if ((hdr->sh_flags & SHF_ALLOC) != 0
 	  && (abfd->flags & DYNAMIC) != 0
-	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						shindex))
 	return FALSE;
 
       /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
@@ -1828,7 +1831,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
       /* Besides being a symbol table, we also treat this as a regular
 	 section, so that objcopy can handle it.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_SYMTAB_SHNDX:	/* Symbol section indices when >64k sections */
       if (elf_symtab_shndx (abfd) == shindex)
@@ -1864,7 +1867,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	  elf_elfsections (abfd)[shindex] = hdr;
 	  /* We also treat this as a regular section, so that objcopy
 	     can handle it.  */
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 	}
 
       /* If the string table isn't one of the above, then treat it as a
@@ -1889,7 +1893,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 		}
 	    }
 	}
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_REL:
     case SHT_RELA:
@@ -1906,7 +1910,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	    ((*_bfd_error_handler)
 	     (_("%B: invalid link %lu for reloc section %s (index %u)"),
 	      abfd, hdr->sh_link, name, shindex));
-	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
 	  }
 
 	/* For some incomprehensible reason Oracle distributes
@@ -1953,7 +1958,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	   can't use it as a reloc section if it points to the null
 	   section.  */
 	if (hdr->sh_link != elf_onesymtab (abfd) || hdr->sh_info == SHN_UNDEF)
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 
 	if (! bfd_section_from_shdr (abfd, hdr->sh_info))
 	  return FALSE;
@@ -1990,19 +1996,19 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_GNU_verdef:
       elf_dynverdef (abfd) = shindex;
       elf_tdata (abfd)->dynverdef_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_versym:
       elf_dynversym (abfd) = shindex;
       elf_tdata (abfd)->dynversym_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_verneed:
       elf_dynverref (abfd) = shindex;
       elf_tdata (abfd)->dynverref_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_SHLIB:
@@ -2015,7 +2021,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
       name = group_signature (abfd, hdr);
       if (name == NULL)
 	return FALSE;
-      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (hdr->contents != NULL)
 	{
@@ -2041,7 +2047,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name);
+      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
+						 shindex);
     }
 
   return TRUE;
@@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
   const struct elf_backend_data *bed;
   int index;
 
-  if (elf_section_data (asect) != NULL
-      && elf_section_data (asect)->this_idx != 0)
-    return elf_section_data (asect)->this_idx;
+  if (elf_section_data (asect) != NULL)
+    {
+      index = elf_section_data (asect)->this_idx;
+      if (index != 0)
+	{
+	  Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
+	  if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
+	    return index;
+	}
+    }
 
   if (bfd_is_abs_section (asect))
     index = SHN_ABS;
@@ -4839,6 +4853,9 @@ _bfd_elf_section_from_bfd_section (bfd *
   else if (bfd_is_und_section (asect))
     index = SHN_UNDEF;
   else
+#if 1
+    index = -1;
+#else
     {
       Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
       int maxindex = elf_numsections (abfd);
@@ -4852,6 +4869,7 @@ _bfd_elf_section_from_bfd_section (bfd *
 	}
       index = -1;
     }
+#endif
 
   bed = get_elf_backend_data (abfd);
   if (bed->elf_backend_section_from_bfd_section)
--- bfd/elf32-arm.c.fast	2005-02-11 13:17:56.000000000 -0800
+++ bfd/elf32-arm.c	2005-03-17 12:32:59.474959865 -0800
@@ -5486,13 +5486,15 @@ elf32_arm_fake_sections (bfd * abfd, Elf
   return TRUE;
 }
 
-/* Handle an ARM specific section when reading an object file.
-   This is called when elf.c finds a section with an unknown type.  */
+/* Handle an ARM specific section when reading an object file.  This is
+   called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
 elf32_arm_section_from_shdr (bfd *abfd,
 			     Elf_Internal_Shdr * hdr,
-			     const char *name)
+			     const char *name,
+			     int shindex)
 {
   /* There ought to be a place to keep ELF backend specific flags, but
      at the moment there isn't one.  We just keep track of the
@@ -5508,7 +5510,7 @@ elf32_arm_section_from_shdr (bfd *abfd,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   return TRUE;
--- bfd/elf32-i370.c.fast	2004-10-21 08:52:32.000000000 -0700
+++ bfd/elf32-i370.c	2005-03-17 12:32:59.476959607 -0800
@@ -286,8 +286,6 @@ static void i370_elf_post_process_header
   PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_boolean i370_elf_create_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean i370_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean i370_elf_fake_sections
   PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static bfd_boolean i370_elf_check_relocs
@@ -385,15 +383,15 @@ i370_elf_merge_private_bfd_data (ibfd, o
  */
 
 static bfd_boolean
-i370_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+i370_elf_section_from_shdr (bfd *abfd,
+			    Elf_Internal_Shdr *hdr,
+			    const char *name,
+			    int shindex)
 {
   asection *newsect;
   flagword flags;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   newsect = hdr->bfd_section;
--- bfd/elf32-ppc.c.fast	2005-03-16 15:08:05.000000000 -0800
+++ bfd/elf32-ppc.c	2005-03-17 12:32:59.479959219 -0800
@@ -1760,15 +1760,19 @@ ppc_elf_plt_sym_val (bfd_vma i ATTRIBUTE
 }
 
 /* Handle a PowerPC specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.  */
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
-ppc_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr, const char *name)
+ppc_elf_section_from_shdr (bfd *abfd,
+			   Elf_Internal_Shdr *hdr,
+			   const char *name,
+			   int shindex)
 {
   asection *newsect;
   flagword flags;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   newsect = hdr->bfd_section;
--- bfd/elf32-sh64.c.fast	2005-03-03 09:15:39.000000000 -0800
+++ bfd/elf32-sh64.c	2005-03-17 12:32:59.481958961 -0800
@@ -63,7 +63,7 @@ static bfd_boolean sh64_elf_link_output_
   (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
    struct elf_link_hash_entry *);
 static bfd_boolean sh64_backend_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 static void sh64_elf_final_write_processing
   (bfd *, bfd_boolean);
 static bfd_boolean sh64_bfd_elf_copy_private_section_data
@@ -253,13 +253,14 @@ sh64_elf_merge_private_data (bfd *ibfd, 
 }
 
 /* Handle a SH64-specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.
 
    We only recognize SHT_SH5_CR_SORTED, on the .cranges section.  */
 
 bfd_boolean
 sh64_backend_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
-				const char *name)
+				const char *name, int shindex)
 {
   flagword flags = 0;
 
@@ -284,7 +285,7 @@ sh64_backend_section_from_shdr (bfd *abf
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   if (flags
--- bfd/elf32-v850.c.fast	2005-03-03 09:15:42.000000000 -0800
+++ bfd/elf32-v850.c	2005-03-17 12:52:03.609106954 -0800
@@ -78,8 +78,6 @@ static bfd_boolean v850_elf_add_symbol_h
 static bfd_boolean v850_elf_link_output_symbol_hook
   PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
 	   asection *, struct elf_link_hash_entry *));
-static bfd_boolean v850_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean v850_elf_gc_sweep_hook
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
@@ -2210,16 +2208,16 @@ v850_elf_link_output_symbol_hook (info, 
 }
 
 static bfd_boolean
-v850_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+v850_elf_section_from_shdr (bfd *abfd,
+			    Elf_Internal_Shdr *hdr,
+			    const char *name,
+			    int shindex)
 {
   /* There ought to be a place to keep ELF backend specific flags, but
      at the moment there isn't one.  We just keep track of the
      sections by their name, instead.  */
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   switch (hdr->sh_type)
--- bfd/elf64-alpha.c.fast	2005-01-31 21:41:45.000000000 -0800
+++ bfd/elf64-alpha.c	2005-03-17 12:44:49.352224625 -0800
@@ -72,8 +72,6 @@ static bfd_boolean elf64_alpha_mkobject
   PARAMS ((bfd *));
 static bfd_boolean elf64_alpha_object_p
   PARAMS ((bfd *));
-static bfd_boolean elf64_alpha_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elf64_alpha_section_flags
   PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elf64_alpha_fake_sections
@@ -2260,15 +2258,16 @@ elf64_alpha_relax_section (abfd, sec, li
 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
 \f
 /* Handle an Alpha specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.
    FIXME: We need to handle the SHF_ALPHA_GPREL flag, but I'm not sure
    how to.  */
 
 static bfd_boolean
-elf64_alpha_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elf64_alpha_section_from_shdr (bfd *abfd,
+			       Elf_Internal_Shdr *hdr,
+			       const char *name,
+			       int shindex)
 {
   asection *newsect;
 
@@ -2287,7 +2286,7 @@ elf64_alpha_section_from_shdr (abfd, hdr
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elf64-hppa.c.fast	2005-02-02 09:28:22.000000000 -0800
+++ bfd/elf64-hppa.c	2005-03-17 12:44:09.561366675 -0800
@@ -184,9 +184,6 @@ static const char *get_dyn_name
 static bfd_boolean elf64_hppa_object_p
   PARAMS ((bfd *));
 
-static bfd_boolean elf64_hppa_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
-
 static void elf64_hppa_post_process_headers
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -413,10 +410,10 @@ elf64_hppa_object_p (abfd)
 /* Given section type (hdr->sh_type), return a boolean indicating
    whether or not the section is an elf64-hppa specific section.  */
 static bfd_boolean
-elf64_hppa_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elf64_hppa_section_from_shdr (bfd *abfd,
+			      Elf_Internal_Shdr *hdr,
+			      const char *name,
+			      int shindex)
 {
   asection *newsect;
 
@@ -436,7 +433,7 @@ elf64_hppa_section_from_shdr (abfd, hdr,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elf64-x86-64.c.fast	2005-03-17 12:32:59.303981960 -0800
+++ bfd/elf64-x86-64.c	2005-03-17 12:32:59.490957798 -0800
@@ -2848,12 +2848,15 @@ elf64_x86_64_plt_sym_val (bfd_vma i, con
    is called when elfcode.h finds a section with an unknown type.  */
 
 static bfd_boolean
-elf64_x86_64_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr, const char *name)
+elf64_x86_64_section_from_shdr (bfd *abfd,
+				Elf_Internal_Shdr *hdr,
+				const char *name,
+				int shindex)
 {
   if (hdr->sh_type != SHT_X86_64_UNWIND)
     return FALSE;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   return TRUE;
--- bfd/elfxx-ia64.c.fast	2005-03-17 12:32:58.906033386 -0800
+++ bfd/elfxx-ia64.c	2005-03-17 12:32:59.494957281 -0800
@@ -193,8 +193,6 @@ static void elfNN_ia64_relax_ldxmov
   PARAMS((bfd_byte *contents, bfd_vma off));
 static bfd_boolean is_unwind_section_name
   PARAMS ((bfd *abfd, const char *));
-static bfd_boolean elfNN_ia64_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elfNN_ia64_section_flags
   PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elfNN_ia64_fake_sections
@@ -1271,13 +1269,14 @@ is_unwind_section_name (abfd, name)
 }
 
 /* Handle an IA-64 specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.  */
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
-elfNN_ia64_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elfNN_ia64_section_from_shdr (bfd *abfd,
+			      Elf_Internal_Shdr *hdr,
+			      const char *name,
+			      int shindex)
 {
   asection *newsect;
 
@@ -1301,7 +1300,7 @@ elfNN_ia64_section_from_shdr (abfd, hdr,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elfxx-mips.c.fast	2005-03-17 12:18:03.076798623 -0800
+++ bfd/elfxx-mips.c	2005-03-17 12:32:59.499956635 -0800
@@ -5068,8 +5068,10 @@ _bfd_mips_elf_section_processing (bfd *a
    how to.  */
 
 bfd_boolean
-_bfd_mips_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
-				 const char *name)
+_bfd_mips_elf_section_from_shdr (bfd *abfd,
+				 Elf_Internal_Shdr *hdr,
+				 const char *name,
+				 int shindex)
 {
   flagword flags = 0;
 
@@ -5141,7 +5143,7 @@ _bfd_mips_elf_section_from_shdr (bfd *ab
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   if (flags)
--- bfd/elfxx-mips.h.fast	2005-03-03 09:16:03.000000000 -0800
+++ bfd/elfxx-mips.h	2005-03-17 12:47:33.258043584 -0800
@@ -31,7 +31,7 @@ extern bfd_boolean _bfd_mips_elf_name_lo
 extern bfd_boolean _bfd_mips_elf_section_processing
   (bfd *, Elf_Internal_Shdr *);
 extern bfd_boolean _bfd_mips_elf_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 extern bfd_boolean _bfd_mips_elf_fake_sections
   (bfd *, Elf_Internal_Shdr *, asection *);
 extern bfd_boolean _bfd_mips_elf_section_from_bfd_section

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-17 23:06 ` PATCH: " H. J. Lu
@ 2005-03-19 18:57   ` Alan Modra
  2005-03-19 19:02     ` H. J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2005-03-19 18:57 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Thu, Mar 17, 2005 at 12:58:27PM -0800, H. J. Lu wrote:
> @@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
>    const struct elf_backend_data *bed;
>    int index;
>  
> -  if (elf_section_data (asect) != NULL
> -      && elf_section_data (asect)->this_idx != 0)
> -    return elf_section_data (asect)->this_idx;
> +  if (elf_section_data (asect) != NULL)
> +    {
> +      index = elf_section_data (asect)->this_idx;
> +      if (index != 0)
> +	{
> +	  Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
> +	  if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
> +	    return index;
> +	}
> +    }

Please explain why this change is necessary.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-19 18:57   ` Alan Modra
@ 2005-03-19 19:02     ` H. J. Lu
  2005-03-20 13:22       ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: H. J. Lu @ 2005-03-19 19:02 UTC (permalink / raw)
  To: binutils

On Sat, Mar 19, 2005 at 08:14:00PM +1030, Alan Modra wrote:
> On Thu, Mar 17, 2005 at 12:58:27PM -0800, H. J. Lu wrote:
> > @@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
> >    const struct elf_backend_data *bed;
> >    int index;
> >  
> > -  if (elf_section_data (asect) != NULL
> > -      && elf_section_data (asect)->this_idx != 0)
> > -    return elf_section_data (asect)->this_idx;
> > +  if (elf_section_data (asect) != NULL)
> > +    {
> > +      index = elf_section_data (asect)->this_idx;
> > +      if (index != 0)
> > +	{
> > +	  Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
> > +	  if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
> > +	    return index;
> > +	}
> > +    }
> 
> Please explain why this change is necessary.
> 

_bfd_elf_section_from_bfd_section is called on input sections. When
there are more than 64K input sections, linear search over a linked
list can be very very slow. Since this_idx isn't used for input section
and for input section, its bfd section is created from its ELF
section index, we can use this_idx to store the ELF section index. The
result is the linking time went from

966.01s user 0.81s system 99% cpu 16:06.87 total

to

45.61s user 0.81s system 99% cpu 46.448 total

It is 20X speed up. I tested it with Linux kernel, binutils, gcc and
glibc on ia32, ia64 and x86_64. There are no regressions.

BTW, it only solves the 64K input section problem. The 64K output
sections is still very slow. bfd_section has a pointer to its BFD
owner. Can we add a pointer to bfd_section, used_by_ld, which will
be used by ld for lang_output_section_statement_type?


H.J.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-19 19:02     ` H. J. Lu
@ 2005-03-20 13:22       ` Alan Modra
  2005-03-20 13:38         ` H. J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2005-03-20 13:22 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Sat, Mar 19, 2005 at 09:57:01AM -0800, H. J. Lu wrote:
> On Sat, Mar 19, 2005 at 08:14:00PM +1030, Alan Modra wrote:
> > On Thu, Mar 17, 2005 at 12:58:27PM -0800, H. J. Lu wrote:
> > > @@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
> > >    const struct elf_backend_data *bed;
> > >    int index;
> > >  
> > > -  if (elf_section_data (asect) != NULL
> > > -      && elf_section_data (asect)->this_idx != 0)
> > > -    return elf_section_data (asect)->this_idx;
> > > +  if (elf_section_data (asect) != NULL)
> > > +    {
> > > +      index = elf_section_data (asect)->this_idx;
> > > +      if (index != 0)
> > > +	{
> > > +	  Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
> > > +	  if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
> > > +	    return index;
> > > +	}
> > > +    }
> > 
> > Please explain why this change is necessary.
> > 
> 
> _bfd_elf_section_from_bfd_section is called on input sections. When
> there are more than 64K input sections, linear search over a linked
> list can be very very slow. Since this_idx isn't used for input section
> and for input section, its bfd section is created from its ELF
> section index, we can use this_idx to store the ELF section index. The
> result is the linking time went from

No, I meant why that particular hunk.  You first posted a patch without
it, then just said it was needed, but not why.

> 966.01s user 0.81s system 99% cpu 16:06.87 total
> 
> to
> 
> 45.61s user 0.81s system 99% cpu 46.448 total
> 
> It is 20X speed up. I tested it with Linux kernel, binutils, gcc and
> glibc on ia32, ia64 and x86_64. There are no regressions.
> 
> BTW, it only solves the 64K input section problem. The 64K output
> sections is still very slow. bfd_section has a pointer to its BFD
> owner. Can we add a pointer to bfd_section, used_by_ld, which will
> be used by ld for lang_output_section_statement_type?

I think it might be worth investigating a larger change, not creating
lang_output_section_statemtents for orphans.  I'll look at this some
time when I have a free moment or two.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-20 13:22       ` Alan Modra
@ 2005-03-20 13:38         ` H. J. Lu
  2005-03-21  0:27           ` H. J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: H. J. Lu @ 2005-03-20 13:38 UTC (permalink / raw)
  To: binutils

On Sun, Mar 20, 2005 at 04:19:46PM +1030, Alan Modra wrote:
> On Sat, Mar 19, 2005 at 09:57:01AM -0800, H. J. Lu wrote:
> > On Sat, Mar 19, 2005 at 08:14:00PM +1030, Alan Modra wrote:
> > > On Thu, Mar 17, 2005 at 12:58:27PM -0800, H. J. Lu wrote:
> > > > @@ -4823,9 +4830,16 @@ _bfd_elf_section_from_bfd_section (bfd *
> > > >    const struct elf_backend_data *bed;
> > > >    int index;
> > > >  
> > > > -  if (elf_section_data (asect) != NULL
> > > > -      && elf_section_data (asect)->this_idx != 0)
> > > > -    return elf_section_data (asect)->this_idx;
> > > > +  if (elf_section_data (asect) != NULL)
> > > > +    {
> > > > +      index = elf_section_data (asect)->this_idx;
> > > > +      if (index != 0)
> > > > +	{
> > > > +	  Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
> > > > +	  if (!i_shdrp || i_shdrp [index]->bfd_section == asect)
> > > > +	    return index;
> > > > +	}
> > > > +    }
> > > 
> > > Please explain why this change is necessary.
> > > 
> > 
> > _bfd_elf_section_from_bfd_section is called on input sections. When
> > there are more than 64K input sections, linear search over a linked
> > list can be very very slow. Since this_idx isn't used for input section
> > and for input section, its bfd section is created from its ELF
> > section index, we can use this_idx to store the ELF section index. The
> > result is the linking time went from
> 
> No, I meant why that particular hunk.  You first posted a patch without
> it, then just said it was needed, but not why.
> 

I don't think it is really needed. I put it there for sanity check. I
think we can remove it.

> > 966.01s user 0.81s system 99% cpu 16:06.87 total
> > 
> > to
> > 
> > 45.61s user 0.81s system 99% cpu 46.448 total
> > 
> > It is 20X speed up. I tested it with Linux kernel, binutils, gcc and
> > glibc on ia32, ia64 and x86_64. There are no regressions.
> > 
> > BTW, it only solves the 64K input section problem. The 64K output
> > sections is still very slow. bfd_section has a pointer to its BFD
> > owner. Can we add a pointer to bfd_section, used_by_ld, which will
> > be used by ld for lang_output_section_statement_type?
> 
> I think it might be worth investigating a larger change, not creating
> lang_output_section_statemtents for orphans.  I'll look at this some
> time when I have a free moment or two.

Great.


H.J.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-20 13:38         ` H. J. Lu
@ 2005-03-21  0:27           ` H. J. Lu
  2005-03-21  2:07             ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: H. J. Lu @ 2005-03-21  0:27 UTC (permalink / raw)
  To: binutils

On Sat, Mar 19, 2005 at 10:08:31PM -0800, H. J. Lu wrote:
> > 
> > No, I meant why that particular hunk.  You first posted a patch without
> > it, then just said it was needed, but not why.
> > 
> 
> I don't think it is really needed. I put it there for sanity check. I
> think we can remove it.
> 

There is the patch without the sanity check. I believe it is OK, at
least on ia32, ia64 and x86_64.


H.J.
-----
2005-03-20  H.J. Lu  <hongjiu.lu@intel.com>

	* elf-bfd.h (elf_backend_data): Add int to
	elf_backend_section_from_shdr.
	(bfd_elf_section_data): Update this_idx to indicate it will be
	used for input file.
	(_bfd_elf_make_section_from_shdr): Add int.
	* elfxx-mips.h (_bfd_mips_elf_section_from_shdr): Likewise.

	* elf.c (_bfd_elf_make_section_from_shdr): Take section index
	and use it to set this_idx in bfd_elf_section_data.
	(bfd_section_from_shdr): Pass shindex to
	_bfd_elf_make_section_from_shdr.
	(_bfd_elf_section_from_bfd_section): Use this_idx in
	bfd_elf_section_data to find section index.

	* elf32-arm.c (elf32_arm_section_from_shdr): Take section
	index and pass it to _bfd_elf_make_section_from_shdr.
	* elf32-i370.c(i370_elf_section_from_shdr): Likewise.
	* elf32-ppc.c (ppc_elf_section_from_shdr): Likewise.
	* elf32-sh64.c (sh64_backend_section_from_shdr): Likewise.
	* elf32-v850.c (v850_elf_section_from_shdr): Likewise.
	* elf64-alpha.c (elf64_alpha_section_from_shdr): Likewise.
	* elf64-hppa.c (elf64_hppa_section_from_shdr): Likewise.
	* elf64-x86-64.c (elf64_x86_64_section_from_shdr): Likewise.
	* elfxx-ia64.c (elfNN_ia64_section_from_shdr): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Likewise.

--- bfd/elf-bfd.h.fast	2005-03-18 09:10:13.000000000 -0800
+++ bfd/elf-bfd.h	2005-03-20 11:05:54.755958746 -0800
@@ -629,7 +629,7 @@ struct elf_backend_data
   /* A function to handle unusual section types when creating BFD
      sections from ELF sections.  */
   bfd_boolean (*elf_backend_section_from_shdr)
-    (bfd *, Elf_Internal_Shdr *, const char *);
+    (bfd *, Elf_Internal_Shdr *, const char *, int);
 
   /* A function to convert machine dependent section header flags to
      BFD internal section header flags.  */
@@ -1060,7 +1060,8 @@ struct bfd_elf_section_data
   unsigned int rel_count2;
 
   /* The ELF section number of this section.  Only used for an output
-     file.  */
+     file.  Also used for an input file as the index into the ELF
+     section array, elf_elfsections.  */
   int this_idx;
 
   /* The ELF section number of the reloc section indicated by
@@ -1416,7 +1417,7 @@ extern bfd_boolean bfd_elf_mkcorefile
 extern Elf_Internal_Shdr *bfd_elf_find_section
   (bfd *, char *);
 extern bfd_boolean _bfd_elf_make_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 extern bfd_boolean _bfd_elf_make_section_from_phdr
   (bfd *, Elf_Internal_Phdr *, int, const char *);
 extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
--- bfd/elf.c.fast	2005-03-14 08:07:20.000000000 -0800
+++ bfd/elf.c	2005-03-20 11:08:28.318266681 -0800
@@ -673,7 +673,8 @@ bfd_elf_is_group_section (bfd *abfd ATTR
 bfd_boolean
 _bfd_elf_make_section_from_shdr (bfd *abfd,
 				 Elf_Internal_Shdr *hdr,
-				 const char *name)
+				 const char *name,
+				 int shindex)
 {
   asection *newsect;
   flagword flags;
@@ -692,6 +693,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 
   hdr->bfd_section = newsect;
   elf_section_data (newsect)->this_hdr = *hdr;
+  elf_section_data (newsect)->this_idx = shindex;
 
   /* Always use the real type/flags.  */
   elf_section_type (newsect) = hdr->sh_type;
@@ -1728,10 +1730,10 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_FINI_ARRAY:	/* .fini_array section.  */
     case SHT_PREINIT_ARRAY:	/* .preinit_array section.  */
     case SHT_GNU_LIBLIST:	/* .gnu.liblist section.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_DYNAMIC:	/* Dynamic linking information.  */
-      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
 	{
@@ -1782,7 +1784,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
          linker.  */
       if ((hdr->sh_flags & SHF_ALLOC) != 0
 	  && (abfd->flags & DYNAMIC) != 0
-	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+	  && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						shindex))
 	return FALSE;
 
       /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
@@ -1826,7 +1829,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
       /* Besides being a symbol table, we also treat this as a regular
 	 section, so that objcopy can handle it.  */
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_SYMTAB_SHNDX:	/* Symbol section indices when >64k sections */
       if (elf_symtab_shndx (abfd) == shindex)
@@ -1862,7 +1865,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	  elf_elfsections (abfd)[shindex] = hdr;
 	  /* We also treat this as a regular section, so that objcopy
 	     can handle it.  */
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 	}
 
       /* If the string table isn't one of the above, then treat it as a
@@ -1887,7 +1891,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 		}
 	    }
 	}
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
 
     case SHT_REL:
     case SHT_RELA:
@@ -1904,7 +1908,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	    ((*_bfd_error_handler)
 	     (_("%B: invalid link %lu for reloc section %s (index %u)"),
 	      abfd, hdr->sh_link, name, shindex));
-	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	    return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						    shindex);
 	  }
 
 	/* For some incomprehensible reason Oracle distributes
@@ -1951,7 +1956,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 	   can't use it as a reloc section if it points to the null
 	   section.  */
 	if (hdr->sh_link != elf_onesymtab (abfd) || hdr->sh_info == SHN_UNDEF)
-	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+	  return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
+						  shindex);
 
 	if (! bfd_section_from_shdr (abfd, hdr->sh_info))
 	  return FALSE;
@@ -1988,19 +1994,19 @@ bfd_section_from_shdr (bfd *abfd, unsign
     case SHT_GNU_verdef:
       elf_dynverdef (abfd) = shindex;
       elf_tdata (abfd)->dynverdef_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_versym:
       elf_dynversym (abfd) = shindex;
       elf_tdata (abfd)->dynversym_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_GNU_verneed:
       elf_dynverref (abfd) = shindex;
       elf_tdata (abfd)->dynverref_hdr = *hdr;
-      return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
       break;
 
     case SHT_SHLIB:
@@ -2013,7 +2019,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
       name = group_signature (abfd, hdr);
       if (name == NULL)
 	return FALSE;
-      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name))
+      if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
       if (hdr->contents != NULL)
 	{
@@ -2039,7 +2045,8 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      return bed->elf_backend_section_from_shdr (abfd, hdr, name);
+      return bed->elf_backend_section_from_shdr (abfd, hdr, name,
+						 shindex);
     }
 
   return TRUE;
@@ -4781,19 +4788,7 @@ _bfd_elf_section_from_bfd_section (bfd *
   else if (bfd_is_und_section (asect))
     index = SHN_UNDEF;
   else
-    {
-      Elf_Internal_Shdr **i_shdrp = elf_elfsections (abfd);
-      int maxindex = elf_numsections (abfd);
-
-      for (index = 1; index < maxindex; index++)
-	{
-	  Elf_Internal_Shdr *hdr = i_shdrp[index];
-
-	  if (hdr != NULL && hdr->bfd_section == asect)
-	    return index;
-	}
-      index = -1;
-    }
+    index = -1;
 
   bed = get_elf_backend_data (abfd);
   if (bed->elf_backend_section_from_bfd_section)
--- bfd/elf32-arm.c.fast	2005-03-19 10:05:53.000000000 -0800
+++ bfd/elf32-arm.c	2005-03-20 11:05:55.060901771 -0800
@@ -5486,13 +5486,15 @@ elf32_arm_fake_sections (bfd * abfd, Elf
   return TRUE;
 }
 
-/* Handle an ARM specific section when reading an object file.
-   This is called when elf.c finds a section with an unknown type.  */
+/* Handle an ARM specific section when reading an object file.  This is
+   called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
 elf32_arm_section_from_shdr (bfd *abfd,
 			     Elf_Internal_Shdr * hdr,
-			     const char *name)
+			     const char *name,
+			     int shindex)
 {
   /* There ought to be a place to keep ELF backend specific flags, but
      at the moment there isn't one.  We just keep track of the
@@ -5508,7 +5510,7 @@ elf32_arm_section_from_shdr (bfd *abfd,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   return TRUE;
--- bfd/elf32-i370.c.fast	2004-10-21 09:12:36.000000000 -0700
+++ bfd/elf32-i370.c	2005-03-20 11:05:55.112892057 -0800
@@ -286,8 +286,6 @@ static void i370_elf_post_process_header
   PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_boolean i370_elf_create_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean i370_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean i370_elf_fake_sections
   PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static bfd_boolean i370_elf_check_relocs
@@ -385,15 +383,15 @@ i370_elf_merge_private_bfd_data (ibfd, o
  */
 
 static bfd_boolean
-i370_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+i370_elf_section_from_shdr (bfd *abfd,
+			    Elf_Internal_Shdr *hdr,
+			    const char *name,
+			    int shindex)
 {
   asection *newsect;
   flagword flags;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   newsect = hdr->bfd_section;
--- bfd/elf32-ppc.c.fast	2005-03-16 21:18:52.000000000 -0800
+++ bfd/elf32-ppc.c	2005-03-20 11:05:55.232869641 -0800
@@ -1760,15 +1760,19 @@ ppc_elf_plt_sym_val (bfd_vma i ATTRIBUTE
 }
 
 /* Handle a PowerPC specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.  */
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
-ppc_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr, const char *name)
+ppc_elf_section_from_shdr (bfd *abfd,
+			   Elf_Internal_Shdr *hdr,
+			   const char *name,
+			   int shindex)
 {
   asection *newsect;
   flagword flags;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   newsect = hdr->bfd_section;
--- bfd/elf32-sh64.c.fast	2005-03-14 08:07:22.000000000 -0800
+++ bfd/elf32-sh64.c	2005-03-20 11:05:55.254865531 -0800
@@ -63,7 +63,7 @@ static bfd_boolean sh64_elf_link_output_
   (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
    struct elf_link_hash_entry *);
 static bfd_boolean sh64_backend_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 static void sh64_elf_final_write_processing
   (bfd *, bfd_boolean);
 static bfd_boolean sh64_bfd_elf_copy_private_section_data
@@ -253,13 +253,14 @@ sh64_elf_merge_private_data (bfd *ibfd, 
 }
 
 /* Handle a SH64-specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.
 
    We only recognize SHT_SH5_CR_SORTED, on the .cranges section.  */
 
 bfd_boolean
 sh64_backend_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
-				const char *name)
+				const char *name, int shindex)
 {
   flagword flags = 0;
 
@@ -284,7 +285,7 @@ sh64_backend_section_from_shdr (bfd *abf
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   if (flags
--- bfd/elf32-v850.c.fast	2005-03-14 08:07:22.000000000 -0800
+++ bfd/elf32-v850.c	2005-03-20 11:05:55.314854323 -0800
@@ -78,8 +78,6 @@ static bfd_boolean v850_elf_add_symbol_h
 static bfd_boolean v850_elf_link_output_symbol_hook
   PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
 	   asection *, struct elf_link_hash_entry *));
-static bfd_boolean v850_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean v850_elf_gc_sweep_hook
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
@@ -2210,16 +2208,16 @@ v850_elf_link_output_symbol_hook (info, 
 }
 
 static bfd_boolean
-v850_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+v850_elf_section_from_shdr (bfd *abfd,
+			    Elf_Internal_Shdr *hdr,
+			    const char *name,
+			    int shindex)
 {
   /* There ought to be a place to keep ELF backend specific flags, but
      at the moment there isn't one.  We just keep track of the
      sections by their name, instead.  */
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   switch (hdr->sh_type)
--- bfd/elf64-alpha.c.fast	2005-01-31 19:28:43.000000000 -0800
+++ bfd/elf64-alpha.c	2005-03-20 11:05:55.345848532 -0800
@@ -72,8 +72,6 @@ static bfd_boolean elf64_alpha_mkobject
   PARAMS ((bfd *));
 static bfd_boolean elf64_alpha_object_p
   PARAMS ((bfd *));
-static bfd_boolean elf64_alpha_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elf64_alpha_section_flags
   PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elf64_alpha_fake_sections
@@ -2260,15 +2258,16 @@ elf64_alpha_relax_section (abfd, sec, li
 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
 \f
 /* Handle an Alpha specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.
    FIXME: We need to handle the SHF_ALPHA_GPREL flag, but I'm not sure
    how to.  */
 
 static bfd_boolean
-elf64_alpha_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elf64_alpha_section_from_shdr (bfd *abfd,
+			       Elf_Internal_Shdr *hdr,
+			       const char *name,
+			       int shindex)
 {
   asection *newsect;
 
@@ -2287,7 +2286,7 @@ elf64_alpha_section_from_shdr (abfd, hdr
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elf64-hppa.c.fast	2005-02-01 22:31:33.000000000 -0800
+++ bfd/elf64-hppa.c	2005-03-20 11:05:55.402837884 -0800
@@ -184,9 +184,6 @@ static const char *get_dyn_name
 static bfd_boolean elf64_hppa_object_p
   PARAMS ((bfd *));
 
-static bfd_boolean elf64_hppa_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
-
 static void elf64_hppa_post_process_headers
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -413,10 +410,10 @@ elf64_hppa_object_p (abfd)
 /* Given section type (hdr->sh_type), return a boolean indicating
    whether or not the section is an elf64-hppa specific section.  */
 static bfd_boolean
-elf64_hppa_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elf64_hppa_section_from_shdr (bfd *abfd,
+			      Elf_Internal_Shdr *hdr,
+			      const char *name,
+			      int shindex)
 {
   asection *newsect;
 
@@ -436,7 +433,7 @@ elf64_hppa_section_from_shdr (abfd, hdr,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elf64-x86-64.c.fast	2005-02-11 11:15:56.000000000 -0800
+++ bfd/elf64-x86-64.c	2005-03-20 11:05:55.489821632 -0800
@@ -2822,12 +2822,15 @@ elf64_x86_64_plt_sym_val (bfd_vma i, con
    is called when elfcode.h finds a section with an unknown type.  */
 
 static bfd_boolean
-elf64_x86_64_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr, const char *name)
+elf64_x86_64_section_from_shdr (bfd *abfd,
+				Elf_Internal_Shdr *hdr,
+				const char *name,
+				int shindex)
 {
   if (hdr->sh_type != SHT_X86_64_UNWIND)
     return FALSE;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   return TRUE;
--- bfd/elfxx-ia64.c.fast	2005-03-20 10:18:04.000000000 -0800
+++ bfd/elfxx-ia64.c	2005-03-20 11:05:55.493820885 -0800
@@ -183,8 +183,6 @@ static void elfNN_ia64_relax_ldxmov
   PARAMS((bfd_byte *contents, bfd_vma off));
 static bfd_boolean is_unwind_section_name
   PARAMS ((bfd *abfd, const char *));
-static bfd_boolean elfNN_ia64_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean elfNN_ia64_section_flags
   PARAMS ((flagword *, const Elf_Internal_Shdr *));
 static bfd_boolean elfNN_ia64_fake_sections
@@ -1261,13 +1259,14 @@ is_unwind_section_name (abfd, name)
 }
 
 /* Handle an IA-64 specific section when reading an object file.  This
-   is called when elfcode.h finds a section with an unknown type.  */
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
 
 static bfd_boolean
-elfNN_ia64_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elfNN_ia64_section_from_shdr (bfd *abfd,
+			      Elf_Internal_Shdr *hdr,
+			      const char *name,
+			      int shindex)
 {
   asection *newsect;
 
@@ -1291,7 +1290,7 @@ elfNN_ia64_section_from_shdr (abfd, hdr,
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
--- bfd/elfxx-mips.c.fast	2005-03-14 08:07:25.000000000 -0800
+++ bfd/elfxx-mips.c	2005-03-20 11:05:55.870750460 -0800
@@ -5068,8 +5068,10 @@ _bfd_mips_elf_section_processing (bfd *a
    how to.  */
 
 bfd_boolean
-_bfd_mips_elf_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr,
-				 const char *name)
+_bfd_mips_elf_section_from_shdr (bfd *abfd,
+				 Elf_Internal_Shdr *hdr,
+				 const char *name,
+				 int shindex)
 {
   flagword flags = 0;
 
@@ -5141,7 +5143,7 @@ _bfd_mips_elf_section_from_shdr (bfd *ab
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   if (flags)
--- bfd/elfxx-mips.h.fast	2005-03-14 08:07:25.000000000 -0800
+++ bfd/elfxx-mips.h	2005-03-20 11:05:55.914742241 -0800
@@ -31,7 +31,7 @@ extern bfd_boolean _bfd_mips_elf_name_lo
 extern bfd_boolean _bfd_mips_elf_section_processing
   (bfd *, Elf_Internal_Shdr *);
 extern bfd_boolean _bfd_mips_elf_section_from_shdr
-  (bfd *, Elf_Internal_Shdr *, const char *);
+  (bfd *, Elf_Internal_Shdr *, const char *, int);
 extern bfd_boolean _bfd_mips_elf_fake_sections
   (bfd *, Elf_Internal_Shdr *, asection *);
 extern bfd_boolean _bfd_mips_elf_section_from_bfd_section

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: Store ELF section index for input file
  2005-03-21  0:27           ` H. J. Lu
@ 2005-03-21  2:07             ` Alan Modra
  0 siblings, 0 replies; 8+ messages in thread
From: Alan Modra @ 2005-03-21  2:07 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Sun, Mar 20, 2005 at 11:18:57AM -0800, H. J. Lu wrote:
> 2005-03-20  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	* elf-bfd.h (elf_backend_data): Add int to
> 	elf_backend_section_from_shdr.
> 	(bfd_elf_section_data): Update this_idx to indicate it will be
> 	used for input file.
> 	(_bfd_elf_make_section_from_shdr): Add int.
> 	* elfxx-mips.h (_bfd_mips_elf_section_from_shdr): Likewise.
> 
> 	* elf.c (_bfd_elf_make_section_from_shdr): Take section index
> 	and use it to set this_idx in bfd_elf_section_data.
> 	(bfd_section_from_shdr): Pass shindex to
> 	_bfd_elf_make_section_from_shdr.
> 	(_bfd_elf_section_from_bfd_section): Use this_idx in
> 	bfd_elf_section_data to find section index.
> 
> 	* elf32-arm.c (elf32_arm_section_from_shdr): Take section
> 	index and pass it to _bfd_elf_make_section_from_shdr.
> 	* elf32-i370.c(i370_elf_section_from_shdr): Likewise.
> 	* elf32-ppc.c (ppc_elf_section_from_shdr): Likewise.
> 	* elf32-sh64.c (sh64_backend_section_from_shdr): Likewise.
> 	* elf32-v850.c (v850_elf_section_from_shdr): Likewise.
> 	* elf64-alpha.c (elf64_alpha_section_from_shdr): Likewise.
> 	* elf64-hppa.c (elf64_hppa_section_from_shdr): Likewise.
> 	* elf64-x86-64.c (elf64_x86_64_section_from_shdr): Likewise.
> 	* elfxx-ia64.c (elfNN_ia64_section_from_shdr): Likewise.
> 	* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Likewise.

OK for mainline.

> @@ -1060,7 +1060,8 @@ struct bfd_elf_section_data
>    unsigned int rel_count2;
>  
>    /* The ELF section number of this section.  Only used for an output
> -     file.  */
> +     file.  Also used for an input file as the index into the ELF
> +     section array, elf_elfsections.  */

Change this to simply "/* The ELF section number of this section.  */"

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-20 22:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-17 22:03 RFC: Store ELF section index for input file H. J. Lu
2005-03-17 23:06 ` PATCH: " H. J. Lu
2005-03-19 18:57   ` Alan Modra
2005-03-19 19:02     ` H. J. Lu
2005-03-20 13:22       ` Alan Modra
2005-03-20 13:38         ` H. J. Lu
2005-03-21  0:27           ` H. J. Lu
2005-03-21  2:07             ` Alan Modra

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).