* fbsd-proc.c: Include "regcache.h", "regset.h" and
[deliverable/binutils-gdb.git] / bfd / elf32-m68hc1x.c
index 709b8f45edc5f59429e4a37ff2eae4b79d188822..2a139a405c26413551141ded6c40cd39b1ed3a8e 100644 (file)
@@ -1,5 +1,6 @@
 /* Motorola 68HC11/HC12-specific support for 32-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -47,16 +48,6 @@ static void m68hc11_elf_set_symbol (bfd* abfd, struct bfd_link_info *info,
 static bfd_boolean m68hc11_elf_export_one_stub
   (struct bfd_hash_entry *gen_entry, void *in_arg);
 
-static bfd_boolean m68hc11_get_relocation_value
-  (bfd* abfd,
-   struct bfd_link_info* info,
-   asection **local_sections,
-   Elf_Internal_Sym* local_syms,
-   Elf_Internal_Rela* rel,
-   const char** name,
-   bfd_vma* relocation,
-   bfd_boolean* is_far);
-
 static void scan_sections_for_abi (bfd*, asection*, PTR);
 
 struct m68hc11_scan_param
@@ -190,7 +181,7 @@ m68hc12_add_stub (const char *stub_name, asection *section,
 
 bfd_boolean
 elf32_m68hc11_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
-                               const Elf_Internal_Sym *sym,
+                               Elf_Internal_Sym *sym,
                                const char **namep ATTRIBUTE_UNUSED,
                                flagword *flagsp ATTRIBUTE_UNUSED,
                                asection **secp ATTRIBUTE_UNUSED,
@@ -902,14 +893,14 @@ elf32_m68hc11_check_relocs (bfd *abfd, struct bfd_link_info *info,
         /* This relocation describes the C++ object vtable hierarchy.
            Reconstruct it for later use during GC.  */
         case R_M68HC11_GNU_VTINHERIT:
-          if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+          if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
             return FALSE;
           break;
 
         /* This relocation describes which C++ vtable entries are actually
            used.  Record for later use during GC.  */
         case R_M68HC11_GNU_VTENTRY:
-          if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
             return FALSE;
           break;
         }
@@ -919,7 +910,8 @@ elf32_m68hc11_check_relocs (bfd *abfd, struct bfd_link_info *info,
 }
 
 static bfd_boolean
-m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
+m68hc11_get_relocation_value (bfd *input_bfd, struct bfd_link_info *info,
+                             asection *input_section,
                               asection **local_sections,
                               Elf_Internal_Sym *local_syms,
                               Elf_Internal_Rela *rel,
@@ -934,8 +926,8 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
   Elf_Internal_Sym *sym;
   const char* stub_name = 0;
 
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
 
   r_symndx = ELF32_R_SYM (rel->r_info);
 
@@ -953,33 +945,17 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
       *is_far = (sym && (sym->st_other & STO_M68HC12_FAR));
       if (*is_far)
         stub_name = (bfd_elf_string_from_elf_section
-                     (abfd, symtab_hdr->sh_link,
+                     (input_bfd, symtab_hdr->sh_link,
                       sym->st_name));
     }
   else
     {
-      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-      while (h->root.type == bfd_link_hash_indirect
-             || h->root.type == bfd_link_hash_warning)
-        h = (struct elf_link_hash_entry *) h->root.u.i.link;
-      if (h->root.type == bfd_link_hash_defined
-          || h->root.type == bfd_link_hash_defweak)
-        {
-          sec = h->root.u.def.section;
-          *relocation = (h->root.u.def.value
-                         + sec->output_section->vma
-                         + sec->output_offset);
-        }
-      else if (h->root.type == bfd_link_hash_undefweak)
-        *relocation = 0;
-      else
-        {
-          if (!((*info->callbacks->undefined_symbol)
-                (info, h->root.root.string, abfd,
-                 sec, rel->r_offset, TRUE)))
-            return FALSE;
-          *relocation = 0;
-        }
+      bfd_boolean unresolved_reloc, warned;
+
+      RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+                              r_symndx, symtab_hdr, sym_hashes,
+                              h, sec, *relocation, unresolved_reloc, warned);
+
       *is_far = (h && (h->other & STO_M68HC12_FAR));
       stub_name = h->root.root.string;
     }
@@ -989,7 +965,7 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
   else
     {
       *name = (bfd_elf_string_from_elf_section
-               (abfd, symtab_hdr->sh_link, sym->st_name));
+               (input_bfd, symtab_hdr->sh_link, sym->st_name));
       if (*name == NULL || **name == '\0')
         *name = bfd_section_name (input_bfd, sec);
     }
@@ -1082,8 +1058,8 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
       (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel);
       howto = arel.howto;
 
-      m68hc11_get_relocation_value (input_bfd, info,
-                                    local_sections, local_syms,
+      m68hc11_get_relocation_value (input_bfd, info, input_section, 
+                                   local_sections, local_syms,
                                     rel, &name, &relocation, &is_far);
 
       /* Do the memory bank mapping.  */
This page took 0.024904 seconds and 4 git commands to generate.