* configure.ac (ia64*-*-*vms*): Add support for ld.
[deliverable/binutils-gdb.git] / bfd / elf32-m68hc1x.c
index bcc0b87b95a605a3ec57b90d322b5616c6c4e907..e1da8b286cde6af3c76a5670211351b41a24e6ce 100644 (file)
@@ -1,6 +1,6 @@
 /* Motorola 68HC11/HC12-specific support for 32-bit ELF
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -74,7 +74,8 @@ m68hc11_elf_hash_table_create (bfd *abfd)
   memset (ret, 0, amt);
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
                                      _bfd_elf_link_hash_newfunc,
-                                     sizeof (struct elf_link_hash_entry)))
+                                     sizeof (struct elf_link_hash_entry),
+                                     M68HC11_ELF_DATA))
     {
       free (ret);
       return NULL;
@@ -95,7 +96,7 @@ m68hc11_elf_hash_table_create (bfd *abfd)
   ret->stub_bfd = NULL;
   ret->stub_section = 0;
   ret->add_stub_section = NULL;
-  ret->sym_sec.abfd = NULL;
+  ret->sym_cache.abfd = NULL;
 
   return ret;
 }
@@ -213,6 +214,20 @@ elf32_m68hc11_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
   return TRUE;
 }
 
+/* Merge non-visibility st_other attributes, STO_M68HC12_FAR and
+   STO_M68HC12_INTERRUPT.  */
+
+void
+elf32_m68hc11_merge_symbol_attribute (struct elf_link_hash_entry *h,
+                                     const Elf_Internal_Sym *isym,
+                                     bfd_boolean definition,
+                                     bfd_boolean dynamic ATTRIBUTE_UNUSED)
+{
+  if (definition)
+    h->other = ((isym->st_other & ~ELF_ST_VISIBILITY (-1))
+               | ELF_ST_VISIBILITY (h->other));
+}
+
 /* External entry points for sizing and building linker stubs.  */
 
 /* Set up various things so that we can make a list of input sections
@@ -232,6 +247,8 @@ elf32_m68hc11_setup_section_lists (bfd *output_bfd, struct bfd_link_info *info)
   struct m68hc11_elf_link_hash_table *htab;
 
   htab = m68hc11_elf_hash_table (info);
+  if (htab == NULL)
+    return -1;
 
   if (bfd_get_flavour (info->output_bfd) != bfd_target_elf_flavour)
     return 0;
@@ -320,9 +337,11 @@ elf32_m68hc11_size_stubs (bfd *output_bfd, bfd *stub_bfd,
   unsigned int bfd_indx, bfd_count;
   bfd_size_type amt;
   asection *stub_sec;
-
   struct m68hc11_elf_link_hash_table *htab = m68hc11_elf_hash_table (info);
 
+  if (htab == NULL)
+    return FALSE;
+
   /* Stash our params away.  */
   htab->stub_bfd = stub_bfd;
   htab->add_stub_section = add_stub_section;
@@ -331,9 +350,7 @@ elf32_m68hc11_size_stubs (bfd *output_bfd, bfd *stub_bfd,
   for (input_bfd = info->input_bfds, bfd_count = 0;
        input_bfd != NULL;
        input_bfd = input_bfd->link_next)
-    {
-      bfd_count += 1;
-    }
+    bfd_count += 1;
 
   /* We want to read in symbol extension records only once.  To do this
      we need to read in the local symbols in parallel and save them for
@@ -379,7 +396,6 @@ elf32_m68hc11_size_stubs (bfd *output_bfd, bfd *stub_bfd,
        input_bfd = input_bfd->link_next, bfd_indx++)
     {
       Elf_Internal_Shdr *symtab_hdr;
-      Elf_Internal_Sym *local_syms;
       struct elf_link_hash_entry ** sym_hashes;
 
       sym_hashes = elf_sym_hashes (input_bfd);
@@ -568,6 +584,8 @@ m68hc11_elf_export_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
 
   info = (struct bfd_link_info *) in_arg;
   htab = m68hc11_elf_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
 
   /* Massage our args to the form they really have.  */
   stub_entry = (struct elf32_m68hc11_stub_hash_entry *) gen_entry;
@@ -629,6 +647,8 @@ elf32_m68hc11_build_stubs (bfd *abfd, struct bfd_link_info *info)
 
   m68hc11_elf_get_bank_parameters (info);
   htab = m68hc11_elf_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
 
   for (stub_sec = htab->stub_bfd->sections;
        stub_sec != NULL;
@@ -678,8 +698,13 @@ m68hc11_elf_get_bank_parameters (struct bfd_link_info *info)
   unsigned i;
   struct m68hc11_page_info *pinfo;
   struct bfd_link_hash_entry *h;
+  struct m68hc11_elf_link_hash_table *htab;
+
+  htab = m68hc11_elf_hash_table (info);
+  if (htab == NULL)
+    return;
 
-  pinfo = &m68hc11_elf_hash_table (info)->pinfo;
+  pinfo = & htab->pinfo;
   if (pinfo->bank_param_initialized)
     return;
 
@@ -892,16 +917,22 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   const char *name = NULL;
   struct m68hc11_page_info *pinfo;
   const struct elf_backend_data * const ebd = get_elf_backend_data (input_bfd);
+  struct m68hc11_elf_link_hash_table *htab;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
+  htab = m68hc11_elf_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
+
   /* Get memory bank parameters.  */
   m68hc11_elf_get_bank_parameters (info);
-  pinfo = &m68hc11_elf_hash_table (info)->pinfo;
 
+  pinfo = & htab->pinfo;
   rel = relocs;
   relend = relocs + input_section->reloc_count;
+
   for (; rel < relend; rel++)
     {
       int r_type;
@@ -918,7 +949,6 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
       bfd_vma insn_page;
       bfd_boolean is_far = FALSE;
       struct elf_link_hash_entry *h;
-      const char* stub_name = 0;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -941,10 +971,6 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                        + sec->output_offset
                        + sym->st_value);
          is_far = (sym && (sym->st_other & STO_M68HC12_FAR));
-         if (is_far)
-           stub_name = (bfd_elf_string_from_elf_section
-                        (input_bfd, symtab_hdr->sh_link,
-                         sym->st_name));
        }
       else
        {
@@ -956,19 +982,11 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                                   warned);
 
          is_far = (h && (h->other & STO_M68HC12_FAR));
-         stub_name = h->root.root.string;
        }
 
       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)
        {
@@ -994,9 +1012,7 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
       if (is_far && ELF32_R_TYPE (rel->r_info) == R_M68HC11_16)
        {
          struct elf32_m68hc11_stub_hash_entry* stub;
-         struct m68hc11_elf_link_hash_table *htab;
 
-         htab = m68hc11_elf_hash_table (info);
          stub = m68hc12_stub_hash_lookup (htab->stub_hash_table,
                                           name, FALSE, FALSE);
          if (stub)
@@ -1186,7 +1202,7 @@ _bfd_m68hc11_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   flagword new_flags;
   bfd_boolean ok = TRUE;
 
-  /* Check if we have the same endianess */
+  /* Check if we have the same endianness */
   if (!_bfd_generic_verify_endian_match (ibfd, obfd))
     return FALSE;
 
@@ -1321,15 +1337,22 @@ void
 elf32_m68hc11_post_process_headers (bfd *abfd, struct bfd_link_info *link_info)
 {
   struct m68hc11_scan_param param;
+  struct m68hc11_elf_link_hash_table *htab;
+
+  if (link_info == NULL)
+    return;
 
-  if (link_info == 0)
+  htab = m68hc11_elf_hash_table (link_info);
+  if (htab == NULL)
     return;
 
   m68hc11_elf_get_bank_parameters (link_info);
 
   param.use_memory_banks = FALSE;
-  param.pinfo = &m68hc11_elf_hash_table (link_info)->pinfo;
+  param.pinfo = & htab->pinfo;
+
   bfd_map_over_sections (abfd, scan_sections_for_abi, &param);
+
   if (param.use_memory_banks)
     {
       Elf_Internal_Ehdr * i_ehdrp;
@@ -1338,4 +1361,3 @@ elf32_m68hc11_post_process_headers (bfd *abfd, struct bfd_link_info *link_info)
       i_ehdrp->e_flags |= E_M68HC12_BANKS;
     }
 }
-
This page took 0.034032 seconds and 4 git commands to generate.