PR 1004
authorAlan Modra <amodra@gmail.com>
Mon, 4 Jul 2005 01:53:44 +0000 (01:53 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 4 Jul 2005 01:53:44 +0000 (01:53 +0000)
bfd/
* 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.

24 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf.c
bfd/elf32-arm.c
bfd/elf32-m32r.c
bfd/elf32-m68hc11.c
bfd/elf32-m68hc12.c
bfd/elf32-mcore.c
bfd/elf32-ppc.c
bfd/elf32-sh64.c
bfd/elf32-v850.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-ppc.c
bfd/elf64-sh64.c
bfd/elfxx-ia64.c
bfd/elfxx-mips.c
bfd/elfxx-mips.h
bfd/elfxx-target.h
binutils/ChangeLog
binutils/objcopy.c
gas/ChangeLog
gas/config/obj-elf.c

index 72e3bdf42eeb981ff5b9ffa83b3316c5928e671f..388c568d9f66117ba8a0da4e6cc6cd42e1c51e9e 100644 (file)
@@ -1,3 +1,46 @@
+2005-07-04  Alan Modra  <amodra@bigpond.net.au>
+
+       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.
+
 2005-07-01  Nick Clifton  <nickc@redhat.com>
 
        * cpu-d10v.c: Update to ISO C90 style function declarations and
index 7c758910f42e460962ada4572f45093411755403..103b613354d6d7cd736bc27b6d277510bb88a402 100644 (file)
@@ -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_hook
   (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 590ce35328d162fa5cf935375e0572eccc77aed4..5bbe6503a24d07d1a1c6f3d8b6a9c2498b316b61 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2270,9 +2270,8 @@ static struct bfd_elf_special_section const special_sections_t[] =
   { 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 const *special_sections [27] =
   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, asection *sec)
       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, asection *sec)
        }
     }
 
-  /* 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 af26109180e70a6fc53357ffb73849adea1fa549..d140e678415dc7ba8d6e9de2926d1613d0841417 100644 (file)
@@ -6943,7 +6943,7 @@ elf32_arm_symbian_link_hash_table_create (bfd *abfd)
 }     
 
 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 +6952,34 @@ static struct bfd_elf_special_section const
   { ".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 +7033,8 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd,
 #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 ea6a40d1a46fb4e1341daa64c095f291fc1184c6..f798088f0d869eca0a8a7bbb69dbde0326e14504 100644 (file)
@@ -4013,45 +4013,30 @@ m32r_elf_check_relocs (bfd *abfd,
   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 (bfd *abfd,
@@ -4156,7 +4141,7 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *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 aff4be6a2b7a804e161827904fa2644130cdd4ec..0cdeef7adcb3aa96bac2bac21bd56cd802c7e2fd 100644 (file)
@@ -1257,65 +1257,32 @@ m68hc11_elf_relax_delete_bytes (bfd *abfd, asection *sec,
      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;
 
-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 */
-};
+  ssect = _bfd_elf_get_special_section (sec->name,
+                                       elf32_m68hc11_special_sections,
+                                       sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 \f
 #define ELF_ARCH               bfd_arch_m68hc11
 #define ELF_MACHINE_CODE       EM_68HC11
@@ -1335,7 +1302,7 @@ static struct bfd_elf_special_section const *
 #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 213ead23b76a2e760b38dd20d69042df7fa42535..6a3a86edfa7fa62538574637f60160eb179690c5 100644 (file)
@@ -535,65 +535,32 @@ m68hc12_elf_set_mach_from_flags (bfd *abfd)
      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;
 
-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 */
-};
+  ssect = _bfd_elf_get_special_section (sec->name,
+                                       elf32_m68hc12_special_sections,
+                                       sec->use_rela_p);
+  if (ssect != NULL)
+    return ssect;
+
+  return _bfd_elf_get_sec_type_attr (abfd, sec);
+}
 \f
 #define ELF_ARCH               bfd_arch_m68hc12
 #define ELF_MACHINE_CODE       EM_68HC12
@@ -611,7 +578,7 @@ static struct bfd_elf_special_section const *
 #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 b554ec06cecb1dca385269f989154d6ae0488be2..cd2590d998149a7c4bceb33d143c9f3caec40cc0 100644 (file)
@@ -635,51 +635,30 @@ mcore_elf_check_relocs (bfd * abfd,
   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"
@@ -699,7 +678,7 @@ static struct bfd_elf_special_section const *
 #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 1d41f57f25a27490a342258fa3cfa8499923d018..1569fb014ba0c99d0adb95b4fadafa8e7c56f74d 100644 (file)
@@ -1828,70 +1828,44 @@ ppc_elf_additional_program_headers (bfd *abfd)
    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);
+}
 \f
 /* Very simple linked list structure for recording apuinfo values.  */
 typedef struct apuinfo_list
@@ -6978,7 +6952,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
 #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 dac8bb4d4481d940625fb5339e64a6aae895c0f6..d9b3f38702cda065a2e93dbca8b653303465a927 100644 (file)
@@ -89,7 +89,7 @@ static void sh64_find_section_for_address
 #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 elf_link_hash_entry *h,
   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 ba98a180717e7c760a78f6baad481a586727c9f5..26f479c9c0638f85bb520692cb89828f563f8091 100644 (file)
@@ -3024,93 +3024,54 @@ v850_elf_relax_section (bfd *abfd,
   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);
+}
 \f
 #define TARGET_LITTLE_SYM                      bfd_elf32_v850_vec
 #define TARGET_LITTLE_NAME                     "elf32-v850"
@@ -3135,7 +3096,7 @@ static struct bfd_elf_special_section const *
 #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 fea89dded97867e7b23cc4ac74b24a611f11c5e1..69cc6baa52a89fffbc46b1adf0b548083a559f99 100644 (file)
@@ -9482,57 +9482,31 @@ xtensa_callback_required_dependence (bfd *abfd,
 /* 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] =
-{
-  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 */
-};
+static const struct bfd_elf_special_section *
+elf_xtensa_get_sec_type_attr (bfd *abfd, asection *sec)
+{
+  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);
+}
 
 \f
 #ifndef ELF_ARCH
@@ -9592,6 +9566,6 @@ static struct bfd_elf_special_section const *
 #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 ac7ada245346c6e1e7171956f9667c0d5b045768..52f82d22408de1301068f81c22598e09e2a44cce 100644 (file)
@@ -5162,45 +5162,30 @@ elf64_alpha_reloc_type_class (const Elf_Internal_Rela *rela)
     }
 }
 \f
-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
@@ -5340,8 +5325,8 @@ static const struct elf_size_info alpha_elf_size_info =
 #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 9084f1fbb22cd4a41c597c397d83ed63b1ba9c93..267c62355e17b29b7d89e3b238b99512d1e39464 100644 (file)
@@ -2671,51 +2671,30 @@ elf64_hppa_elf_get_symbol_type (elf_sym, type)
     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 +2792,7 @@ const struct elf_size_info hppa64_elf_size_info =
 #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 +2801,7 @@ const struct elf_size_info hppa64_elf_size_info =
 #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 51b6cc9b64328d17b97270b6f1f382182e906803..570754acdcb8ea34d43785ae78a1d92451c68491 100644 (file)
@@ -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 *ibfd, bfd *obfd)
 
 /* 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 2b4630dc5565fe0daf373b39c9b1b659282c3e72..16fbe5e5676e39fd56c71a874865a8fdbe4b4d2d 100644 (file)
@@ -4068,44 +4068,29 @@ sh64_elf64_merge_symbol_attribute (struct elf_link_hash_entry *h,
   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 +4150,7 @@ static struct bfd_elf_special_section const *
                                        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 9963734c670e1675b61c38c3afe5309fd7161edf..d9f876269442a52488c08249b4897b677964c6a5 100644 (file)
@@ -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 (bfd *abfd ATTRIBUTE_UNUSED,
 #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 10ce7d19def0de3647d6a7e387870a0796ba952b..dc75331b06f2b8ddd933275103eef8ae2e15c17d 100644 (file)
@@ -9969,63 +9969,31 @@ _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr)
   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 },
+  { ".sbss",   5, -2, SHT_NOBITS,     SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
+  { ".sdata",  6, -2, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
+  { ".ucode",  6,  0, SHT_MIPS_UCODE, 0 },
   { NULL,      0,  0, 0,              0 }
 };
 
-static struct bfd_elf_special_section const
-  mips_special_sections_s[]=
+const struct bfd_elf_special_section *
+_bfd_mips_elf_get_sec_type_attr (bfd *abfd, asection *sec)
 {
-  { ".sdata",  6, -2, SHT_PROGBITS,   SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
-  { ".sbss",   5, -2, SHT_NOBITS,     SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL },
-};
+  const struct bfd_elf_special_section const *ssect;
 
-static struct bfd_elf_special_section const
-  mips_special_sections_u[]=
-{
-  { ".ucode",  6,  0, SHT_MIPS_UCODE, 0 },
-  { NULL,      0,  0, 0,              0 }
-};
+  /* See if this is one of the special sections.  */
+  if (sec->name == NULL)
+    return NULL;
 
-struct bfd_elf_special_section const *
-  _bfd_mips_elf_special_sections[27] =
-{
-  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 */
-};
+  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 624d4ab7ce7b3d5d0815393aae095ecbe58f47e7..2c63123bb25cd16de815d575480c1333b6ecc92c 100644 (file)
@@ -127,9 +127,10 @@ extern bfd_boolean _bfd_mips_relax_section
   (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 fcfd0402d9c30cb44f91d24d166ebfaf32ba22e9..7a7f3e850226e35033ce0982f887d571702f875e 100644 (file)
 #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
 #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 elfNN_bed =
   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 elfNN_bed =
   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 3e25586861924ecf51ba2f4f8583d865f5721e7d..24984942b70597cd24554a120ab8fa42145d0303 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-04  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 1004
+       * objcopy.c (copy_object): Use bfd_make_section_with_flags.
+       (write_debugging_info): Likewise.
+       (setup_section): Use bfd_make_section_anyway_with_flags.
+
 2005-07-01  Steve Ellcey  <sje@cup.hp.com>
 
        * configure.in (AM_BINUTILS_WARNINGS): Add.
index 4dfba3c7b79a1cf48f83b971f63fd56c17ced122..abc0eb1326c217857e456bb2178942eca52ec0a9 100644 (file)
@@ -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 isection, void *obfdarg)
       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 isection, void *obfdarg)
       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 isection, void *obfdarg)
       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 *dhandle,
       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 2fd0e6370fb08573dd6a55ed8db93ad0d5344630..b883fbcf9347aea36453b9be0449aa9b9441bd65 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-04  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 1004
+       * config/obj-elf.c (obj_elf_change_section): Use backend
+       get_sec_type_attr.
+
 2005-07-01  Jan Beulich  <jbeulich@novell.com>
 
        * config/tc-ia64.c (line_separator_chars): Add '{' and '}'.
index 1db7b485500e0d057016552f87905ad1f1b7d4c7..d015dab2ea3fd9b93ca44b0f915fb4060a9d1e82 100644 (file)
@@ -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)
     {