PR 1004
[deliverable/binutils-gdb.git] / bfd / elf64-hppa.c
index 800d66ad7ca57e966a20ab13d23da164268fa04b..267c62355e17b29b7d89e3b238b99512d1e39464 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for HPPA 64-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -16,7 +16,7 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "alloca-conf.h"
 #include "bfd.h"
@@ -184,9 +184,6 @@ static const char *get_dyn_name
 static bfd_boolean elf64_hppa_object_p
   PARAMS ((bfd *));
 
-static bfd_boolean elf64_hppa_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
-
 static void elf64_hppa_post_process_headers
   PARAMS ((bfd *, struct bfd_link_info *));
 
@@ -305,14 +302,15 @@ elf64_hppa_new_dyn_hash_entry (entry, table, string)
   if (!ret)
     return 0;
 
-  /* Initialize our local data.  All zeros, and definitely easier
-     than setting 8 bit fields.  */
-  memset (ret, 0, sizeof (*ret));
-
   /* Call the allocation method of the superclass.  */
   ret = ((struct elf64_hppa_dyn_hash_entry *)
         bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
 
+  /* Initialize our local data.  All zeros.  */
+  memset (&ret->dlt_offset, 0,
+         (sizeof (struct elf64_hppa_dyn_hash_entry)
+          - offsetof (struct elf64_hppa_dyn_hash_entry, dlt_offset)));
+
   return &ret->root;
 }
 
@@ -412,10 +410,10 @@ elf64_hppa_object_p (abfd)
 /* Given section type (hdr->sh_type), return a boolean indicating
    whether or not the section is an elf64-hppa specific section.  */
 static bfd_boolean
-elf64_hppa_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+elf64_hppa_section_from_shdr (bfd *abfd,
+                             Elf_Internal_Shdr *hdr,
+                             const char *name,
+                             int shindex)
 {
   asection *newsect;
 
@@ -435,7 +433,7 @@ elf64_hppa_section_from_shdr (abfd, hdr, name)
       return FALSE;
     }
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
   newsect = hdr->bfd_section;
 
@@ -534,15 +532,14 @@ get_reloc_section (abfd, hppa_info, sec)
   srel = bfd_get_section_by_name (dynobj, srel_name);
   if (srel == NULL)
     {
-      srel = bfd_make_section (dynobj, srel_name);
+      srel = bfd_make_section_with_flags (dynobj, srel_name,
+                                         (SEC_ALLOC
+                                          | SEC_LOAD
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_LINKER_CREATED
+                                          | SEC_READONLY));
       if (srel == NULL
-         || !bfd_set_section_flags (dynobj, srel,
-                                    (SEC_ALLOC
-                                     | SEC_LOAD
-                                     | SEC_HAS_CONTENTS
-                                     | SEC_IN_MEMORY
-                                     | SEC_LINKER_CREATED
-                                     | SEC_READONLY))
          || !bfd_set_section_alignment (dynobj, srel, 3))
        return FALSE;
     }
@@ -1234,14 +1231,13 @@ get_opd (abfd, info, hppa_info)
       if (!dynobj)
        hppa_info->root.dynobj = dynobj = abfd;
 
-      opd = bfd_make_section (dynobj, ".opd");
+      opd = bfd_make_section_with_flags (dynobj, ".opd",
+                                        (SEC_ALLOC
+                                         | SEC_LOAD
+                                         | SEC_HAS_CONTENTS
+                                         | SEC_IN_MEMORY
+                                         | SEC_LINKER_CREATED));
       if (!opd
-         || !bfd_set_section_flags (dynobj, opd,
-                                    (SEC_ALLOC
-                                     | SEC_LOAD
-                                     | SEC_HAS_CONTENTS
-                                     | SEC_IN_MEMORY
-                                     | SEC_LINKER_CREATED))
          || !bfd_set_section_alignment (abfd, opd, 3))
        {
          BFD_ASSERT (0);
@@ -1272,14 +1268,13 @@ get_plt (abfd, info, hppa_info)
       if (!dynobj)
        hppa_info->root.dynobj = dynobj = abfd;
 
-      plt = bfd_make_section (dynobj, ".plt");
+      plt = bfd_make_section_with_flags (dynobj, ".plt",
+                                        (SEC_ALLOC
+                                         | SEC_LOAD
+                                         | SEC_HAS_CONTENTS
+                                         | SEC_IN_MEMORY
+                                         | SEC_LINKER_CREATED));
       if (!plt
-         || !bfd_set_section_flags (dynobj, plt,
-                                    (SEC_ALLOC
-                                     | SEC_LOAD
-                                     | SEC_HAS_CONTENTS
-                                     | SEC_IN_MEMORY
-                                     | SEC_LINKER_CREATED))
          || !bfd_set_section_alignment (abfd, plt, 3))
        {
          BFD_ASSERT (0);
@@ -1310,14 +1305,13 @@ get_dlt (abfd, info, hppa_info)
       if (!dynobj)
        hppa_info->root.dynobj = dynobj = abfd;
 
-      dlt = bfd_make_section (dynobj, ".dlt");
+      dlt = bfd_make_section_with_flags (dynobj, ".dlt",
+                                        (SEC_ALLOC
+                                         | SEC_LOAD
+                                         | SEC_HAS_CONTENTS
+                                         | SEC_IN_MEMORY
+                                         | SEC_LINKER_CREATED));
       if (!dlt
-         || !bfd_set_section_flags (dynobj, dlt,
-                                    (SEC_ALLOC
-                                     | SEC_LOAD
-                                     | SEC_HAS_CONTENTS
-                                     | SEC_IN_MEMORY
-                                     | SEC_LINKER_CREATED))
          || !bfd_set_section_alignment (abfd, dlt, 3))
        {
          BFD_ASSERT (0);
@@ -1348,15 +1342,13 @@ get_stub (abfd, info, hppa_info)
       if (!dynobj)
        hppa_info->root.dynobj = dynobj = abfd;
 
-      stub = bfd_make_section (dynobj, ".stub");
+      stub = bfd_make_section_with_flags (dynobj, ".stub",
+                                         (SEC_ALLOC | SEC_LOAD
+                                          | SEC_HAS_CONTENTS
+                                          | SEC_IN_MEMORY
+                                          | SEC_READONLY
+                                          | SEC_LINKER_CREATED));
       if (!stub
-         || !bfd_set_section_flags (dynobj, stub,
-                                    (SEC_ALLOC
-                                     | SEC_LOAD
-                                     | SEC_HAS_CONTENTS
-                                     | SEC_IN_MEMORY
-                                     | SEC_READONLY
-                                     | SEC_LINKER_CREATED))
          || !bfd_set_section_alignment (abfd, stub, 3))
        {
          BFD_ASSERT (0);
@@ -1426,46 +1418,46 @@ elf64_hppa_create_dynamic_sections (abfd, info)
   if (! get_opd (abfd, info, elf64_hppa_hash_table (info)))
     return FALSE;
 
-  s = bfd_make_section(abfd, ".rela.dlt");
+  s = bfd_make_section_with_flags (abfd, ".rela.dlt",
+                                  (SEC_ALLOC | SEC_LOAD
+                                   | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY
+                                   | SEC_READONLY
+                                   | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | SEC_READONLY
-                                          | SEC_LINKER_CREATED))
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   elf64_hppa_hash_table (info)->dlt_rel_sec = s;
 
-  s = bfd_make_section(abfd, ".rela.plt");
+  s = bfd_make_section_with_flags (abfd, ".rela.plt",
+                                  (SEC_ALLOC | SEC_LOAD
+                                   | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY
+                                   | SEC_READONLY
+                                   | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | SEC_READONLY
-                                          | SEC_LINKER_CREATED))
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   elf64_hppa_hash_table (info)->plt_rel_sec = s;
 
-  s = bfd_make_section(abfd, ".rela.data");
+  s = bfd_make_section_with_flags (abfd, ".rela.data",
+                                  (SEC_ALLOC | SEC_LOAD
+                                   | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY
+                                   | SEC_READONLY
+                                   | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | SEC_READONLY
-                                          | SEC_LINKER_CREATED))
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   elf64_hppa_hash_table (info)->other_rel_sec = s;
 
-  s = bfd_make_section(abfd, ".rela.opd");
+  s = bfd_make_section_with_flags (abfd, ".rela.opd",
+                                  (SEC_ALLOC | SEC_LOAD
+                                   | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY
+                                   | SEC_READONLY
+                                   | SEC_LINKER_CREATED));
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD
-                                          | SEC_HAS_CONTENTS
-                                          | SEC_IN_MEMORY
-                                          | SEC_READONLY
-                                          | SEC_LINKER_CREATED))
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   elf64_hppa_hash_table (info)->opd_rel_sec = s;
@@ -1810,7 +1802,7 @@ elf64_hppa_size_dynamic_sections (output_bfd, info)
 
       if (strip)
        {
-         _bfd_strip_section_from_output (info, s);
+         s->flags |= SEC_EXCLUDE;
          continue;
        }
 
@@ -1969,7 +1961,7 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
      the original values (in elf64_hppa_link_output_symbol_hook).  */
   if (dyn_h && dyn_h->want_opd)
     {
-      BFD_ASSERT (sopd != NULL)
+      BFD_ASSERT (sopd != NULL);
 
       /* Save away the original value and section index so that we
         can restore them later.  */
@@ -1993,7 +1985,7 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
       Elf_Internal_Rela rel;
       bfd_byte *loc;
 
-      BFD_ASSERT (splt != NULL && spltrel != NULL)
+      BFD_ASSERT (splt != NULL && spltrel != NULL);
 
       /* We do not actually care about the value in the PLT entry
         if we are creating a shared library and the symbol is
@@ -2043,7 +2035,7 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym)
       int insn;
       unsigned int max_offset;
 
-      BFD_ASSERT (stub != NULL)
+      BFD_ASSERT (stub != NULL);
 
       /* Install the generic stub template.
 
@@ -2679,13 +2671,31 @@ elf64_hppa_elf_get_symbol_type (elf_sym, type)
     return type;
 }
 
-static struct bfd_elf_special_section const elf64_hppa_special_sections[]=
+static struct bfd_elf_special_section const elf64_hppa_special_sections[] =
 {
   { ".fini",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { ".init",    5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { NULL,       0, 0, 0,            0 }
 };
 
+static const struct bfd_elf_special_section *
+elf64_hppa_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,
+                                       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.  */
 
 const struct elf_size_info hppa64_elf_size_info =
@@ -2782,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"
 
@@ -2791,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"
This page took 0.029953 seconds and 4 git commands to generate.