This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

elf_gc_mark and elf_gc_sweep cleanup


This patch defines a default _bfd_elf_gc_mark_hook, which can be used
directly by many targets.  Most others just need to handle their
GNU_VTINHERIT and GNU_VTENTRY relocs, then call the default.  I've also
removed all the do-nothing backend gc_sweep_hook functions.

	* elflink.c (_bfd_elf_gc_mark_hook): New function.
	* elf-bfd.h (_bfd_elf_gc_mark_hook): Declare.
	* elfxx-target.h (elf_backend_gc_mark_hook): Default to above.
	* elf-m10300.c (mn10300_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	* elf32-arm.c (elf32_arm_gc_mark_hook): Likewise.
	* elf32-cris.c (cris_elf_gc_mark_hook): Likewise.
	* elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise.
	* elf32-i386.c (elf_i386_gc_mark_hook): Likewise.
	* elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise.
	* elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise.
	* elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise.
	* elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise.
	* elf32-s390.c (elf_s390_gc_mark_hook): Likewise.
	* elf32-score.c (_bfd_score_elf_gc_mark_hook): Likewise.
	* elf32-sh.c (sh_elf_gc_mark_hook): Likewise.
	* elf32-vax.c (elf_vax_gc_mark_hook): Likewise.
	* elf32-xtensa.c (elf_xtensa_gc_mark_hook): Likewise.
	* elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise.
	* elf64-s390.c (elf_s390_gc_mark_hook): Likewise.
	* elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
	* elf32-bfin.c (bfin_gc_mark_hook): Likewise.
	(bfinfdpic_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define for elf32-bfinfdpic.
	* elf32-d10v.c (elf32_d10v_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(elf32_d10v_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-fr30.c (fr30_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(fr30_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-frv.c (elf32_frv_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(elf32_frv_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-iq2000.c (iq2000_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(iq2000_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-openrisc.c (openrisc_elf_gc_mark_hook): Use
	_bfd_elf_gc_mark_hook.
	(openrisc_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-v850.c (v850_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(v850_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Use
	_bfd_elf_gc_mark_hook.
	(xstormy16_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf64-sh64.c (sh_elf64_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
	(sh_elf64_gc_sweep_hook): Delete.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-avr.c (elf32_avr_gc_mark_hook): Delete.
	(elf32_avr_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-cr16c.c (elf32_cr16c_gc_mark_hook): Delete.
	(elf32_cr16c_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-crx.c (elf32_crx_gc_mark_hook): Delete.
	(elf32_crx_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-h8300.c (elf32_h8_gc_mark_hook): Delete.
	(elf32_h8_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-ip2k.c (ip2k_elf_gc_mark_hook): Delete.
	(ip2k_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-m32c.c (m32c_elf_gc_mark_hook, m32c_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-m68hc11.c (elf_backend_gc_mark_hook): Don't define.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-m68hc12.c (elf_backend_gc_mark_hook): Don't define.
	(elf_backend_gc_sweep_hook): Don't define.
	* elf32-m68hc1x.c (elf32_m68hc11_gc_mark_hook): Delete.
	(elf32_m68hc11_gc_sweep_hook): Delete.
	* elf32-m68hc1x.h (elf32_m68hc11_gc_mark_hook): Delete.
	(elf32_m68hc11_gc_sweep_hook): Delete.
	* elf32-msp430.c (elf32_msp430_gc_mark_hook): Delete.
	(elf32_msp430_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
	* elf32-mt.c (mt_elf_gc_mark_hook, mt_elf_gc_sweep_hook): Delete.
	(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.213
diff -u -p -r1.213 elf-bfd.h
--- bfd/elf-bfd.h	22 Sep 2006 13:16:45 -0000	1.213
+++ bfd/elf-bfd.h	28 Sep 2006 07:40:28 -0000
@@ -1867,6 +1867,10 @@ extern bfd_boolean bfd_elf_gc_record_vti
 extern bfd_boolean bfd_elf_gc_record_vtentry
   (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
 
+extern asection *_bfd_elf_gc_mark_hook
+  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
+   struct elf_link_hash_entry *, Elf_Internal_Sym *);
+
 extern bfd_boolean _bfd_elf_gc_mark
   (struct bfd_link_info *, asection *,
    asection * (*) (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.230
diff -u -p -r1.230 elflink.c
--- bfd/elflink.c	16 Sep 2006 18:12:14 -0000	1.230
+++ bfd/elflink.c	28 Sep 2006 07:41:32 -0000
@@ -9248,14 +9248,44 @@ bfd_elf_final_link (bfd *abfd, struct bf
 
 /* Garbage collect unused sections.  */
 
-/* The mark phase of garbage collection.  For a given section, mark
-   it and any sections in this section's group, and all the sections
-   which define symbols to which it refers.  */
-
 typedef asection * (*gc_mark_hook_fn)
   (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
    struct elf_link_hash_entry *, Elf_Internal_Sym *);
 
+/* Default gc_mark_hook.  */
+
+asection *
+_bfd_elf_gc_mark_hook (asection *sec,
+		       struct bfd_link_info *info ATTRIBUTE_UNUSED,
+		       Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
+		       struct elf_link_hash_entry *h,
+		       Elf_Internal_Sym *sym)
+{
+  if (h != NULL)
+    {
+      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);
+
+  return NULL;
+}
+
+/* The mark phase of garbage collection.  For a given section, mark
+   it and any sections in this section's group, and all the sections
+   which define symbols to which it refers.  */
+
 bfd_boolean
 _bfd_elf_gc_mark (struct bfd_link_info *info,
 		  asection *sec,
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.97
diff -u -p -r1.97 elfxx-target.h
--- bfd/elfxx-target.h	10 Jul 2006 21:40:23 -0000	1.97
+++ bfd/elfxx-target.h	28 Sep 2006 07:41:43 -0000
@@ -131,7 +131,7 @@
 #define elf_backend_gc_mark_dynamic_ref	bfd_elf_gc_mark_dynamic_ref_symbol
 #endif
 #ifndef elf_backend_gc_mark_hook
-#define elf_backend_gc_mark_hook	NULL
+#define elf_backend_gc_mark_hook	_bfd_elf_gc_mark_hook
 #endif
 #ifndef elf_backend_gc_sweep_hook
 #define elf_backend_gc_sweep_hook	NULL
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.75
diff -u -p -r1.75 elf-m10300.c
--- bfd/elf-m10300.c	16 Sep 2006 18:12:13 -0000	1.75
+++ bfd/elf-m10300.c	28 Sep 2006 07:40:31 -0000
@@ -134,9 +134,6 @@ static void mn10300_info_to_howto
 static bfd_boolean mn10300_elf_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
-static asection *mn10300_elf_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *info, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
 static bfd_boolean mn10300_elf_relax_delete_bytes
   PARAMS ((bfd *, asection *, bfd_vma, int));
 static bfd_boolean mn10300_elf_symbol_address_p
@@ -922,40 +919,21 @@ mn10300_elf_check_relocs (abfd, info, se
    relocation.  */
 
 static asection *
-mn10300_elf_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+mn10300_elf_gc_mark_hook (asection *sec,
+			  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_MN10300_GNU_VTINHERIT:
-	case R_MN10300_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_MN10300_GNU_VTINHERIT:
+      case R_MN10300_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Perform a relocation as part of a final link.  */
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.91
diff -u -p -r1.91 elf32-arm.c
--- bfd/elf32-arm.c	22 Sep 2006 13:16:45 -0000	1.91
+++ bfd/elf32-arm.c	28 Sep 2006 07:40:36 -0000
@@ -6689,39 +6689,21 @@ elf32_arm_get_symbol_type (Elf_Internal_
 }
 
 static asection *
-elf32_arm_gc_mark_hook (asection *                   sec,
-			struct bfd_link_info *       info ATTRIBUTE_UNUSED,
-			Elf_Internal_Rela *          rel,
-			struct elf_link_hash_entry * h,
-			Elf_Internal_Sym *           sym)
+elf32_arm_gc_mark_hook (asection *sec,
+			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))
+    switch (ELF32_R_TYPE (rel->r_info))
       {
       case R_ARM_GNU_VTINHERIT:
       case R_ARM_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);
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elf32-avr.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-avr.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf32-avr.c
--- bfd/elf32-avr.c	24 May 2006 07:36:09 -0000	1.26
+++ bfd/elf32-avr.c	28 Sep 2006 07:40:37 -0000
@@ -688,48 +688,6 @@ avr_info_to_howto_rela (bfd *abfd ATTRIB
   cache_ptr->howto = &elf_avr_howto_table[r_type];
 }
 
-static asection *
-elf32_avr_gc_mark_hook (asection *sec,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			Elf_Internal_Rela *rel,
-			struct elf_link_hash_entry *h,
-			Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	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);
-
-  return NULL;
-}
-
-static bfd_boolean
-elf32_avr_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			 asection *sec ATTRIBUTE_UNUSED,
-			 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't use got and plt entries for avr.  */
-  return TRUE;
-}
-
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
@@ -2951,8 +2909,6 @@ elf32_avr_build_stubs (struct bfd_link_i
 #define elf_info_to_howto	             avr_info_to_howto_rela
 #define elf_info_to_howto_rel	             NULL
 #define elf_backend_relocate_section         elf32_avr_relocate_section
-#define elf_backend_gc_mark_hook             elf32_avr_gc_mark_hook
-#define elf_backend_gc_sweep_hook            elf32_avr_gc_sweep_hook
 #define elf_backend_check_relocs             elf32_avr_check_relocs
 #define elf_backend_can_gc_sections          1
 #define elf_backend_rela_normal		     1
Index: bfd/elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.16
diff -u -p -r1.16 elf32-bfin.c
--- bfd/elf32-bfin.c	16 Sep 2006 18:12:13 -0000	1.16
+++ bfd/elf32-bfin.c	28 Sep 2006 07:40:41 -0000
@@ -3106,51 +3106,20 @@ bfin_relocate_section (bfd * output_bfd,
 
 static asection *
 bfin_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_BFIN_GNU_VTINHERIT:
-	case R_BFIN_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    default:
-	      break;
-
-	    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;
-	    }
-	}
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  return NULL;
-}
-
-
-/* Update the got entry reference counts for the section being removed.  */
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_BFIN_GNU_VTINHERIT:
+      case R_BFIN_GNU_VTENTRY:
+	return NULL;
+      }
 
-static bfd_boolean
-bfinfdpic_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			 asection *sec ATTRIBUTE_UNUSED,
-			 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
@@ -5564,7 +5533,6 @@ error_return:
 #define	elf32_bed		elf32_bfinfdpic_bed
 
 #undef elf_backend_gc_sweep_hook
-#define elf_backend_gc_sweep_hook       bfinfdpic_gc_sweep_hook
 
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size     0
Index: bfd/elf32-cr16c.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cr16c.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-cr16c.c
--- bfd/elf32-cr16c.c	4 May 2005 15:53:12 -0000	1.7
+++ bfd/elf32-cr16c.c	28 Sep 2006 07:40:41 -0000
@@ -798,53 +798,6 @@ elf32_cr16c_relocate_section (bfd *outpu
   return TRUE;
 }
 
-static asection *
-elf32_cr16c_gc_mark_hook (asection *sec,
-			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			  Elf_Internal_Rela *rel,
-			  struct elf_link_hash_entry *h,
-			  Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-
-	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);
-    }
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-elf32_cr16c_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			   struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			   asection *sec ATTRIBUTE_UNUSED,
-			   const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't support garbage collection of GOT and PLT relocs yet.  */
-  return TRUE;
-}
-
 /* CR16C ELF uses three common sections:
    One is for default common symbols (placed in usual common section).
    Second is for near common symbols (placed in "ncommon" section).
@@ -991,8 +944,6 @@ elf32_cr16c_link_output_symbol_hook (str
 #define elf_info_to_howto			elf_cr16c_info_to_howto
 #define elf_info_to_howto_rel			elf_cr16c_info_to_howto_rel
 #define elf_backend_relocate_section		elf32_cr16c_relocate_section
-#define elf_backend_gc_mark_hook        	elf32_cr16c_gc_mark_hook
-#define elf_backend_gc_sweep_hook       	elf32_cr16c_gc_sweep_hook
 #define elf_backend_symbol_processing		elf32_cr16c_symbol_processing
 #define elf_backend_section_from_bfd_section 	elf32_cr16c_section_from_bfd_section
 #define elf_backend_add_symbol_hook		elf32_cr16c_add_symbol_hook
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.74
diff -u -p -r1.74 elf32-cris.c
--- bfd/elf32-cris.c	16 Sep 2006 18:12:13 -0000	1.74
+++ bfd/elf32-cris.c	28 Sep 2006 07:40:43 -0000
@@ -51,14 +51,6 @@ static bfd_reloc_status_type cris_final_
   PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, bfd_vma));
 
-static bfd_boolean cris_elf_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-
-static asection * cris_elf_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-
 static bfd_boolean cris_elf_object_p PARAMS ((bfd *));
 
 static void cris_elf_final_write_processing PARAMS ((bfd *, bfd_boolean));
@@ -1923,50 +1915,30 @@ elf_cris_finish_dynamic_sections (output
    relocation.  */
 
 static asection *
-cris_elf_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+cris_elf_gc_mark_hook (asection *sec,
+		       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_CRIS_GNU_VTINHERIT:
-	case R_CRIS_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_CRIS_GNU_VTINHERIT:
+      case R_CRIS_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
-cris_elf_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
+cris_elf_gc_sweep_hook (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
Index: bfd/elf32-crx.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-crx.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-crx.c
--- bfd/elf32-crx.c	4 May 2005 15:53:12 -0000	1.7
+++ bfd/elf32-crx.c	28 Sep 2006 07:40:43 -0000
@@ -38,12 +38,6 @@ static bfd_reloc_status_type crx_elf_fin
 static bfd_boolean elf32_crx_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
-static asection * elf32_crx_gc_mark_hook
-  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-   struct elf_link_hash_entry *, Elf_Internal_Sym *);
-static bfd_boolean elf32_crx_gc_sweep_hook
-  (bfd *, struct bfd_link_info *, asection *,
-   const Elf_Internal_Rela *);
 static bfd_boolean elf32_crx_relax_section
   (bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
 static bfd_byte * elf32_crx_get_relocated_section_contents
@@ -1297,42 +1291,6 @@ elf32_crx_relax_section (bfd *abfd, asec
   return FALSE;
 }
 
-static asection *
-elf32_crx_gc_mark_hook (asection *sec,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
-			struct elf_link_hash_entry *h,
-			Elf_Internal_Sym *sym)
-{
-  if (h == NULL)
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  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:
-      return NULL;
-    }
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-elf32_crx_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			 asection *sec ATTRIBUTE_UNUSED,
-			 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't support garbage collection of GOT and PLT relocs yet.  */
-  return TRUE;
-}
-
 /* Definitions for setting CRX target vector.  */
 #define TARGET_LITTLE_SYM		bfd_elf32_crx_vec
 #define TARGET_LITTLE_NAME		"elf32-crx"
@@ -1348,8 +1306,6 @@ elf32_crx_gc_sweep_hook (bfd *abfd ATTRI
 #define bfd_elf32_bfd_relax_section	elf32_crx_relax_section
 #define bfd_elf32_bfd_get_relocated_section_contents \
 				elf32_crx_get_relocated_section_contents
-#define elf_backend_gc_mark_hook        elf32_crx_gc_mark_hook
-#define elf_backend_gc_sweep_hook       elf32_crx_gc_sweep_hook
 #define elf_backend_can_gc_sections     1
 #define elf_backend_rela_normal		1
 
Index: bfd/elf32-d10v.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-d10v.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf32-d10v.c
--- bfd/elf32-d10v.c	8 Dec 2005 11:05:36 -0000	1.30
+++ bfd/elf32-d10v.c	28 Sep 2006 07:40:43 -0000
@@ -219,48 +219,20 @@ d10v_info_to_howto_rel (bfd *abfd ATTRIB
 
 static asection *
 elf32_d10v_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))
+    switch (ELF32_R_TYPE (rel->r_info))
       {
       case R_D10V_GNU_VTINHERIT:
       case R_D10V_GNU_VTENTRY:
-        break;
+	return NULL;
+      }
 
-      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);
-
-  return NULL;
-}
-
-static bfd_boolean
-elf32_d10v_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			  asection *sec ATTRIBUTE_UNUSED,
-			  const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't use got and plt entries for d10v.  */
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Look through the relocs for a section during the first phase.
@@ -573,7 +545,6 @@ elf32_d10v_relocate_section (bfd *output
 #define elf_backend_object_p	             0
 #define elf_backend_final_write_processing   0
 #define elf_backend_gc_mark_hook             elf32_d10v_gc_mark_hook
-#define elf_backend_gc_sweep_hook            elf32_d10v_gc_sweep_hook
 #define elf_backend_check_relocs             elf32_d10v_check_relocs
 #define elf_backend_relocate_section         elf32_d10v_relocate_section
 #define elf_backend_can_gc_sections          1
Index: bfd/elf32-fr30.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-fr30.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf32-fr30.c
--- bfd/elf32-fr30.c	20 Jun 2005 18:12:06 -0000	1.30
+++ bfd/elf32-fr30.c	28 Sep 2006 07:40:44 -0000
@@ -39,12 +39,6 @@ static bfd_boolean fr30_elf_relocate_sec
 static bfd_reloc_status_type fr30_final_link_relocate
   PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, bfd_vma));
-static bfd_boolean fr30_elf_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static asection * fr30_elf_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
 static bfd_boolean fr30_elf_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
@@ -624,52 +618,21 @@ fr30_elf_relocate_section (output_bfd, i
    relocation.  */
 
 static asection *
-fr30_elf_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym * sym;
+fr30_elf_gc_mark_hook (asection *sec,
+		       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_FR30_GNU_VTINHERIT:
-	case R_FR30_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);
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_FR30_GNU_VTINHERIT:
+      case R_FR30_GNU_VTENTRY:
+	return NULL;
+      }
 
-static bfd_boolean
-fr30_elf_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
-{
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Look through the relocs for a section during the first phase.
@@ -747,7 +710,6 @@ fr30_elf_check_relocs (abfd, info, sec, 
 #define elf_info_to_howto			fr30_info_to_howto_rela
 #define elf_backend_relocate_section		fr30_elf_relocate_section
 #define elf_backend_gc_mark_hook		fr30_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		fr30_elf_gc_sweep_hook
 #define elf_backend_check_relocs                fr30_elf_check_relocs
 
 #define elf_backend_can_gc_sections		1
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.48
diff -u -p -r1.48 elf32-frv.c
--- bfd/elf32-frv.c	20 Jun 2006 14:34:08 -0000	1.48
+++ bfd/elf32-frv.c	28 Sep 2006 07:40:46 -0000
@@ -57,12 +57,6 @@ static bfd_boolean elf32_frv_add_symbol_
 static bfd_reloc_status_type frv_final_link_relocate
   PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, bfd_vma));
-static bfd_boolean elf32_frv_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *, const
-	   Elf_Internal_Rela *));
-static asection * elf32_frv_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
 static bfd_boolean elf32_frv_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
@@ -4145,54 +4139,22 @@ elf32_frv_relocate_section (output_bfd, 
    relocation.  */
 
 static asection *
-elf32_frv_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf32_frv_gc_mark_hook (asection *sec,
+			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_FRV_GNU_VTINHERIT:
-	case R_FRV_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    default:
-	      break;
-
-	    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;
-	    }
-	}
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_FRV_GNU_VTINHERIT:
+      case R_FRV_GNU_VTENTRY:
+	return NULL;
+      }
 
-static bfd_boolean
-elf32_frv_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
-{
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
-
 
 /* Hook called by the linker routine which adds symbols from an object
    file.  We use it to put .comm items in .scomm, and not .comm.  */
@@ -6911,7 +6873,6 @@ elf32_frv_grok_psinfo (bfd *abfd, Elf_In
 #define elf_info_to_howto			frv_info_to_howto_rela
 #define elf_backend_relocate_section		elf32_frv_relocate_section
 #define elf_backend_gc_mark_hook		elf32_frv_gc_mark_hook
-#define elf_backend_gc_sweep_hook		elf32_frv_gc_sweep_hook
 #define elf_backend_check_relocs                elf32_frv_check_relocs
 #define elf_backend_object_p			elf32_frv_object_p
 #define elf_backend_add_symbol_hook             elf32_frv_add_symbol_hook
Index: bfd/elf32-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-h8300.c,v
retrieving revision 1.48
diff -u -p -r1.48 elf32-h8300.c
--- bfd/elf32-h8300.c	4 May 2005 15:53:13 -0000	1.48
+++ bfd/elf32-h8300.c	28 Sep 2006 07:40:48 -0000
@@ -42,11 +42,6 @@ static bfd_boolean elf32_h8_symbol_addre
 static bfd_byte *elf32_h8_get_relocated_section_contents
   (bfd *, struct bfd_link_info *, struct bfd_link_order *,
    bfd_byte *, bfd_boolean, asymbol **);
-static asection *elf32_h8_gc_mark_hook
-  (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-   struct elf_link_hash_entry *, Elf_Internal_Sym *);
-static bfd_boolean elf32_h8_gc_sweep_hook
-  (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
 static bfd_reloc_status_type elf32_h8_final_link_relocate
   (unsigned long, bfd *, bfd *, asection *,
    bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
@@ -1490,42 +1485,6 @@ elf32_h8_get_relocated_section_contents 
   return NULL;
 }
 
-static asection *
-elf32_h8_gc_mark_hook (asection *sec,
-		       struct bfd_link_info *info ATTRIBUTE_UNUSED,
-		       Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
-		       struct elf_link_hash_entry *h,
-		       Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    {
-      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);
-  return NULL;
-}
-
-static bfd_boolean
-elf32_h8_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			asection *sec ATTRIBUTE_UNUSED,
-			const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 
 #define TARGET_BIG_SYM			bfd_elf32_h8300_vec
 #define TARGET_BIG_NAME			"elf32-h8300"
@@ -1544,8 +1503,6 @@ elf32_h8_gc_sweep_hook (bfd *abfd ATTRIB
   elf32_h8_object_p
 #define bfd_elf32_bfd_merge_private_bfd_data \
   elf32_h8_merge_private_bfd_data
-#define elf_backend_gc_mark_hook        elf32_h8_gc_mark_hook
-#define elf_backend_gc_sweep_hook       elf32_h8_gc_sweep_hook
 
 /* ??? when elf_backend_relocate_section is not defined, elf32-target.h
    defaults to using _bfd_generic_link_hash_table_create, but
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.146
diff -u -p -r1.146 elf32-hppa.c
--- bfd/elf32-hppa.c	16 Sep 2006 18:12:13 -0000	1.146
+++ bfd/elf32-hppa.c	28 Sep 2006 07:40:50 -0000
@@ -1588,38 +1588,20 @@ elf32_hppa_check_relocs (bfd *abfd,
 
 static asection *
 elf32_hppa_gc_mark_hook (asection *sec,
-			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 struct bfd_link_info *info,
 			 Elf_Internal_Rela *rela,
 			 struct elf_link_hash_entry *hh,
 			 Elf_Internal_Sym *sym)
 {
   if (hh != NULL)
-    {
-      switch ((unsigned int) ELF32_R_TYPE (rela->r_info))
-	{
-	case R_PARISC_GNU_VTINHERIT:
-	case R_PARISC_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (hh->root.type)
-	    {
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      return hh->root.u.def.section;
-
-	    case bfd_link_hash_common:
-	      return hh->root.u.c.p->section;
-
-	    default:
-	      break;
-	    }
-	}
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+    switch ((unsigned int) ELF32_R_TYPE (rela->r_info))
+      {
+      case R_PARISC_GNU_VTINHERIT:
+      case R_PARISC_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rela, hh, sym);
 }
 
 /* Update the got and plt entry reference counts for the section being
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.165
diff -u -p -r1.165 elf32-i386.c
--- bfd/elf32-i386.c	16 Sep 2006 18:12:13 -0000	1.165
+++ bfd/elf32-i386.c	28 Sep 2006 07:40:52 -0000
@@ -1279,38 +1279,20 @@ elf_i386_check_relocs (bfd *abfd,
 
 static asection *
 elf_i386_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_386_GNU_VTINHERIT:
-	case R_386_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_386_GNU_VTINHERIT:
+      case R_386_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elf32-ip2k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ip2k.c,v
retrieving revision 1.20
diff -u -p -r1.20 elf32-ip2k.c
--- bfd/elf32-ip2k.c	1 Jul 2005 11:16:29 -0000	1.20
+++ bfd/elf32-ip2k.c	28 Sep 2006 07:40:53 -0000
@@ -1502,53 +1502,6 @@ ip2k_elf_relocate_section (bfd *output_b
   return TRUE;
 }
 
-static asection *
-ip2k_elf_gc_mark_hook (asection *sec,
-		       struct bfd_link_info *info ATTRIBUTE_UNUSED,
-		       Elf_Internal_Rela *rel,
-		       struct elf_link_hash_entry *h,
-		       Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-      {
-      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
-     {
-       if (!(elf_bad_symtab (sec->owner)
-	     && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
-	   && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
-		 && sym->st_shndx != SHN_COMMON))
-	 return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-      }
-  return NULL;
-}
-
-static bfd_boolean
-ip2k_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			asection *sec ATTRIBUTE_UNUSED,
-			const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't use got and plt entries for ip2k.  */
-  return TRUE;
-}
-
 #define TARGET_BIG_SYM	 bfd_elf32_ip2k_vec
 #define TARGET_BIG_NAME  "elf32-ip2k"
 
@@ -1562,8 +1515,6 @@ ip2k_elf_gc_sweep_hook (bfd *abfd ATTRIB
 
 #define elf_backend_can_gc_sections     	1
 #define elf_backend_rela_normal			1
-#define elf_backend_gc_mark_hook                ip2k_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook               ip2k_elf_gc_sweep_hook
 #define elf_backend_relocate_section		ip2k_elf_relocate_section
 
 #define elf_symbol_leading_char			'_'
Index: bfd/elf32-iq2000.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-iq2000.c,v
retrieving revision 1.16
diff -u -p -r1.16 elf32-iq2000.c
--- bfd/elf32-iq2000.c	16 Sep 2006 18:12:13 -0000	1.16
+++ bfd/elf32-iq2000.c	28 Sep 2006 07:40:53 -0000
@@ -642,53 +642,25 @@ iq2000_elf_relocate_section (bfd *		    
 }
 
 
-/* Update the got entry reference counts for the section being
-   removed.  */
-
-static bfd_boolean
-iq2000_elf_gc_sweep_hook (bfd *		            abfd ATTRIBUTE_UNUSED,
-			  struct bfd_link_info *    info ATTRIBUTE_UNUSED,
-			  asection *		    sec ATTRIBUTE_UNUSED,
-			  const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 /* Return the section that should be marked against GC for a given
    relocation.	*/
 
 static asection *
-iq2000_elf_gc_mark_hook (asection *		      sec,
-			 struct bfd_link_info *	      info ATTRIBUTE_UNUSED,
-			 Elf_Internal_Rela *	      rel,
-			 struct elf_link_hash_entry * h,
-			 Elf_Internal_Sym *	      sym)
-{
-  if (h == NULL)
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  switch (ELF32_R_TYPE (rel->r_info))
-    {
-    case R_IQ2000_GNU_VTINHERIT:
-    case R_IQ2000_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;
-	}
-    }
+iq2000_elf_gc_mark_hook (asection *sec,
+			 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_IQ2000_GNU_VTINHERIT:
+      case R_IQ2000_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 
@@ -874,7 +846,6 @@ iq2000_elf_object_p (bfd *abfd)
 #define elf_info_to_howto			iq2000_info_to_howto_rela
 #define elf_backend_relocate_section		iq2000_elf_relocate_section
 #define elf_backend_gc_mark_hook		iq2000_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		iq2000_elf_gc_sweep_hook
 #define elf_backend_check_relocs		iq2000_elf_check_relocs
 #define elf_backend_object_p			iq2000_elf_object_p
 #define elf_backend_rela_normal			1
Index: bfd/elf32-m32c.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32c.c,v
retrieving revision 1.8
diff -u -p -r1.8 elf32-m32c.c
--- bfd/elf32-m32c.c	1 Jun 2006 03:45:58 -0000	1.8
+++ bfd/elf32-m32c.c	28 Sep 2006 07:40:54 -0000
@@ -32,10 +32,6 @@ static void m32c_info_to_howto_rela 
   (bfd *, arelent *, Elf_Internal_Rela *);
 static bfd_boolean m32c_elf_relocate_section 
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
-static bfd_boolean m32c_elf_gc_sweep_hook
-  (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
-static asection * m32c_elf_gc_mark_hook
-  (asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *);
 static bfd_boolean m32c_elf_check_relocs
   (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
 static bfd_boolean m32c_elf_relax_delete_bytes (bfd *, asection *, bfd_vma, int);
@@ -572,62 +568,6 @@ m32c_elf_relocate_section
   return TRUE;
 }
 
-/* Return the section that should be marked against GC for a given
-   relocation.  */
-
-static asection *
-m32c_elf_gc_mark_hook
-    (asection *                   sec,
-     struct bfd_link_info *       info ATTRIBUTE_UNUSED,
-     Elf_Internal_Rela *          rel,
-     struct elf_link_hash_entry * h,
-     Elf_Internal_Sym *           sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	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
-    {
-      if (!(elf_bad_symtab (sec->owner)
-	    && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
-	  && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
-		&& sym->st_shndx != SHN_COMMON))
-	{
-	  return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-	}
-    }
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-m32c_elf_gc_sweep_hook
-    (bfd *                     abfd ATTRIBUTE_UNUSED,
-     struct bfd_link_info *    info ATTRIBUTE_UNUSED,
-     asection *                sec ATTRIBUTE_UNUSED,
-     const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 /* We support 16-bit pointers to code above 64k by generating a thunk
    below 64k containing a JMP instruction to the final address.  */
  
@@ -2050,8 +1990,6 @@ m32c_elf_relax_delete_bytes
 #define elf_info_to_howto			m32c_info_to_howto_rela
 #define elf_backend_object_p			m32c_elf_object_p
 #define elf_backend_relocate_section		m32c_elf_relocate_section
-#define elf_backend_gc_mark_hook		m32c_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		m32c_elf_gc_sweep_hook
 #define elf_backend_check_relocs                m32c_elf_check_relocs
 #define elf_backend_object_p			m32c_elf_object_p
 #define elf_symbol_leading_char                 ('_')
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.81
diff -u -p -r1.81 elf32-m32r.c
--- bfd/elf32-m32r.c	16 Sep 2006 18:12:13 -0000	1.81
+++ bfd/elf32-m32r.c	28 Sep 2006 07:40:56 -0000
@@ -3637,40 +3637,22 @@ m32r_elf_print_private_bfd_data (bfd *ab
 
 static asection *
 m32r_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))
+    switch (ELF32_R_TYPE (rel->r_info))
       {
       case R_M32R_GNU_VTINHERIT:
       case R_M32R_GNU_VTENTRY:
       case R_M32R_RELA_GNU_VTINHERIT:
       case R_M32R_RELA_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);
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 static bfd_boolean
Index: bfd/elf32-m68hc11.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc11.c,v
retrieving revision 1.33
diff -u -p -r1.33 elf32-m68hc11.c
--- bfd/elf32-m68hc11.c	16 Sep 2006 18:12:13 -0000	1.33
+++ bfd/elf32-m68hc11.c	28 Sep 2006 07:40:57 -0000
@@ -1276,8 +1276,6 @@ static const struct bfd_elf_special_sect
 #define elf_info_to_howto	0
 #define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
 #define bfd_elf32_bfd_relax_section  m68hc11_elf_relax_section
-#define elf_backend_gc_mark_hook     elf32_m68hc11_gc_mark_hook
-#define elf_backend_gc_sweep_hook    elf32_m68hc11_gc_sweep_hook
 #define elf_backend_check_relocs     elf32_m68hc11_check_relocs
 #define elf_backend_relocate_section elf32_m68hc11_relocate_section
 #define elf_backend_add_symbol_hook  elf32_m68hc11_add_symbol_hook
Index: bfd/elf32-m68hc12.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc12.c,v
retrieving revision 1.25
diff -u -p -r1.25 elf32-m68hc12.c
--- bfd/elf32-m68hc12.c	16 Sep 2006 18:12:13 -0000	1.25
+++ bfd/elf32-m68hc12.c	28 Sep 2006 07:40:57 -0000
@@ -553,8 +553,6 @@ static const struct bfd_elf_special_sect
 
 #define elf_info_to_howto	0
 #define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
-#define elf_backend_gc_mark_hook     elf32_m68hc11_gc_mark_hook
-#define elf_backend_gc_sweep_hook    elf32_m68hc11_gc_sweep_hook
 #define elf_backend_check_relocs     elf32_m68hc11_check_relocs
 #define elf_backend_relocate_section elf32_m68hc11_relocate_section
 #define elf_backend_object_p		m68hc12_elf_set_mach_from_flags
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.25
diff -u -p -r1.25 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c	16 Mar 2006 12:20:15 -0000	1.25
+++ bfd/elf32-m68hc1x.c	28 Sep 2006 07:40:58 -0000
@@ -810,48 +810,6 @@ m68hc11_elf_special_reloc (bfd *abfd ATT
   abort();
 }
 
-asection *
-elf32_m68hc11_gc_mark_hook (asection *sec,
-                            struct bfd_link_info *info ATTRIBUTE_UNUSED,
-                            Elf_Internal_Rela *rel,
-                            struct elf_link_hash_entry *h,
-                            Elf_Internal_Sym *sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	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);
-
-  return NULL;
-}
-
-bfd_boolean
-elf32_m68hc11_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-                             struct bfd_link_info *info ATTRIBUTE_UNUSED,
-                             asection *sec ATTRIBUTE_UNUSED,
-                             const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't use got and plt entries for 68hc11/68hc12.  */
-  return TRUE;
-}
-
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
Index: bfd/elf32-m68hc1x.h
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.h,v
retrieving revision 1.6
diff -u -p -r1.6 elf32-m68hc1x.h
--- bfd/elf32-m68hc1x.h	4 May 2005 15:53:16 -0000	1.6
+++ bfd/elf32-m68hc1x.h	28 Sep 2006 07:40:58 -0000
@@ -159,14 +159,6 @@ bfd_reloc_status_type m68hc11_elf_specia
     asymbol *symbol, void *data, asection *input_section,
     bfd *output_bfd, char **error_message);
 
-/* GC mark and sweep.  */
-asection *elf32_m68hc11_gc_mark_hook
-  (asection *sec, struct bfd_link_info *info,
-   Elf_Internal_Rela *rel, struct elf_link_hash_entry *h,
-   Elf_Internal_Sym *sym);
-bfd_boolean elf32_m68hc11_gc_sweep_hook
-  (bfd *abfd, struct bfd_link_info *info,
-   asection *sec, const Elf_Internal_Rela *relocs);
 bfd_boolean elf32_m68hc11_check_relocs
   (bfd * abfd, struct bfd_link_info * info,
    asection * sec, const Elf_Internal_Rela * relocs);
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.91
diff -u -p -r1.91 elf32-m68k.c
--- bfd/elf32-m68k.c	16 Sep 2006 18:12:13 -0000	1.91
+++ bfd/elf32-m68k.c	28 Sep 2006 07:40:59 -0000
@@ -37,12 +37,6 @@ static struct bfd_link_hash_table *elf_m
 static bfd_boolean elf_m68k_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
-static asection *elf_m68k_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-static bfd_boolean elf_m68k_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
 static bfd_boolean elf_m68k_adjust_dynamic_symbol
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
 static bfd_boolean elf_m68k_size_dynamic_sections
@@ -980,50 +974,30 @@ elf_m68k_check_relocs (abfd, info, sec, 
    relocation.  */
 
 static asection *
-elf_m68k_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf_m68k_gc_mark_hook (asection *sec,
+		       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_68K_GNU_VTINHERIT:
-	case R_68K_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    default:
-	      break;
-
-	    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;
-	    }
-	}
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_68K_GNU_VTINHERIT:
+      case R_68K_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
-elf_m68k_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf_m68k_gc_sweep_hook (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
Index: bfd/elf32-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mcore.c,v
retrieving revision 1.45
diff -u -p -r1.45 elf32-mcore.c
--- bfd/elf32-mcore.c	16 Sep 2006 18:12:14 -0000	1.45
+++ bfd/elf32-mcore.c	28 Sep 2006 07:41:00 -0000
@@ -526,37 +526,21 @@ mcore_elf_relocate_section (bfd * output
    relocation.  */
 
 static asection *
-mcore_elf_gc_mark_hook (asection *                   sec,
-			struct bfd_link_info *       info ATTRIBUTE_UNUSED,
-			Elf_Internal_Rela *          rel,
-			struct elf_link_hash_entry * h,
-			Elf_Internal_Sym *           sym)
+mcore_elf_gc_mark_hook (asection *sec,
+			struct bfd_link_info *info,
+			Elf_Internal_Rela *rel,
+			struct elf_link_hash_entry *h,
+			Elf_Internal_Sym *sym)
 {
-  if (h == NULL)
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+  if (h != NULL)
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_MCORE_GNU_VTINHERIT:
+      case R_MCORE_GNU_VTENTRY:
+	return NULL;
+      }
 
-  switch (ELF32_R_TYPE (rel->r_info))
-    {
-    case R_MCORE_GNU_VTINHERIT:
-    case R_MCORE_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;
-	}
-    }
-
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elf32-msp430.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-msp430.c,v
retrieving revision 1.13
diff -u -p -r1.13 elf32-msp430.c
--- bfd/elf32-msp430.c	1 Sep 2005 11:27:15 -0000	1.13
+++ bfd/elf32-msp430.c	28 Sep 2006 07:41:00 -0000
@@ -213,48 +213,6 @@ msp430_info_to_howto_rela (bfd * abfd AT
   cache_ptr->howto = &elf_msp430_howto_table[r_type];
 }
 
-static asection *
-elf32_msp430_gc_mark_hook (asection * sec,
-			   struct bfd_link_info * info ATTRIBUTE_UNUSED,
-			   Elf_Internal_Rela * rel,
-			   struct elf_link_hash_entry * h,
-			   Elf_Internal_Sym * sym)
-{
-  if (h != NULL)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	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);
-
-  return NULL;
-}
-
-static bfd_boolean
-elf32_msp430_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
-			    struct bfd_link_info * info ATTRIBUTE_UNUSED,
-			    asection * sec ATTRIBUTE_UNUSED,
-			    const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
-{
-  /* We don't use got and plt entries for msp430.  */
-  return TRUE;
-}
-
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
@@ -1210,8 +1168,6 @@ error_return:
 #define elf_info_to_howto	             msp430_info_to_howto_rela
 #define elf_info_to_howto_rel	             NULL
 #define elf_backend_relocate_section         elf32_msp430_relocate_section
-#define elf_backend_gc_mark_hook             elf32_msp430_gc_mark_hook
-#define elf_backend_gc_sweep_hook            elf32_msp430_gc_sweep_hook
 #define elf_backend_check_relocs             elf32_msp430_check_relocs
 #define elf_backend_can_gc_sections          1
 #define elf_backend_final_write_processing   bfd_elf_msp430_final_write_processing
Index: bfd/elf32-mt.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mt.c,v
retrieving revision 1.4
diff -u -p -r1.4 elf32-mt.c
--- bfd/elf32-mt.c	27 Dec 2005 17:47:42 -0000	1.4
+++ bfd/elf32-mt.c	28 Sep 2006 07:41:00 -0000
@@ -394,57 +394,6 @@ mt_elf_relocate_section
   return TRUE;
 }
 
-/* Return the section that should be marked against GC for a given
-   relocation.  */
-
-static asection *
-mt_elf_gc_mark_hook
-    (asection *                   sec,
-     struct bfd_link_info *       info ATTRIBUTE_UNUSED,
-     Elf_Internal_Rela *          rel ATTRIBUTE_UNUSED,
-     struct elf_link_hash_entry * h,
-     Elf_Internal_Sym *           sym)
-{
-  if (h != NULL)
-    {
-      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
-    {
-      if (!(elf_bad_symtab (sec->owner)
-	    && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
-	  && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
-		&& sym->st_shndx != SHN_COMMON))
-	return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-    }
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being
-   removed.  */
-
-static bfd_boolean
-mt_elf_gc_sweep_hook
-    (bfd *                     abfd ATTRIBUTE_UNUSED,
-     struct bfd_link_info *    info ATTRIBUTE_UNUSED,
-     asection *                sec ATTRIBUTE_UNUSED,
-     const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
@@ -632,8 +581,6 @@ mt_elf_print_private_bfd_data (bfd * abf
 
 #define bfd_elf32_bfd_reloc_type_lookup	        mt_reloc_type_lookup
 
-#define elf_backend_gc_mark_hook		mt_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		mt_elf_gc_sweep_hook
 #define elf_backend_check_relocs                mt_elf_check_relocs
 #define elf_backend_object_p		        mt_elf_object_p
 #define elf_backend_rela_normal			1
Index: bfd/elf32-openrisc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-openrisc.c,v
retrieving revision 1.23
diff -u -p -r1.23 elf32-openrisc.c
--- bfd/elf32-openrisc.c	1 Jul 2005 11:16:29 -0000	1.23
+++ bfd/elf32-openrisc.c	28 Sep 2006 07:41:01 -0000
@@ -413,47 +413,20 @@ openrisc_elf_relocate_section (bfd *outp
 
 static asection *
 openrisc_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)
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
-
-  switch (ELF32_R_TYPE (rel->r_info))
-    {
-    case R_OPENRISC_GNU_VTINHERIT:
-    case R_OPENRISC_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;
-	}
-    }
-
-  return NULL;
-}
+  if (h != NULL)
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_OPENRISC_GNU_VTINHERIT:
+      case R_OPENRISC_GNU_VTENTRY:
+	return NULL;
+      }
 
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-openrisc_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			    struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			    asection *sec ATTRIBUTE_UNUSED,
-			    const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Look through the relocs for a section during the first phase.
@@ -560,7 +533,6 @@ openrisc_elf_final_write_processing (bfd
 #define elf_info_to_howto		openrisc_info_to_howto_rela
 #define elf_backend_relocate_section	openrisc_elf_relocate_section
 #define elf_backend_gc_mark_hook	openrisc_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook	openrisc_elf_gc_sweep_hook
 #define elf_backend_check_relocs	openrisc_elf_check_relocs
 
 #define elf_backend_can_gc_sections	1
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.203
diff -u -p -r1.203 elf32-ppc.c
--- bfd/elf32-ppc.c	16 Sep 2006 18:12:14 -0000	1.203
+++ bfd/elf32-ppc.c	28 Sep 2006 07:41:04 -0000
@@ -3653,38 +3653,20 @@ ppc_elf_select_plt_layout (bfd *output_b
 
 static asection *
 ppc_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_PPC_GNU_VTINHERIT:
-	case R_PPC_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_PPC_GNU_VTINHERIT:
+      case R_PPC_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got, plt and dynamic reloc reference counts for the
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.86
diff -u -p -r1.86 elf32-s390.c
--- bfd/elf32-s390.c	20 Sep 2006 14:38:17 -0000	1.86
+++ bfd/elf32-s390.c	28 Sep 2006 07:41:06 -0000
@@ -46,12 +46,6 @@ static void elf_s390_copy_indirect_symbo
 static bfd_boolean elf_s390_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
-static asection *elf_s390_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-static bfd_boolean elf_s390_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
 struct elf_s390_link_hash_entry;
 static void elf_s390_adjust_gotplt
   PARAMS ((struct elf_s390_link_hash_entry *));
@@ -1379,50 +1373,30 @@ elf_s390_check_relocs (abfd, info, sec, 
    relocation.  */
 
 static asection *
-elf_s390_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf_s390_gc_mark_hook (asection *sec,
+		       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_390_GNU_VTINHERIT:
-	case R_390_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      return h->root.u.def.section;
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_390_GNU_VTINHERIT:
+      case R_390_GNU_VTENTRY:
+	return NULL;
+      }
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 
-	    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);
-
-  return NULL;
 }
 
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
-elf_s390_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf_s390_gc_sweep_hook (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
Index: bfd/elf32-score.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-score.c,v
retrieving revision 1.2
diff -u -p -r1.2 elf32-score.c
--- bfd/elf32-score.c	27 Sep 2006 04:07:57 -0000	1.2
+++ bfd/elf32-score.c	28 Sep 2006 07:41:08 -0000
@@ -3616,40 +3616,25 @@ _bfd_score_elf_ignore_discarded_relocs (
   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.  */
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.142
diff -u -p -r1.142 elf32-sh.c
--- bfd/elf32-sh.c	16 Sep 2006 18:12:14 -0000	1.142
+++ bfd/elf32-sh.c	28 Sep 2006 07:41:11 -0000
@@ -4515,42 +4515,20 @@ tpoff (struct bfd_link_info *info, bfd_v
 
 static asection *
 sh_elf_gc_mark_hook (asection *sec,
-		     struct bfd_link_info *info ATTRIBUTE_UNUSED,
-		     Elf_Internal_Rela *rel, struct elf_link_hash_entry *h,
+		     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_SH_GNU_VTINHERIT:
-	case R_SH_GNU_VTENTRY:
-	  break;
-
-	default:
-#ifdef INCLUDE_SHMEDIA
-	  while (h->root.type == bfd_link_hash_indirect
-		 && h->root.u.i.link)
-	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-#endif
-	  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_SH_GNU_VTINHERIT:
+      case R_SH_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elf32-v850.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-v850.c,v
retrieving revision 1.63
diff -u -p -r1.63 elf32-v850.c
--- bfd/elf32-v850.c	16 Sep 2006 18:12:14 -0000	1.63
+++ bfd/elf32-v850.c	28 Sep 2006 07:41:12 -0000
@@ -1711,50 +1711,22 @@ v850_elf_relocate_section (bfd *output_b
   return TRUE;
 }
 
-static bfd_boolean
-v850_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			asection *sec ATTRIBUTE_UNUSED,
-			const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* No got and plt entries for v850-elf.  */
-  return TRUE;
-}
-
 static asection *
 v850_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))
+    switch (ELF32_R_TYPE (rel->r_info))
       {
       case R_V850_GNU_VTINHERIT:
       case R_V850_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);
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Set the right machine number.  */
@@ -3078,7 +3050,6 @@ static const struct bfd_elf_special_sect
 #define elf_backend_section_from_shdr		v850_elf_section_from_shdr
 #define elf_backend_fake_sections		v850_elf_fake_sections
 #define elf_backend_gc_mark_hook                v850_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook               v850_elf_gc_sweep_hook
 #define elf_backend_special_sections		v850_elf_special_sections
 
 #define elf_backend_can_gc_sections 1
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.37
diff -u -p -r1.37 elf32-vax.c
--- bfd/elf32-vax.c	16 Sep 2006 18:12:14 -0000	1.37
+++ bfd/elf32-vax.c	28 Sep 2006 07:41:13 -0000
@@ -34,13 +34,6 @@ static struct bfd_hash_entry *elf_vax_li
 static struct bfd_link_hash_table *elf_vax_link_hash_table_create (bfd *);
 static bfd_boolean elf_vax_check_relocs (bfd *, struct bfd_link_info *,
 					 asection *, const Elf_Internal_Rela *);
-static asection *elf_vax_gc_mark_hook (asection *, struct bfd_link_info *,
-				       Elf_Internal_Rela *,
-				       struct elf_link_hash_entry *,
-				       Elf_Internal_Sym *);
-static bfd_boolean elf_vax_gc_sweep_hook (bfd *, struct bfd_link_info *,
-					  asection *,
-					  const Elf_Internal_Rela *);
 static bfd_boolean elf_vax_adjust_dynamic_symbol (struct bfd_link_info *,
 						  struct elf_link_hash_entry *);
 static bfd_boolean elf_vax_size_dynamic_sections (bfd *, struct bfd_link_info *);
@@ -829,38 +822,20 @@ elf_vax_check_relocs (bfd *abfd, struct 
 
 static asection *
 elf_vax_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_VAX_GNU_VTINHERIT:
-	case R_VAX_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    default:
-	      break;
-
-	    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;
-	    }
-	}
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_VAX_GNU_VTINHERIT:
+      case R_VAX_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elf32-xstormy16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
retrieving revision 1.34
diff -u -p -r1.34 elf32-xstormy16.c
--- bfd/elf32-xstormy16.c	1 Jul 2005 11:16:29 -0000	1.34
+++ bfd/elf32-xstormy16.c	28 Sep 2006 07:41:14 -0000
@@ -967,50 +967,21 @@ xstormy16_elf_finish_dynamic_sections (b
    relocation.  */
 
 static asection *
-xstormy16_elf_gc_mark_hook (asection *                   sec,
-			    struct bfd_link_info *       info ATTRIBUTE_UNUSED,
-			    Elf_Internal_Rela *          rel,
-			    struct elf_link_hash_entry * h,
-			    Elf_Internal_Sym *           sym)
+xstormy16_elf_gc_mark_hook (asection *sec,
+			    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_XSTORMY16_GNU_VTINHERIT:
-	case R_XSTORMY16_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_XSTORMY16_GNU_VTINHERIT:
+      case R_XSTORMY16_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-xstormy16_elf_gc_sweep_hook (bfd *                     abfd ATTRIBUTE_UNUSED,
-			     struct bfd_link_info *    info ATTRIBUTE_UNUSED,
-			     asection *                sec ATTRIBUTE_UNUSED,
-			     const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
-{
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 #define ELF_ARCH		bfd_arch_xstormy16
@@ -1024,7 +995,6 @@ xstormy16_elf_gc_sweep_hook (bfd *      
 #define elf_info_to_howto			xstormy16_info_to_howto_rela
 #define elf_backend_relocate_section		xstormy16_elf_relocate_section
 #define elf_backend_gc_mark_hook		xstormy16_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		xstormy16_elf_gc_sweep_hook
 #define elf_backend_check_relocs                xstormy16_elf_check_relocs
 #define elf_backend_always_size_sections \
   xstormy16_elf_always_size_sections
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf32-xtensa.c
--- bfd/elf32-xtensa.c	16 Sep 2006 18:12:14 -0000	1.69
+++ bfd/elf32-xtensa.c	28 Sep 2006 07:41:20 -0000
@@ -966,38 +966,20 @@ elf_xtensa_hide_symbol (struct bfd_link_
 
 static asection *
 elf_xtensa_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)
-    {
-      switch (ELF32_R_TYPE (rel->r_info))
-	{
-	case R_XTENSA_GNU_VTINHERIT:
-	case R_XTENSA_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);
+  if (h != NULL)
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_XTENSA_GNU_VTINHERIT:
+      case R_XTENSA_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 
Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.49
diff -u -p -r1.49 elf64-mmix.c
--- bfd/elf64-mmix.c	16 Sep 2006 18:12:14 -0000	1.49
+++ bfd/elf64-mmix.c	28 Sep 2006 07:41:21 -0000
@@ -187,14 +187,6 @@ static bfd_boolean mmix_elf_relocate_sec
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
 	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
 
-static asection * mmix_elf_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-
-static bfd_boolean mmix_elf_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-
 static bfd_reloc_status_type mmix_final_link_relocate
   PARAMS ((reloc_howto_type *, asection *, bfd_byte *,
 	   bfd_vma, bfd_signed_vma, bfd_vma, const char *, asection *));
@@ -1744,40 +1736,21 @@ mmix_final_link_relocate (howto, input_s
    relocation.  */
 
 static asection *
-mmix_elf_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+mmix_elf_gc_mark_hook (asection *sec,
+		       struct bfd_link_info *info,
+		       Elf_Internal_Rela *rel,
+		       struct elf_link_hash_entry *h,
+		       Elf_Internal_Sym *sym)
 {
   if (h != NULL)
-    {
-      switch (ELF64_R_TYPE (rel->r_info))
-	{
-	case R_MMIX_GNU_VTINHERIT:
-	case R_MMIX_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 (ELF64_R_TYPE (rel->r_info))
+      {
+      case R_MMIX_GNU_VTINHERIT:
+      case R_MMIX_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update relocation info for a GC-excluded section.  We could supposedly
@@ -1786,11 +1759,10 @@ mmix_elf_gc_mark_hook (sec, info, rel, h
    present.  Better to waste some memory and (perhaps) a little time.  */
 
 static bfd_boolean
-mmix_elf_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
+mmix_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			asection *sec,
+			const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
 {
   struct bpo_reloc_section_info *bpodata
     = mmix_elf_section_data (sec)->bpo.reloc;
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.86
diff -u -p -r1.86 elf64-s390.c
--- bfd/elf64-s390.c	20 Sep 2006 14:38:17 -0000	1.86
+++ bfd/elf64-s390.c	28 Sep 2006 07:41:22 -0000
@@ -46,12 +46,6 @@ static void elf_s390_copy_indirect_symbo
 static bfd_boolean elf_s390_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
 	   const Elf_Internal_Rela *));
-static asection *elf_s390_gc_mark_hook
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-	   struct elf_link_hash_entry *, Elf_Internal_Sym *));
-static bfd_boolean elf_s390_gc_sweep_hook
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
 struct elf_s390_link_hash_entry;
 static void elf_s390_adjust_gotplt
   PARAMS ((struct elf_s390_link_hash_entry *));
@@ -1345,50 +1339,30 @@ elf_s390_check_relocs (abfd, info, sec, 
    relocation.  */
 
 static asection *
-elf_s390_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf_s390_gc_mark_hook (asection *sec,
+		       struct bfd_link_info *info,
+		       Elf_Internal_Rela *rel,
+		       struct elf_link_hash_entry *h,
+		       Elf_Internal_Sym *sym)
 {
   if (h != NULL)
-    {
-      switch (ELF64_R_TYPE (rel->r_info))
-	{
-	case R_390_GNU_VTINHERIT:
-	case R_390_GNU_VTENTRY:
-	  break;
-
-	default:
-	  switch (h->root.type)
-	    {
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      return h->root.u.def.section;
+    switch (ELF64_R_TYPE (rel->r_info))
+      {
+      case R_390_GNU_VTINHERIT:
+      case R_390_GNU_VTENTRY:
+	return NULL;
+      }
 
-	    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);
-
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
 
 static bfd_boolean
-elf_s390_gc_sweep_hook (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf_s390_gc_sweep_hook (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.68
diff -u -p -r1.68 elf64-sh64.c
--- bfd/elf64-sh64.c	16 Sep 2006 18:12:14 -0000	1.68
+++ bfd/elf64-sh64.c	28 Sep 2006 07:41:24 -0000
@@ -2366,53 +2366,20 @@ sh_elf64_merge_private_data (bfd *ibfd, 
 
 static asection *
 sh_elf64_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 (ELF64_R_TYPE (rel->r_info))
-	{
-	case R_SH_GNU_VTINHERIT:
-	case R_SH_GNU_VTENTRY:
-	  break;
-
-	default:
-	  while (h->root.type == bfd_link_hash_indirect
-		 && h->root.u.i.link)
-	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-	  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);
-
-  return NULL;
-}
-
-/* Update the got entry reference counts for the section being removed.  */
+    switch (ELF64_R_TYPE (rel->r_info))
+      {
+      case R_SH_GNU_VTINHERIT:
+      case R_SH_GNU_VTENTRY:
+	return NULL;
+      }
 
-static bfd_boolean
-sh_elf64_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
-			struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			asection *sec ATTRIBUTE_UNUSED,
-			const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
-  /* No got and plt entries for 64-bit SH at present.  */
-  return TRUE;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Look through the relocs for a section during the first phase.
@@ -4102,7 +4069,6 @@ static const struct bfd_elf_special_sect
 #define elf_backend_fake_sections	sh64_elf64_fake_sections
 
 #define elf_backend_gc_mark_hook        sh_elf64_gc_mark_hook
-#define elf_backend_gc_sweep_hook       sh_elf64_gc_sweep_hook
 #define elf_backend_check_relocs        sh_elf64_check_relocs
 
 #define elf_backend_can_gc_sections	1
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.124
diff -u -p -r1.124 elf64-x86-64.c
--- bfd/elf64-x86-64.c	16 Sep 2006 18:12:14 -0000	1.124
+++ bfd/elf64-x86-64.c	28 Sep 2006 07:41:26 -0000
@@ -1134,38 +1134,20 @@ elf64_x86_64_check_relocs (bfd *abfd, st
 
 static asection *
 elf64_x86_64_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 (ELF64_R_TYPE (rel->r_info))
-	{
-	case R_X86_64_GNU_VTINHERIT:
-	case R_X86_64_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 (ELF64_R_TYPE (rel->r_info))
+      {
+      case R_X86_64_GNU_VTINHERIT:
+      case R_X86_64_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.	 */
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.182
diff -u -p -r1.182 elfxx-mips.c
--- bfd/elfxx-mips.c	16 Sep 2006 18:12:14 -0000	1.182
+++ bfd/elfxx-mips.c	28 Sep 2006 07:41:39 -0000
@@ -9372,7 +9372,7 @@ _bfd_mips_elf_modify_segment_map (bfd *a
 
 asection *
 _bfd_mips_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)
@@ -9380,32 +9380,14 @@ _bfd_mips_elf_gc_mark_hook (asection *se
   /* ??? Do mips16 stub sections need to be handled special?  */
 
   if (h != NULL)
-    {
-      switch (ELF_R_TYPE (sec->owner, rel->r_info))
-	{
-	case R_MIPS_GNU_VTINHERIT:
-	case R_MIPS_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 (ELF_R_TYPE (sec->owner, rel->r_info))
+      {
+      case R_MIPS_GNU_VTINHERIT:
+      case R_MIPS_GNU_VTENTRY:
+	return NULL;
+      }
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */
Index: bfd/elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.24
diff -u -p -r1.24 elfxx-sparc.c
--- bfd/elfxx-sparc.c	16 Sep 2006 18:12:14 -0000	1.24
+++ bfd/elfxx-sparc.c	28 Sep 2006 07:41:43 -0000
@@ -1532,35 +1532,14 @@ _bfd_sparc_elf_gc_mark_hook (asection *s
 			     Elf_Internal_Sym *sym)
 {
   if (h != NULL)
-    {
-      struct _bfd_sparc_elf_link_hash_table *htab;
-
-      htab = _bfd_sparc_elf_hash_table (info);
-      switch (SPARC_ELF_R_TYPE (rel->r_info))
+    switch (SPARC_ELF_R_TYPE (rel->r_info))
       {
       case R_SPARC_GNU_VTINHERIT:
       case R_SPARC_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;
-	  }
+	return NULL;
       }
-    }
-  else
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
 
-  return NULL;
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
 /* Update the got entry reference counts for the section being removed.  */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]