OSDN Git Service

bfd/
[pf3gnuchains/pf3gnuchains4x.git] / bfd / elf32-vax.c
index 27bb230..643381c 100644 (file)
@@ -1,6 +1,7 @@
 /* VAX series support for 32-bit ELF
    Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
    Contributed by Matt Thomas <matt@3am-software.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -371,7 +372,7 @@ static const bfd_byte elf_vax_plt0_entry[PLT_ENTRY_SIZE] =
 static const bfd_byte elf_vax_plt_entry[PLT_ENTRY_SIZE] =
 {
   0xfc, 0x0f,          /* .word ^M<r11:r2> */
-  0x16,        0xef,           /* jsb L^(pc) */
+  0x16, 0xef,          /* jsb L^(pc) */
   0, 0, 0, 0,          /* replaced with offset to start of .plt  */
   0, 0, 0, 0,          /* index into .rela.plt */
 };
@@ -407,35 +408,24 @@ struct elf_vax_link_hash_entry
   bfd_vma got_addend;
 };
 
-/* VAX ELF linker hash table.  */
-
-struct elf_vax_link_hash_table
-{
-  struct elf_link_hash_table root;
-};
-
 /* Declare this now that the above structures are defined.  */
 
 static bfd_boolean elf_vax_discard_copies (struct elf_vax_link_hash_entry *,
-                                          PTR);
+                                          void *);
 
 /* Declare this now that the above structures are defined.  */
 
 static bfd_boolean elf_vax_instantiate_got_entries (struct elf_link_hash_entry *,
-                                                   PTR);
+                                                   void *);
 
 /* Traverse an VAX ELF linker hash table.  */
 
 #define elf_vax_link_hash_traverse(table, func, info)                  \
   (elf_link_hash_traverse                                              \
-   (&(table)->root,                                                    \
+   ((table),                                                           \
     (bfd_boolean (*) (struct elf_link_hash_entry *, PTR)) (func),      \
     (info)))
 
-/* Get the VAX ELF linker hash table from a link_info structure.  */
-
-#define elf_vax_hash_table(p) ((struct elf_vax_link_hash_table *) (p)->hash)
-
 /* Create an entry in an VAX ELF linker hash table.  */
 
 static struct bfd_hash_entry *
@@ -472,22 +462,23 @@ elf_vax_link_hash_newfunc (struct bfd_hash_entry *entry,
 static struct bfd_link_hash_table *
 elf_vax_link_hash_table_create (bfd *abfd)
 {
-  struct elf_vax_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct elf_vax_link_hash_table);
+  struct elf_link_hash_table *ret;
+  bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
   ret = bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
 
-  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+  if (!_bfd_elf_link_hash_table_init (ret, abfd,
                                      elf_vax_link_hash_newfunc,
-                                     sizeof (struct elf_vax_link_hash_entry)))
+                                     sizeof (struct elf_vax_link_hash_entry),
+                                     GENERIC_ELF_DATA))
     {
       free (ret);
       return NULL;
     }
 
-  return &ret->root.root;
+  return &ret->root;
 }
 
 /* Keep vax-specific flags in the ELF header */
@@ -504,7 +495,6 @@ elf32_vax_set_private_flags (bfd *abfd, flagword flags)
 static bfd_boolean
 elf32_vax_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  flagword out_flags;
   flagword in_flags;
 
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
@@ -512,7 +502,6 @@ elf32_vax_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
     return TRUE;
 
   in_flags  = elf_elfheader (ibfd)->e_flags;
-  out_flags = elf_elfheader (obfd)->e_flags;
 
   if (!elf_flags_init (obfd))
     {
@@ -1132,7 +1121,7 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
      allocated space for them in the check_relocs routine, but we will not
      fill them in in the relocate_section routine.  */
   if (info->shared && info->symbolic)
-    elf_vax_link_hash_traverse (elf_vax_hash_table (info),
+    elf_vax_link_hash_traverse (elf_hash_table (info),
                                elf_vax_discard_copies,
                                NULL);
 
@@ -1284,9 +1273,6 @@ elf_vax_discard_copies (struct elf_vax_link_hash_entry *h,
 {
   struct elf_vax_pcrel_relocs_copied *s;
 
-  if (h->root.root.type == bfd_link_hash_warning)
-    h = (struct elf_vax_link_hash_entry *) h->root.root.u.i.link;
-
   /* We only discard relocs for symbols defined in a regular object.  */
   if (!h->root.def_regular)
     return TRUE;
@@ -1372,7 +1358,6 @@ elf_vax_relocate_section (bfd *output_bfd,
   bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
-  bfd_vma *local_got_offsets;
   bfd_vma plt_index;
   bfd_vma got_offset;
   asection *sgot;
@@ -1385,7 +1370,6 @@ elf_vax_relocate_section (bfd *output_bfd,
   dynobj = elf_hash_table (info)->dynobj;
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
-  local_got_offsets = elf_local_got_offsets (input_bfd);
 
   sgot = NULL;
   splt = NULL;
@@ -1467,15 +1451,8 @@ elf_vax_relocate_section (bfd *output_bfd,
        }
 
       if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
        continue;
@@ -1583,7 +1560,7 @@ elf_vax_relocate_section (bfd *output_bfd,
          if (sgotplt == NULL)
            {
              sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-             BFD_ASSERT (splt != NULL);
+             BFD_ASSERT (sgotplt != NULL);
            }
 
          plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
@@ -1593,7 +1570,7 @@ elf_vax_relocate_section (bfd *output_bfd,
             The first two are reserved.  */
          got_offset = (plt_index + 3) * 4;
 
-         /* We want the relocate to point into the .got.plt instead
+         /* We want the relocation to point into the .got.plt instead
             of the plt itself.  */
          relocation = (sgotplt->output_section->vma
                        + sgotplt->output_offset
@@ -1625,7 +1602,7 @@ elf_vax_relocate_section (bfd *output_bfd,
        case R_VAX_16:
        case R_VAX_32:
          if (info->shared
-             && r_symndx != 0
+             && r_symndx != STN_UNDEF
              && (input_section->flags & SEC_ALLOC) != 0
              && ((r_type != R_VAX_PC8
                   && r_type != R_VAX_PC16