This is the mail archive of the binutils@sources.redhat.com 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]

Fix strip/objcopy on new ppc32 plt/got binaries


This fixes objcopy for ppc32 when using the new non-exec .plt and .got
sections.  The problem being that the ELF section type for these
sections, set by special_sections, now is one of two possibilities
depending on the input file.  To allow this, the elf_backend_data
interface needs to be a little more flexible.  I chose to replace the
current special_sections array with a function, in the process removing
the two-level section name lookup optimisation for backend sections.
Most backends didn't benefit from the optimisation.

	PR 1004
	* elf-bfd.h (struct elf_backend_data): Add get_sec_type_attr.  Delete
	special_sections.
	(_bfd_elf_get_special_section): Declare.
	(bfd_elf_special_section): Update prototype.
	* elf.c (special_sections): Remove unused outer entries.
	(get_special_section): Delete.
	(_bfd_elf_get_special_section): New function.
	(_bfd_elf_get_sec_type_attr): Replace "name" arg with "sec".  Update
	special_sections indexing.
	(_bfd_elf_new_section_hook): Call backend get_sec_type_attr.
	* elf32-arm.c (symbian_special_sections_d): Delete.
	(symbian_special_sections_g, symbian_special_sections_h): Delete.
	(symbian_special_sections_i, symbian_special_sections_f): Delete.
	(symbian_special_sections_p): Delete.
	(elf32_arm_symbian_special_sections): Merge above to here.
	(elf32_arm_symbian_get_sec_type_attr): New function.
	(elf_backend_special_sections): Don't define.
	(elf_backend_get_sec_type_attr): Define.
	* elf32-m32r.c: Similarly to elf32-arm.c.
	* elf32-m68hc11.c: Likewise.
	* elf32-m68hc12.c: Likewise.
	* elf32-mcore.c: Likewise.
	* elf32-sh64.c: Likewise.
	* elf32-v850.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-sh64.c: Likewise.
	* elfxx-ia64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elf32-ppc.c: Likewise.
	(bfd_elf_special_section ppc_alt_plt): New.  Use it if .plt loadable.
	* elfxx-mips.h (_bfd_mips_elf_get_sec_type_attr): Declare.
	(_bfd_mips_elf_special_sections, elf_backend_special_sections): Delete.
	(elf_backend_get_sec_type_attr): Define.
	* elfxx-target.h (elf_backend_get_sec_type_attr): Define.
	(elf_backend_special_sections): Don't define.
	(elfNN_bed): Update.

binutils/
	* objcopy.c (copy_object): Use bfd_make_section_with_flags.
	(write_debugging_info): Likewise.
	(setup_section): Use bfd_make_section_anyway_with_flags.
gas/
	* config/obj-elf.c (obj_elf_change_section): Use backend
	get_sec_type_attr.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.189
diff -u -p -r1.189 elf-bfd.h
--- bfd/elf-bfd.h	6 Jun 2005 14:28:30 -0000	1.189
+++ bfd/elf-bfd.h	1 Jul 2005 02:54:16 -0000
@@ -633,11 +633,16 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_section_from_shdr)
     (bfd *, Elf_Internal_Shdr *, const char *, int);
 
-  /* A function to convert machine dependent section header flags to
+  /* A function to convert machine dependent ELF section header flags to
      BFD internal section header flags.  */
   bfd_boolean (*elf_backend_section_flags)
     (flagword *, const Elf_Internal_Shdr *);
 
+  /* A function that returns a struct containing ELF section flags and
+     type for the given BFD section.   */
+  const struct bfd_elf_special_section * (*get_sec_type_attr)
+    (bfd *, asection *);
+
   /* A function to handle unusual program segment types when creating BFD
      sections from ELF program segments.  */
   bfd_boolean (*elf_backend_section_from_phdr)
@@ -976,10 +981,6 @@ struct elf_backend_data
 
   const struct elf_size_info *s;
 
-  /* An array of 27 target specific special section map arrays,
-     covering 'a' to 'z', plus other.  */
-  const struct bfd_elf_special_section **special_sections;
-
   /* The size in bytes of the header for the GOT.  This includes the
      so-called reserved entries on some systems.  */
   bfd_vma got_header_size;
@@ -1501,8 +1502,10 @@ extern bfd_boolean _bfd_elf_new_section_
   (bfd *, asection *);
 extern bfd_boolean _bfd_elf_init_reloc_shdr
   (bfd *, Elf_Internal_Shdr *, asection *, bfd_boolean);
+extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
+  (const char *, const struct bfd_elf_special_section *, unsigned int);
 extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
-  (bfd *, const char *);
+  (bfd *, asection *);
 
 /* If the target doesn't have reloc handling written yet:  */
 extern void _bfd_elf_no_info_to_howto
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.303
diff -u -p -r1.303 elf.c
--- bfd/elf.c	17 Jun 2005 15:48:25 -0000	1.303
+++ bfd/elf.c	1 Jul 2005 02:54:23 -0000
@@ -2270,9 +2270,8 @@ static struct bfd_elf_special_section co
   { NULL,              0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *special_sections [27] =
+static struct bfd_elf_special_section const *special_sections[] =
 {
-  NULL,				/* 'a' */
   special_sections_b,		/* 'b' */
   special_sections_c,		/* 'b' */
   special_sections_d,		/* 'd' */
@@ -2292,51 +2291,29 @@ static struct bfd_elf_special_section co
   special_sections_r,		/* 'r' */
   special_sections_s,		/* 's' */
   special_sections_t,		/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
 };
 
-static const struct bfd_elf_special_section *
-get_special_section (const char *name,
-		     const struct bfd_elf_special_section **special_sections_p,
-		     unsigned int rela)
+const struct bfd_elf_special_section *
+_bfd_elf_get_special_section (const char *name,
+			      const struct bfd_elf_special_section *spec,
+			      unsigned int rela)
 {
   int i;
   int len;
-  const struct bfd_elf_special_section *special_sections;
-
-  if (name [0] == '.')
-    {
-      i = name [1] - 'a';
-      if (i < 0 || i > 25)
-	i = 26;
-    }
-  else
-    i = 26;
-
-  special_sections = special_sections_p [i];
 
-  if (!special_sections)
-    return special_sections;
+  len = strlen (name);
 
-  len= strlen (name);
-
-  for (i = 0; special_sections[i].prefix != NULL; i++)
+  for (i = 0; spec[i].prefix != NULL; i++)
     {
       int suffix_len;
-      int prefix_len = special_sections[i].prefix_length;
+      int prefix_len = spec[i].prefix_length;
 
       if (len < prefix_len)
 	continue;
-      if (memcmp (name, special_sections[i].prefix, prefix_len) != 0)
+      if (memcmp (name, spec[i].prefix, prefix_len) != 0)
 	continue;
 
-      suffix_len = special_sections[i].suffix_length;
+      suffix_len = spec[i].suffix_length;
       if (suffix_len <= 0)
 	{
 	  if (name[prefix_len] != 0)
@@ -2345,7 +2322,7 @@ get_special_section (const char *name,
 		continue;
 	      if (name[prefix_len] != '.'
 		  && (suffix_len == -2
-		      || (rela && special_sections[i].type == SHT_REL)))
+		      || (rela && spec[i].type == SHT_REL)))
 		continue;
 	    }
 	}
@@ -2354,41 +2331,46 @@ get_special_section (const char *name,
 	  if (len < prefix_len + suffix_len)
 	    continue;
 	  if (memcmp (name + len - suffix_len,
-		      special_sections[i].prefix + prefix_len,
+		      spec[i].prefix + prefix_len,
 		      suffix_len) != 0)
 	    continue;
 	}
-      return &special_sections[i];
+      return &spec[i];
     }
 
   return NULL;
 }
 
 const struct bfd_elf_special_section *
-_bfd_elf_get_sec_type_attr (bfd *abfd, const char *name)
+_bfd_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 {
-  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-  const struct bfd_elf_special_section *ssect = NULL;
+  int i;
+  const struct bfd_elf_special_section *spec;
 
   /* See if this is one of the special sections.  */
-  if (name)
-    {
-      unsigned int rela = bed->default_use_rela_p;
+  if (sec->name == NULL)
+    return NULL;
 
-      if (bed->special_sections)
-	ssect = get_special_section (name, bed->special_sections, rela);
+  if (sec->name[0] != '.')
+    return NULL;
 
-      if (! ssect)
-	ssect = get_special_section (name, special_sections, rela);
-    }
+  i = sec->name[1] - 'b';
+  if (i < 0 || i > 't' - 'b')
+    return NULL;
+
+  spec = special_sections[i];
 
-  return ssect;
+  if (spec == NULL)
+    return NULL;
+
+  return _bfd_elf_get_special_section (sec->name, spec, sec->use_rela_p);
 }
 
 bfd_boolean
 _bfd_elf_new_section_hook (bfd *abfd, asection *sec)
 {
   struct bfd_elf_section_data *sdata;
+  const struct elf_backend_data *bed;
   const struct bfd_elf_special_section *ssect;
 
   sdata = (struct bfd_elf_section_data *) sec->used_by_bfd;
@@ -2400,13 +2382,17 @@ _bfd_elf_new_section_hook (bfd *abfd, as
       sec->used_by_bfd = sdata;
     }
 
+  /* Indicate whether or not this section should use RELA relocations.  */
+  bed = get_elf_backend_data (abfd);
+  sec->use_rela_p = bed->default_use_rela_p;
+
   /* When we read a file, we don't need section type and flags unless
      it is a linker created section.  They will be overridden in
      _bfd_elf_make_section_from_shdr anyway.  */
   if (abfd->direction != read_direction
       || (sec->flags & SEC_LINKER_CREATED) != 0)
     {
-      ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name);
+      ssect = (*bed->get_sec_type_attr) (abfd, sec);
       if (ssect != NULL)
 	{
 	  elf_section_type (sec) = ssect->type;
@@ -2414,9 +2400,6 @@ _bfd_elf_new_section_hook (bfd *abfd, as
 	}
     }
 
-  /* Indicate whether or not this section should use RELA relocations.  */
-  sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p;
-
   return TRUE;
 }
 
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.44
diff -u -p -r1.44 elf32-arm.c
--- bfd/elf32-arm.c	20 Jun 2005 18:12:06 -0000	1.44
+++ bfd/elf32-arm.c	1 Jul 2005 02:54:26 -0000
@@ -6943,7 +6931,7 @@ elf32_arm_symbian_link_hash_table_create
 }     
 
 static struct bfd_elf_special_section const
-  symbian_special_sections_d[]=
+elf32_arm_symbian_special_sections[] =
 {
   /* In a BPABI executable, the dynamic linking sections do not go in
      the loadable read-only segment.  The post-linker may wish to
@@ -6952,92 +6940,34 @@ static struct bfd_elf_special_section co
   { ".dynamic",        8,  0, SHT_DYNAMIC,  0 },
   { ".dynstr",         7,  0, SHT_STRTAB,   0 },
   { ".dynsym",         7,  0, SHT_DYNSYM,   0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_g[]=
-{
-  /* In a BPABI executable, the dynamic linking sections do not go in
-     the loadable read-only segment.  The post-linker may wish to
-     refer to these sections, but they are not part of the final
-     program image.  */
   { ".got",            4,  0, SHT_PROGBITS, 0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_h[]=
-{
-  /* In a BPABI executable, the dynamic linking sections do not go in
-     the loadable read-only segment.  The post-linker may wish to
-     refer to these sections, but they are not part of the final
-     program image.  */
   { ".hash",           5,  0, SHT_HASH,     0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_i[]=
-{
   /* These sections do not need to be writable as the SymbianOS
      postlinker will arrange things so that no dynamic relocation is
      required.  */
   { ".init_array",    11,  0, SHT_INIT_ARRAY, SHF_ALLOC },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_f[]=
-{
-  /* These sections do not need to be writable as the SymbianOS
-     postlinker will arrange things so that no dynamic relocation is
-     required.  */
   { ".fini_array",    11,  0, SHT_FINI_ARRAY, SHF_ALLOC },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_p[]=
-{
-  /* These sections do not need to be writable as the SymbianOS
-     postlinker will arrange things so that no dynamic relocation is
-     required.  */
   { ".preinit_array", 14,  0, SHT_PREINIT_ARRAY, SHF_ALLOC },
   { NULL,              0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elf32_arm_symbian_special_sections[27]=
+static const struct bfd_elf_special_section *
+elf32_arm_symbian_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  symbian_special_sections_d,	/* 'd' */
-  NULL,				/* 'e' */
-  symbian_special_sections_f,	/* 'f' */
-  symbian_special_sections_g,	/* 'g' */
-  symbian_special_sections_h,	/* 'h' */
-  symbian_special_sections_i,	/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  symbian_special_sections_p,	/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf32_arm_symbian_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 static void
 elf32_arm_symbian_begin_write_processing (bfd *abfd, 
@@ -7091,8 +7021,8 @@ elf32_arm_symbian_modify_segment_map (bf
 #define bfd_elf32_bfd_link_hash_table_create \
   elf32_arm_symbian_link_hash_table_create
 
-#undef elf_backend_special_sections
-#define elf_backend_special_sections elf32_arm_symbian_special_sections
+#undef elf_backend_get_sec_type_attr
+#define elf_backend_get_sec_type_attr elf32_arm_symbian_get_sec_type_attr
 
 #undef elf_backend_begin_write_processing
 #define elf_backend_begin_write_processing \
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf32-m32r.c
--- bfd/elf32-m32r.c	20 Jun 2005 18:12:06 -0000	1.63
+++ bfd/elf32-m32r.c	1 Jul 2005 02:54:36 -0000
@@ -4188,45 +4192,30 @@ m32r_elf_check_relocs (abfd, info, sec, 
   return TRUE;
 }
 
-static struct bfd_elf_special_section const
-  m32r_elf_special_sections_s[] =
+static struct bfd_elf_special_section const m32r_elf_special_sections[] =
 {
-  { ".sdata",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".sbss",    5, -2, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
-  { NULL,              0,  0, 0,            0 }
+  { ".sdata",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  { NULL,       0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  m32r_elf_special_sections[27] =
+static const struct bfd_elf_special_section *
+m32r_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  m32r_elf_special_sections_s,	/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					m32r_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 static bfd_boolean
 m32r_elf_fake_sections (abfd, hdr, sec)
@@ -4337,7 +4326,7 @@ m32r_elf_reloc_type_class (rela)
 #define bfd_elf32_bfd_merge_private_bfd_data 	m32r_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags		m32r_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data	m32r_elf_print_private_bfd_data
-#define elf_backend_special_sections		m32r_elf_special_sections
+#define elf_backend_get_sec_type_attr		m32r_elf_get_sec_type_attr
 
 #include "elf32-target.h"
 
Index: bfd/elf32-m68hc11.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc11.c,v
retrieving revision 1.29
diff -u -p -r1.29 elf32-m68hc11.c
--- bfd/elf32-m68hc11.c	7 May 2005 13:22:48 -0000	1.29
+++ bfd/elf32-m68hc11.c	1 Jul 2005 02:54:36 -0000
@@ -1257,65 +1257,32 @@ m68hc11_elf_relax_delete_bytes (bfd *abf
      are located in .page0.
    - The .vectors is the section that represents the interrupt
      vectors.  */
-static struct bfd_elf_special_section const
-  m68hc11_special_sections_e[] =
+static struct bfd_elf_special_section const elf32_m68hc11_special_sections[] =
 {
   { ".eeprom",   7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  m68hc11_special_sections_s[]=
-{
+  { ".page0",    6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".softregs", 9, 0, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
+  { ".vectors",  8, 0, SHT_PROGBITS, SHF_ALLOC },
   { NULL,        0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const
-  m68hc11_special_sections_p[]=
+static const struct bfd_elf_special_section *
+elf32_m68hc11_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  { ".page0",    6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
+  const struct bfd_elf_special_section const *ssect;
 
-static struct bfd_elf_special_section const
-  m68hc11_special_sections_v[]=
-{
-  { ".vectors",  8, 0, SHT_PROGBITS, SHF_ALLOC },
-  { NULL,        0, 0, 0,            0 }
-};
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf32_m68hc11_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
 
-static struct bfd_elf_special_section const *
-  elf32_m68hc11_special_sections[27] =
-{
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  m68hc11_special_sections_e,	/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  m68hc11_special_sections_p,	/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  m68hc11_special_sections_s,	/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  m68hc11_special_sections_v,	/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #define ELF_ARCH		bfd_arch_m68hc11
 #define ELF_MACHINE_CODE	EM_68HC11
@@ -1335,7 +1302,7 @@ static struct bfd_elf_special_section co
 #define elf_backend_object_p	0
 #define elf_backend_final_write_processing	0
 #define elf_backend_can_gc_sections		1
-#define elf_backend_special_sections elf32_m68hc11_special_sections
+#define elf_backend_get_sec_type_attr elf32_m68hc11_get_sec_type_attr
 
 #define bfd_elf32_bfd_link_hash_table_create \
                                 m68hc11_elf_bfd_link_hash_table_create
Index: bfd/elf32-m68hc12.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc12.c,v
retrieving revision 1.21
diff -u -p -r1.21 elf32-m68hc12.c
--- bfd/elf32-m68hc12.c	7 May 2005 13:22:49 -0000	1.21
+++ bfd/elf32-m68hc12.c	1 Jul 2005 02:54:37 -0000
@@ -535,65 +535,32 @@ m68hc12_elf_set_mach_from_flags (bfd *ab
      Page0 accesses are faster on the M68HC12.
    - The .vectors is the section that represents the interrupt
      vectors.  */
-static struct bfd_elf_special_section const
-  m68hc12_special_sections_e[] =
+static struct bfd_elf_special_section const elf32_m68hc12_special_sections[] =
 {
   { ".eeprom",   7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  m68hc12_special_sections_s[]=
-{
+  { ".page0",    6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".softregs", 9, 0, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
+  { ".vectors",  8, 0, SHT_PROGBITS, SHF_ALLOC },
   { NULL,        0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const
-  m68hc12_special_sections_p[]=
+static const struct bfd_elf_special_section *
+elf32_m68hc12_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  { ".page0",    6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
+  const struct bfd_elf_special_section const *ssect;
 
-static struct bfd_elf_special_section const
-  m68hc12_special_sections_v[]=
-{
-  { ".vectors",  8, 0, SHT_PROGBITS, SHF_ALLOC },
-  { NULL,        0, 0, 0,            0 }
-};
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf32_m68hc12_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
 
-static struct bfd_elf_special_section const *
-  elf32_m68hc12_special_sections[27] =
-{
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  m68hc12_special_sections_e,	/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  m68hc12_special_sections_p,	/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  m68hc12_special_sections_s,	/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  m68hc12_special_sections_v,	/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #define ELF_ARCH		bfd_arch_m68hc12
 #define ELF_MACHINE_CODE	EM_68HC12
@@ -611,7 +578,7 @@ static struct bfd_elf_special_section co
 #define elf_backend_object_p		m68hc12_elf_set_mach_from_flags
 #define elf_backend_final_write_processing	0
 #define elf_backend_can_gc_sections		1
-#define elf_backend_special_sections elf32_m68hc12_special_sections
+#define elf_backend_get_sec_type_attr elf32_m68hc12_get_sec_type_attr
 #define elf_backend_post_process_headers     elf32_m68hc11_post_process_headers
 #define elf_backend_add_symbol_hook  elf32_m68hc11_add_symbol_hook
 
Index: bfd/elf32-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mcore.c,v
retrieving revision 1.40
diff -u -p -r1.40 elf32-mcore.c
--- bfd/elf32-mcore.c	20 Jun 2005 18:12:07 -0000	1.40
+++ bfd/elf32-mcore.c	1 Jul 2005 02:54:38 -0000
@@ -667,51 +667,30 @@ mcore_elf_check_relocs (abfd, info, sec,
   return TRUE;
 }
 
-static struct bfd_elf_special_section const
-  mcore_special_sections_c [] =
+static struct bfd_elf_special_section const mcore_elf_special_sections[]=
 {
   { ".ctors",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  mcore_special_sections_d[]=
-{
   { ".dtors",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { NULL,       0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  mcore_elf_special_sections[27]=
+static const struct bfd_elf_special_section *
+mcore_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  mcore_special_sections_c,	/* 'c' */
-  mcore_special_sections_d,	/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					mcore_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #define TARGET_BIG_SYM		bfd_elf32_mcore_big_vec
 #define TARGET_BIG_NAME		"elf32-mcore-big"
@@ -731,7 +710,7 @@ static struct bfd_elf_special_section co
 #define elf_backend_gc_mark_hook		mcore_elf_gc_mark_hook
 #define elf_backend_gc_sweep_hook		mcore_elf_gc_sweep_hook
 #define elf_backend_check_relocs                mcore_elf_check_relocs
-#define elf_backend_special_sections		mcore_elf_special_sections
+#define elf_backend_get_sec_type_attr		mcore_elf_get_sec_type_attr
 
 #define elf_backend_can_gc_sections		1
 #define elf_backend_rela_normal			1
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.166
diff -u -p -r1.166 elf32-ppc.c
--- bfd/elf32-ppc.c	30 Jun 2005 08:11:13 -0000	1.166
+++ bfd/elf32-ppc.c	1 Jul 2005 02:54:43 -0000
@@ -1828,70 +1828,44 @@ ppc_elf_additional_program_headers (bfd 
    that the linker doesn't crater when trying to make more than
    2 sections.  */
 
-static struct bfd_elf_special_section const
-  ppc_special_sections_p[] =
+static struct bfd_elf_special_section const ppc_elf_special_sections[] =
 {
   { ".plt",              4,  0, SHT_NOBITS,   SHF_ALLOC + SHF_EXECINSTR },
-  { NULL,                0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  ppc_special_sections_s[] =
-{
-  { ".sdata",            6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".sbss",             5, -2, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
-  { ".sdata2",           7, -2, SHT_PROGBITS, SHF_ALLOC },
   { ".sbss2",            6, -2, SHT_PROGBITS, SHF_ALLOC },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  ppc_special_sections_t[] =
-{
+  { ".sdata",            6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  { ".sdata2",           7, -2, SHT_PROGBITS, SHF_ALLOC },
   { ".tags",             5,  0, SHT_ORDERED,  SHF_ALLOC },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  ppc_special_sections_other[]=
-{
   { ".PPC.EMB.apuinfo", 16,  0, SHT_NOTE,     0 },
-  { ".PPC.EMB.sdata0",  15,  0, SHT_PROGBITS, SHF_ALLOC },
   { ".PPC.EMB.sbss0",   14,  0, SHT_PROGBITS, SHF_ALLOC },
-  { NULL,        0, 0, 0,            0 }
+  { ".PPC.EMB.sdata0",  15,  0, SHT_PROGBITS, SHF_ALLOC },
+  { NULL,                0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  ppc_elf_special_sections[27]=
+/* This is what we want for new plt/got.  */
+static struct bfd_elf_special_section ppc_alt_plt =
+  { ".plt",              4,  0, SHT_PROGBITS, SHF_ALLOC };
+
+static const struct bfd_elf_special_section *
+ppc_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  ppc_special_sections_p,	/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  ppc_special_sections_s,	/* 's' */
-  ppc_special_sections_t,	/* 's' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  ppc_special_sections_other,	/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name, ppc_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    {
+      if (ssect == ppc_elf_special_sections && (sec->flags & SEC_LOAD) != 0)
+	ssect = &ppc_alt_plt;
+      return ssect;
+    }
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 /* Very simple linked list structure for recording apuinfo values.  */
 typedef struct apuinfo_list
@@ -6978,7 +6951,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 #define elf_backend_begin_write_processing	ppc_elf_begin_write_processing
 #define elf_backend_final_write_processing	ppc_elf_final_write_processing
 #define elf_backend_write_section		ppc_elf_write_section
-#define elf_backend_special_sections		ppc_elf_special_sections
+#define elf_backend_get_sec_type_attr		ppc_elf_get_sec_type_attr
 #define elf_backend_plt_sym_val			ppc_elf_plt_sym_val
 
 #include "elf32-target.h"
Index: bfd/elf32-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh64.c,v
retrieving revision 1.34
diff -u -p -r1.34 elf32-sh64.c
--- bfd/elf32-sh64.c	7 May 2005 13:22:50 -0000	1.34
+++ bfd/elf32-sh64.c	1 Jul 2005 02:54:49 -0000
@@ -89,7 +89,7 @@ static void sh64_find_section_for_addres
 #define elf_backend_merge_symbol_attribute	sh64_elf_merge_symbol_attribute
 #define elf_backend_final_write_processing 	sh64_elf_final_write_processing
 #define elf_backend_section_from_shdr		sh64_backend_section_from_shdr
-#define elf_backend_special_sections		sh64_elf_special_sections
+#define elf_backend_get_sec_type_attr		sh64_elf_get_sec_type_attr
 #define elf_backend_section_flags		sh64_elf_section_flags
 
 #define bfd_elf32_new_section_hook		sh64_elf_new_section_hook
@@ -754,44 +754,29 @@ sh64_elf_merge_symbol_attribute (struct 
   return;
 }
 
-static struct bfd_elf_special_section const
-  sh64_special_sections_c[] =
+static struct bfd_elf_special_section const sh64_elf_special_sections[] =
 {
   { ".cranges", 8, 0, SHT_PROGBITS, 0 },
-  { NULL,        0, 0, 0,            0 }
+  { NULL,       0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  sh64_elf_special_sections[27]=
+static const struct bfd_elf_special_section *
+sh64_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  sh64_special_sections_c,	/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					sh64_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #undef	TARGET_BIG_SYM
 #define	TARGET_BIG_SYM		bfd_elf32_sh64_vec
Index: bfd/elf32-v850.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-v850.c,v
retrieving revision 1.57
diff -u -p -r1.57 elf32-v850.c
--- bfd/elf32-v850.c	20 Jun 2005 18:12:08 -0000	1.57
+++ bfd/elf32-v850.c	1 Jul 2005 02:54:49 -0000
@@ -3129,93 +3129,54 @@ v850_elf_relax_section (abfd, sec, link_
   goto finish;
 }
 
-static struct bfd_elf_special_section const
-  v850_special_sections_c[]=
+static struct bfd_elf_special_section const v850_elf_special_sections[] =
 {
   { ".call_table_data", 16,  0, SHT_PROGBITS,     (SHF_ALLOC
                                                    + SHF_WRITE) },
   { ".call_table_text", 16,  0, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
                                                    + SHF_EXECINSTR) },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  v850_special_sections_r[]=
-{
   { ".rosdata",          8, -2, SHT_PROGBITS,     (SHF_ALLOC
                                                    + SHF_V850_GPREL) },
   { ".rozdata",          8, -2, SHT_PROGBITS,     (SHF_ALLOC
                                                    + SHF_V850_R0REL) },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  v850_special_sections_s[]=
-{
-  { ".sdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
-                                                   + SHF_V850_GPREL) },
   { ".sbss",             5, -2, SHT_NOBITS,       (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_GPREL) },
   { ".scommon",          8, -2, SHT_V850_SCOMMON, (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_GPREL) },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  v850_special_sections_t[]=
-{
-  { ".tdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
-                                                   + SHF_V850_EPREL) },
+  { ".sdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
+                                                   + SHF_V850_GPREL) },
   { ".tbss",             5, -2, SHT_NOBITS,       (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_EPREL) },
   { ".tcommon",          8, -2, SHT_V850_TCOMMON, (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_R0REL) },
-  { NULL,               0,   0, 0,                0 }
-};
-
-static struct bfd_elf_special_section const
-  v850_special_sections_z[]=
-{
-  { ".zdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
-                                                   + SHF_V850_R0REL) },
+  { ".tdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
+                                                   + SHF_V850_EPREL) },
   { ".zbss",             5, -2, SHT_NOBITS,       (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_R0REL) },
   { ".zcommon",          8, -2, SHT_V850_ZCOMMON, (SHF_ALLOC + SHF_WRITE
                                                    + SHF_V850_R0REL) },
+  { ".zdata",            6, -2, SHT_PROGBITS,     (SHF_ALLOC + SHF_WRITE
+                                                   + SHF_V850_R0REL) },
   { NULL,        0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  v850_elf_special_sections[27] =
+static const struct bfd_elf_special_section *
+v850_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  v850_special_sections_c,	/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  v850_special_sections_r,	/* 'r' */
-  v850_special_sections_s,	/* 's' */
-  v850_special_sections_t,	/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  v850_special_sections_z,	/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					v850_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #define TARGET_LITTLE_SYM			bfd_elf32_v850_vec
 #define TARGET_LITTLE_NAME			"elf32-v850"
@@ -3240,7 +3201,7 @@ static struct bfd_elf_special_section co
 #define elf_backend_fake_sections		v850_elf_fake_sections
 #define elf_backend_gc_mark_hook                v850_elf_gc_mark_hook
 #define elf_backend_gc_sweep_hook               v850_elf_gc_sweep_hook
-#define elf_backend_special_sections		v850_elf_special_sections
+#define elf_backend_get_sec_type_attr		v850_elf_get_sec_type_attr
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_rela_normal 1
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.49
diff -u -p -r1.49 elf32-xtensa.c
--- bfd/elf32-xtensa.c	20 May 2005 19:53:18 -0000	1.49
+++ bfd/elf32-xtensa.c	1 Jul 2005 02:54:54 -0000
@@ -9482,57 +9478,31 @@ xtensa_callback_required_dependence (bfd
 /* The default literal sections should always be marked as "code" (i.e.,
    SHF_EXECINSTR).  This is particularly important for the Linux kernel
    module loader so that the literals are not placed after the text.  */
-static struct bfd_elf_special_section const
-  xtensa_special_sections_f[]=
+static struct bfd_elf_special_section const elf_xtensa_special_sections[] =
 {
   { ".fini.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
-  { NULL,             0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  xtensa_special_sections_i[]=
-{
   { ".init.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
-  { NULL,             0, 0, 0,            0 }
-};
-static struct bfd_elf_special_section const
-  xtensa_special_sections_l[]=
-{
   { ".literal",       8, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR },
   { NULL,             0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elf_xtensa_special_sections[27] =
+static const struct bfd_elf_special_section *
+elf_xtensa_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  xtensa_special_sections_f,	/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  xtensa_special_sections_i,	/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  xtensa_special_sections_l,	/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf_xtensa_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 
 #ifndef ELF_ARCH
@@ -9592,6 +9562,6 @@ static struct bfd_elf_special_section co
 #define elf_backend_reloc_type_class	     elf_xtensa_reloc_type_class
 #define elf_backend_relocate_section	     elf_xtensa_relocate_section
 #define elf_backend_size_dynamic_sections    elf_xtensa_size_dynamic_sections
-#define elf_backend_special_sections	     elf_xtensa_special_sections
+#define elf_backend_get_sec_type_attr	     elf_xtensa_get_sec_type_attr
 
 #include "elf32-target.h"
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.141
diff -u -p -r1.141 elf64-alpha.c
--- bfd/elf64-alpha.c	31 May 2005 22:53:44 -0000	1.141
+++ bfd/elf64-alpha.c	1 Jul 2005 02:54:57 -0000
@@ -5180,45 +5160,30 @@ elf64_alpha_reloc_type_class (const Elf_
     }
 }
 
-static struct bfd_elf_special_section const
-  alpha_special_sections_s[]=
+static struct bfd_elf_special_section const elf64_alpha_special_sections[] =
 {
-  { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
   { ".sbss",  5, -2, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
+  { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL },
   { NULL,     0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elf64_alpha_special_sections[27] =
+static const struct bfd_elf_special_section *
+elf64_alpha_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  alpha_special_sections_s,	/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf64_alpha_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 /* ECOFF swapping routines.  These are used when dealing with the
    .mdebug section, which is in the ECOFF debugging format.  Copied
@@ -5358,8 +5323,8 @@ static const struct elf_size_info alpha_
 #define elf_backend_size_info \
   alpha_elf_size_info
 
-#define elf_backend_special_sections \
-  elf64_alpha_special_sections
+#define elf_backend_get_sec_type_attr \
+  elf64_alpha_get_sec_type_attr
 
 /* A few constants that determine how the .plt section is set up.  */
 #define elf_backend_want_got_plt 0
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.59
diff -u -p -r1.59 elf64-hppa.c
--- bfd/elf64-hppa.c	7 May 2005 13:22:52 -0000	1.59
+++ bfd/elf64-hppa.c	1 Jul 2005 02:54:59 -0000
@@ -2671,51 +2642,30 @@ elf64_hppa_elf_get_symbol_type (elf_sym,
     return type;
 }
 
-static struct bfd_elf_special_section const
-  hppa_special_sections_f[]=
+static struct bfd_elf_special_section const elf64_hppa_special_sections[] =
 {
   { ".fini",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  hppa_special_sections_i[]=
-{
   { ".init",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { NULL,       0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elf64_hppa_special_sections[27] =
+static const struct bfd_elf_special_section *
+elf64_hppa_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  hppa_special_sections_f,	/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  hppa_special_sections_i,	/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'f' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elf64_hppa_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 /* The hash bucket size is the standard one, namely 4.  */
 
@@ -2813,7 +2763,7 @@ const struct elf_size_info hppa64_elf_si
 #define elf_backend_get_symbol_type	elf64_hppa_elf_get_symbol_type
 #define elf_backend_reloc_type_class	elf64_hppa_reloc_type_class
 #define elf_backend_rela_normal		1
-#define elf_backend_special_sections	elf64_hppa_special_sections
+#define elf_backend_get_sec_type_attr	elf64_hppa_get_sec_type_attr
 
 #include "elf64-target.h"
 
@@ -2822,7 +2772,7 @@ const struct elf_size_info hppa64_elf_si
 #undef TARGET_BIG_NAME
 #define TARGET_BIG_NAME			"elf64-hppa-linux"
 
-#undef elf_backend_special_sections
+#undef elf_backend_get_sec_type_attr
 
 #define INCLUDED_TARGET_FILE 1
 #include "elf64-target.h"
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.211
diff -u -p -r1.211 elf64-ppc.c
--- bfd/elf64-ppc.c	20 Jun 2005 18:12:08 -0000	1.211
+++ bfd/elf64-ppc.c	1 Jul 2005 02:55:04 -0000
@@ -100,7 +100,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_reloc_type_class	      ppc64_elf_reloc_type_class
 #define elf_backend_finish_dynamic_sections   ppc64_elf_finish_dynamic_sections
 #define elf_backend_link_output_symbol_hook   ppc64_elf_output_symbol_hook
-#define elf_backend_special_sections	      ppc64_elf_special_sections
+#define elf_backend_get_sec_type_attr	      ppc64_elf_get_sec_type_attr
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
@@ -2508,61 +2508,34 @@ ppc64_elf_merge_private_bfd_data (bfd *i
 
 /* Add extra PPC sections.  */
 
-static struct bfd_elf_special_section const
-  ppc64_special_sections_p[]=
+static struct bfd_elf_special_section const ppc64_elf_special_sections[]=
 {
   { ".plt",     4,  0, SHT_NOBITS,   0 },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  ppc64_special_sections_s[]=
-{
-  { ".sdata",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".sbss",    5, -2, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
-  { NULL,        0, 0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  ppc64_special_sections_t[]=
-{
+  { ".sdata",   6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".toc",     4,  0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".toc1",    5,  0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".tocbss",  7,  0, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE },
   { NULL,       0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  ppc64_elf_special_sections[27]=
+static const struct bfd_elf_special_section *
+ppc64_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  ppc64_special_sections_p,	/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  ppc64_special_sections_s,	/* 's' */
-  ppc64_special_sections_t,	/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					ppc64_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 struct _ppc64_elf_section_data
 {
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.58
diff -u -p -r1.58 elf64-sh64.c
--- bfd/elf64-sh64.c	20 Jun 2005 18:12:10 -0000	1.58
+++ bfd/elf64-sh64.c	1 Jul 2005 02:55:08 -0000
@@ -4068,44 +4056,29 @@ sh64_elf64_merge_symbol_attribute (struc
   return;
 }
 
-static struct bfd_elf_special_section const
-  sh64_special_sections_c[] =
+static struct bfd_elf_special_section const sh64_elf64_special_sections[]=
 {
   { ".cranges", 8, 0, SHT_PROGBITS, 0 },
-  { NULL,        0, 0, 0,            0 }
+  { NULL,       0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  sh64_elf64_special_sections[27]=
+static const struct bfd_elf_special_section *
+sh64_elf64_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  sh64_special_sections_c,	/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  NULL,				/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					sh64_elf64_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 #define TARGET_BIG_SYM		bfd_elf64_sh64_vec
 #define TARGET_BIG_NAME		"elf64-sh64"
@@ -4165,7 +4138,7 @@ static struct bfd_elf_special_section co
 					sh64_elf64_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
 					sh64_elf64_finish_dynamic_sections
-#define elf_backend_special_sections	sh64_elf64_special_sections
+#define elf_backend_get_sec_type_attr	sh64_elf64_get_sec_type_attr
 
 #define elf_backend_want_got_plt	1
 #define elf_backend_plt_readonly	1
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.165
diff -u -p -r1.165 elfxx-ia64.c
--- bfd/elfxx-ia64.c	27 Jun 2005 21:08:10 -0000	1.165
+++ bfd/elfxx-ia64.c	1 Jul 2005 02:55:12 -0000
@@ -5050,45 +5050,30 @@ elfNN_ia64_reloc_type_class (rela)
     }
 }
 
-static struct bfd_elf_special_section const
-  ia64_special_sections_s[]=
+static struct bfd_elf_special_section const elfNN_ia64_special_sections[] =
 {
   { ".sbss",  5, -1, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
   { ".sdata", 6, -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
   { NULL,        0, 0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elfNN_ia64_special_sections[27] =
+static const struct bfd_elf_special_section *
+elfNN_ia64_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  NULL,				/* 'l' */
-  NULL,				/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  ia64_special_sections_s,	/* 's' */
-  NULL,				/* 't' */
-  NULL,				/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					elfNN_ia64_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 
 static bfd_boolean
 elfNN_ia64_object_p (bfd *abfd)
@@ -5311,7 +5296,7 @@ elfNN_hpux_backend_symbol_processing (bf
 #define elf_backend_hide_symbol		elfNN_ia64_hash_hide_symbol
 #define elf_backend_reloc_type_class	elfNN_ia64_reloc_type_class
 #define elf_backend_rela_normal		1
-#define elf_backend_special_sections	elfNN_ia64_special_sections
+#define elf_backend_get_sec_type_attr	elfNN_ia64_get_sec_type_attr
 
 /* FIXME: PR 290: The Intel C compiler generates SHT_IA_64_UNWIND with
    SHF_LINK_ORDER. But it doesn't set theh sh_link or sh_info fields.
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.142
diff -u -p -r1.142 elfxx-mips.c
--- bfd/elfxx-mips.c	20 Jun 2005 18:12:10 -0000	1.142
+++ bfd/elfxx-mips.c	1 Jul 2005 02:55:18 -0000
@@ -9969,63 +9956,31 @@ _bfd_mips_elf_print_private_bfd_data (bf
   return TRUE;
 }
 
-static struct bfd_elf_special_section const
-  mips_special_sections_l[]=
+struct bfd_elf_special_section const _bfd_mips_elf_special_sections[] =
 {
   { ".lit4",   5,  0, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
   { ".lit8",   5,  0, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
-  { NULL,      0,  0, 0,              0 }
-};
-
-static struct bfd_elf_special_section const
-  mips_special_sections_m[]=
-{
   { ".mdebug", 7,  0, SHT_MIPS_DEBUG, 0 },
-  { NULL,      0,  0, 0,              0 }
-};
-
-static struct bfd_elf_special_section const
-  mips_special_sections_s[]=
-{
-  { ".sdata",  6, -2, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
   { ".sbss",   5, -2, SHT_NOBITS,     SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
-};
-
-static struct bfd_elf_special_section const
-  mips_special_sections_u[]=
-{
+  { ".sdata",  6, -2, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
   { ".ucode",  6,  0, SHT_MIPS_UCODE, 0 },
   { NULL,      0,  0, 0,              0 }
 };
 
-struct bfd_elf_special_section const *
-  _bfd_mips_elf_special_sections[27] =
+const struct bfd_elf_special_section *
+_bfd_mips_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  NULL,				/* 'a' */
-  NULL,				/* 'b' */
-  NULL,				/* 'c' */
-  NULL,				/* 'd' */
-  NULL,				/* 'e' */
-  NULL,				/* 'f' */
-  NULL,				/* 'g' */
-  NULL,				/* 'h' */
-  NULL,				/* 'i' */
-  NULL,				/* 'j' */
-  NULL,				/* 'k' */
-  mips_special_sections_l,	/* 'l' */
-  mips_special_sections_m,	/* 'm' */
-  NULL,				/* 'n' */
-  NULL,				/* 'o' */
-  NULL,				/* 'p' */
-  NULL,				/* 'q' */
-  NULL,				/* 'r' */
-  mips_special_sections_s,	/* 'm' */
-  NULL,				/* 't' */
-  mips_special_sections_u,	/* 'u' */
-  NULL,				/* 'v' */
-  NULL,				/* 'w' */
-  NULL,				/* 'x' */
-  NULL,				/* 'y' */
-  NULL,				/* 'z' */
-  NULL				/* other */
-};
+  const struct bfd_elf_special_section const *ssect;
+
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
+
+  ssect = _bfd_elf_get_special_section (sec->name,
+					_bfd_mips_elf_special_sections,
+					sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
Index: bfd/elfxx-mips.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.h,v
retrieving revision 1.27
diff -u -p -r1.27 elfxx-mips.h
--- bfd/elfxx-mips.h	23 May 2005 17:44:54 -0000	1.27
+++ bfd/elfxx-mips.h	1 Jul 2005 02:55:18 -0000
@@ -127,9 +127,10 @@ extern bfd_boolean _bfd_mips_relax_secti
   (bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
 extern bfd_vma _bfd_mips_elf_sign_extend
   (bfd_vma, int);
+extern const struct bfd_elf_special_section *_bfd_mips_elf_get_sec_type_attr
+  (bfd *, asection *);
 
-extern struct bfd_elf_special_section const *_bfd_mips_elf_special_sections[];
 #define elf_backend_name_local_section_symbols \
   _bfd_mips_elf_name_local_section_symbols
-#define elf_backend_special_sections _bfd_mips_elf_special_sections
+#define elf_backend_get_sec_type_attr _bfd_mips_elf_get_sec_type_attr
 #define elf_backend_eh_frame_address_size _bfd_mips_elf_eh_frame_address_size
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.84
diff -u -p -r1.84 elfxx-target.h
--- bfd/elfxx-target.h	23 May 2005 17:44:54 -0000	1.84
+++ bfd/elfxx-target.h	1 Jul 2005 02:55:20 -0000
@@ -331,6 +331,9 @@
 #ifndef elf_backend_section_flags
 #define elf_backend_section_flags	0
 #endif
+#ifndef elf_backend_get_sec_type_attr
+#define elf_backend_get_sec_type_attr	_bfd_elf_get_sec_type_attr
+#endif
 #ifndef elf_backend_section_from_phdr
 #define elf_backend_section_from_phdr	_bfd_elf_make_section_from_phdr
 #endif
@@ -506,10 +509,6 @@
 #define elf_backend_size_info _bfd_elfNN_size_info
 #endif
 
-#ifndef elf_backend_special_sections
-#define elf_backend_special_sections NULL
-#endif
-
 #ifndef elf_backend_sign_extend_vma
 #define elf_backend_sign_extend_vma 0
 #endif
@@ -540,6 +539,7 @@ static const struct elf_backend_data elf
   elf_backend_section_processing,
   elf_backend_section_from_shdr,
   elf_backend_section_flags,
+  elf_backend_get_sec_type_attr,
   elf_backend_section_from_phdr,
   elf_backend_fake_sections,
   elf_backend_section_from_bfd_section,
@@ -591,7 +591,6 @@ static const struct elf_backend_data elf
   ELF_MACHINE_ALT1,
   ELF_MACHINE_ALT2,
   &elf_backend_size_info,
-  elf_backend_special_sections,
   elf_backend_got_header_size,
   elf_backend_collect,
   elf_backend_type_change_ok,
Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.84
diff -u -p -r1.84 objcopy.c
--- binutils/objcopy.c	14 Jun 2005 13:26:42 -0000	1.84
+++ binutils/objcopy.c	1 Jul 2005 02:55:25 -0000
@@ -1290,7 +1290,15 @@ copy_object (bfd *ibfd, bfd *obfd)
 	{
 	  flagword flags;
 
-	  padd->section = bfd_make_section (obfd, padd->name);
+	  pset = find_section_list (padd->name, FALSE);
+	  if (pset != NULL)
+	    pset->used = TRUE;
+
+	  flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
+	  if (pset != NULL && pset->set_flags)
+	    flags = pset->flags | SEC_HAS_CONTENTS;
+
+	  padd->section = bfd_make_section_with_flags (obfd, padd->name, flags);
 	  if (padd->section == NULL)
 	    {
 	      non_fatal (_("can't create section `%s': %s"),
@@ -1304,21 +1312,6 @@ copy_object (bfd *ibfd, bfd *obfd)
 	      return FALSE;
 	    }
 
-	  pset = find_section_list (padd->name, FALSE);
-	  if (pset != NULL)
-	    pset->used = TRUE;
-
-	  if (pset != NULL && pset->set_flags)
-	    flags = pset->flags | SEC_HAS_CONTENTS;
-	  else
-	    flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
-
-	  if (! bfd_set_section_flags (obfd, padd->section, flags))
-	    {
-	      bfd_nonfatal (bfd_get_filename (obfd));
-	      return FALSE;
-	    }
-
 	  if (pset != NULL)
 	    {
 	      if (pset->change_vma != CHANGE_IGNORE)
@@ -2001,7 +1994,12 @@ setup_section (bfd *ibfd, sec_ptr isecti
       name = n;
     }
 
-  osection = bfd_make_section_anyway (obfd, name);
+  if (p != NULL && p->set_flags)
+    flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
+  else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0)
+    flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+
+  osection = bfd_make_section_anyway_with_flags (obfd, name, flags);
 
   if (osection == NULL)
     {
@@ -2009,6 +2007,12 @@ setup_section (bfd *ibfd, sec_ptr isecti
       goto loser;
     }
 
+  if (strip_symbols == STRIP_NONDEBUG
+      && obfd->xvec->flavour == bfd_target_elf_flavour
+      && (flags & SEC_ALLOC) != 0
+      && (p == NULL || !p->set_flags))
+    elf_section_type (osection) = SHT_NOBITS;
+
   size = bfd_section_size (ibfd, isection);
   if (copy_byte >= 0)
     size = (size + interleave - 1) / interleave;
@@ -2057,21 +2061,6 @@ setup_section (bfd *ibfd, sec_ptr isecti
       goto loser;
     }
 
-  if (p != NULL && p->set_flags)
-    flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
-  else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0)
-    {
-      flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
-      if (obfd->xvec->flavour == bfd_target_elf_flavour)
-	elf_section_type (osection) = SHT_NOBITS;
-    }
-
-  if (!bfd_set_section_flags (obfd, osection, flags))
-    {
-      err = _("flags");
-      goto loser;
-    }
-
   /* Copy merge entity size.  */
   osection->entsize = isection->entsize;
 
@@ -2353,28 +2342,22 @@ write_debugging_info (bfd *obfd, void *d
       bfd_byte *syms, *strings;
       bfd_size_type symsize, stringsize;
       asection *stabsec, *stabstrsec;
+      flagword flags;
 
       if (! write_stabs_in_sections_debugging_info (obfd, dhandle, &syms,
 						    &symsize, &strings,
 						    &stringsize))
 	return FALSE;
 
-      stabsec = bfd_make_section (obfd, ".stab");
-      stabstrsec = bfd_make_section (obfd, ".stabstr");
+      flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+      stabsec = bfd_make_section_with_flags (obfd, ".stab", flags);
+      stabstrsec = bfd_make_section_with_flags (obfd, ".stabstr", flags);
       if (stabsec == NULL
 	  || stabstrsec == NULL
 	  || ! bfd_set_section_size (obfd, stabsec, symsize)
 	  || ! bfd_set_section_size (obfd, stabstrsec, stringsize)
 	  || ! bfd_set_section_alignment (obfd, stabsec, 2)
-	  || ! bfd_set_section_alignment (obfd, stabstrsec, 0)
-	  || ! bfd_set_section_flags (obfd, stabsec,
-				   (SEC_HAS_CONTENTS
-				    | SEC_READONLY
-				    | SEC_DEBUGGING))
-	  || ! bfd_set_section_flags (obfd, stabstrsec,
-				      (SEC_HAS_CONTENTS
-				       | SEC_READONLY
-				       | SEC_DEBUGGING)))
+	  || ! bfd_set_section_alignment (obfd, stabstrsec, 0))
 	{
 	  non_fatal (_("%s: can't create debugging section: %s"),
 		     bfd_get_filename (obfd),
Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.93
diff -u -p -r1.93 obj-elf.c
--- gas/config/obj-elf.c	5 May 2005 09:12:52 -0000	1.93
+++ gas/config/obj-elf.c	1 Jul 2005 02:55:40 -0000
@@ -520,6 +520,7 @@ obj_elf_change_section (const char *name
   asection *old_sec;
   segT sec;
   flagword flags;
+  const struct elf_backend_data *bed;
   const struct bfd_elf_special_section *ssect;
 
 #ifdef md_flush_pending_output
@@ -551,7 +552,8 @@ obj_elf_change_section (const char *name
   else
     sec = subseg_force_new (name, 0);
 
-  ssect = _bfd_elf_get_sec_type_attr (stdoutput, name);
+  bed = get_elf_backend_data (stdoutput);
+  ssect = (*bed->get_sec_type_attr) (stdoutput, sec);
 
   if (ssect != NULL)
     {

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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