* elflink.c (_bfd_elf_gc_mark_hook): New function.
[deliverable/binutils-gdb.git] / bfd / elf32-score.c
index c84763aa28b261f0bd18259254d5b3620a0923b6..60a1a200274850bca19402cc9237fad76fb59708 100644 (file)
@@ -2308,9 +2308,13 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
         {
           sym = local_syms + r_symndx;
           sec = local_sections[r_symndx];
-          relocation = (sec->output_section->vma + sec->output_offset + sym->st_value);
+          relocation = (sec->output_section->vma
+                       + sec->output_offset
+                       + sym->st_value);
+          name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec);
 
-          if ((sec->flags & SEC_MERGE) && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+          if ((sec->flags & SEC_MERGE)
+             && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
             {
               asection *msec;
               bfd_vma addend, value;
@@ -2432,13 +2436,6 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
            }
         }
 
-      if (h == NULL)
-        {
-          name = (bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name));
-          if (name == NULL || *name == '\0')
-            name = bfd_section_name (input_bfd, sec);
-        }
-
       r = score_elf_final_link_relocate (howto, input_bfd, output_bfd,
                                          input_section, contents, rel, relocs,
                                          relocation, info, sec, name,
@@ -3619,40 +3616,25 @@ _bfd_score_elf_ignore_discarded_relocs (asection *sec)
   return FALSE;
 }
 
-/* This function discover the section a particular relocation refers to.
-   Return the section that should be marked against GC for a given relocation.  */
+/* Return the section that should be marked against GC for a given
+   relocation.  */
 
 static asection *
 _bfd_score_elf_gc_mark_hook (asection *sec,
-                            struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                            struct bfd_link_info *info,
                             Elf_Internal_Rela *rel,
                             struct elf_link_hash_entry *h,
                             Elf_Internal_Sym *sym)
 {
   if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-        {
-        case R_SCORE_GNU_VTINHERIT:
-        case R_SCORE_GNU_VTENTRY:
-          break;
-        default:
-          switch (h->root.type)
-            {
-            case bfd_link_hash_defined:
-            case bfd_link_hash_defweak:
-              return h->root.u.def.section;
-            case bfd_link_hash_common:
-              return h->root.u.c.p->section;
-            default:
-              break;
-            }
-        }
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_SCORE_GNU_VTINHERIT:
+      case R_SCORE_GNU_VTENTRY:
+       return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Support for core dump NOTE sections.  */
This page took 0.025764 seconds and 4 git commands to generate.