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]

Re: gc-sections and DWARF ranges


On Fri, Oct 22, 2010 at 02:45:49PM +1030, Alan Modra wrote:
> On Thu, Oct 21, 2010 at 10:35:38PM -0400, Daniel Jacobowitz wrote:
> > What's your opinion of a flat-out hack then?
> 
> What does one more hack matter?  :-)

Here's the patch, then.  It builds for all targets and tests OK on
x86_64.  I'm going to run some more tests before I commit it.

-- 
Daniel Jacobowitz
CodeSourcery

2010-10-22  Daniel Jacobowitz  <dan@codesourcery.com>

	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Always call
	_bfd_clear_contents.  Pass it the input section.
	* libbfd-in.h (_bfd_clear_contents): Add input_section argument.
	* libbfd.h: Regenerate.
	* reloc.c (_bfd_clear_contents): Take input_section argument.
	Use non-zero for .debug_ranges.
	(bfd_generic_get_relocated_section_conten): Update _bfd_clear_contents
	call.

	* elf32-arm.c (elf32_arm_relocate_section): Use
	RELOC_AGAINST_DISCARDED_SECTION.
	* elf-m10200.c (mn10200_elf_relocate_section): Likewise.
	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
	* elf32-arm.c (elf32_arm_relocate_section): Likewise.
	* elf32-avr.c (elf32_avr_relocate_section): Likewise.
	* elf32-bfin.c (bfin_relocate_section): Likewise.
	(bfinfdpic_relocate_section): Likewise.
	* elf32-cr16.c (elf32_cr16_relocate_section): Likewise.
	* elf32-cr16c.c (elf32_cr16c_relocate_section): Likewise.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-crx.c (elf32_crx_relocate_section): Likewise.
	* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
	* elf32-fr30.c (fr30_elf_relocate_section): Likewise.
	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
	* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	* elf32-i370.c (i370_elf_relocate_section): Likewise.
	* elf32-i860.c (elf32_i860_relocate_section): Likewise.
	* elf32-ip2k.c (ip2k_elf_relocate_section): Likewise.
	* elf32-iq2000.c (iq2000_elf_relocate_section): Likewise.
	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
	* elf32-m32c.c (m32c_elf_relocate_section): Likewise.
	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
	* elf32-mep.c (mep_elf_relocate_section): Likewise.
	* elf32-moxie.c (moxie_elf_relocate_section): Likewise.
	* elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
	* elf32-mt.c (mt_elf_relocate_section): Likewise.
	* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-rx.c (rx_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-spu.c (spu_elf_relocate_section): Likewise.
	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
	* elf32-v850.c (v850_elf_relocate_section): Likewise.
	* elf32-vax.c (elf_vax_relocate_section): Likewise.
	* elf32-xc16x.c (elf32_xc16x_relocate_section): Likewise.
	* elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section_r): Likewise.
	(elf64_alpha_relocate_section): Likewise.
	* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
	* elf64-mmix.c (mmix_elf_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
	* elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_relocate_section): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.

	ld/testsuite/
	* ld-discard/zero-range.d, ld-discard/zero-range.s: New files.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.311
diff -u -p -r1.311 elf-bfd.h
--- bfd/elf-bfd.h	21 Oct 2010 12:29:01 -0000	1.311
+++ bfd/elf-bfd.h	22 Oct 2010 14:20:22 -0000
@@ -2355,6 +2355,9 @@ extern asection _bfd_elf_large_com_secti
 #define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section,	\
 					rel, relend, howto, contents)	\
   {									\
+    _bfd_clear_contents (howto, input_bfd, input_section,		\
+			 contents + rel->r_offset);			\
+									\
     if (info->relocatable						\
 	&& (input_section->flags & SEC_DEBUGGING))			\
       {									\
@@ -2380,7 +2383,6 @@ extern asection _bfd_elf_large_com_secti
 	  }								\
       }									\
 									\
-    _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);	\
     rel->r_info = 0;							\
     rel->r_addend = 0;							\
     continue;								\
Index: bfd/elf-m10200.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10200.c,v
retrieving revision 1.36
diff -u -p -r1.36 elf-m10200.c
--- bfd/elf-m10200.c	27 Jun 2010 04:07:51 -0000	1.36
+++ bfd/elf-m10200.c	22 Oct 2010 14:20:22 -0000
@@ -402,15 +402,8 @@ mn10200_elf_relocate_section (output_bfd
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.105
diff -u -p -r1.105 elf-m10300.c
--- bfd/elf-m10300.c	25 Aug 2010 14:53:39 -0000	1.105
+++ bfd/elf-m10300.c	22 Oct 2010 14:20:22 -0000
@@ -1510,15 +1510,8 @@ mn10300_elf_relocate_section (bfd *outpu
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.245
diff -u -p -r1.245 elf32-arm.c
--- bfd/elf32-arm.c	11 Oct 2010 07:38:53 -0000	1.245
+++ bfd/elf32-arm.c	22 Oct 2010 14:20:22 -0000
@@ -9033,15 +9033,8 @@ elf32_arm_relocate_section (bfd *       
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-avr.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-avr.c,v
retrieving revision 1.47
diff -u -p -r1.47 elf32-avr.c
--- bfd/elf32-avr.c	25 Aug 2010 14:53:40 -0000	1.47
+++ bfd/elf32-avr.c	22 Oct 2010 14:20:22 -0000
@@ -1232,15 +1232,8 @@ elf32_avr_relocate_section (bfd *output_
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.48
diff -u -p -r1.48 elf32-bfin.c
--- bfd/elf32-bfin.c	25 Aug 2010 14:53:40 -0000	1.48
+++ bfd/elf32-bfin.c	22 Oct 2010 14:20:22 -0000
@@ -1429,15 +1429,8 @@ bfin_relocate_section (bfd * output_bfd,
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
@@ -2655,15 +2648,8 @@ bfinfdpic_relocate_section (bfd * output
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-cr16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cr16.c,v
retrieving revision 1.15
diff -u -p -r1.15 elf32-cr16.c
--- bfd/elf32-cr16.c	27 Jun 2010 04:07:51 -0000	1.15
+++ bfd/elf32-cr16.c	22 Oct 2010 14:20:22 -0000
@@ -1432,15 +1432,8 @@ elf32_cr16_relocate_section (bfd *output
         }
 
       if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
         continue;
Index: bfd/elf32-cr16c.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cr16c.c,v
retrieving revision 1.15
diff -u -p -r1.15 elf32-cr16c.c
--- bfd/elf32-cr16c.c	27 Jun 2010 04:07:51 -0000	1.15
+++ bfd/elf32-cr16c.c	22 Oct 2010 14:20:22 -0000
@@ -724,15 +724,8 @@ elf32_cr16c_relocate_section (bfd *outpu
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.113
diff -u -p -r1.113 elf32-cris.c
--- bfd/elf32-cris.c	24 Sep 2010 12:14:24 -0000	1.113
+++ bfd/elf32-cris.c	22 Oct 2010 14:20:22 -0000
@@ -1181,15 +1181,8 @@ cris_elf_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-crx.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-crx.c,v
retrieving revision 1.15
diff -u -p -r1.15 elf32-crx.c
--- bfd/elf32-crx.c	27 Jun 2010 04:07:51 -0000	1.15
+++ bfd/elf32-crx.c	22 Oct 2010 14:20:22 -0000
@@ -874,15 +874,8 @@ elf32_crx_relocate_section (bfd *output_
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-d10v.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-d10v.c,v
retrieving revision 1.38
diff -u -p -r1.38 elf32-d10v.c
--- bfd/elf32-d10v.c	28 Sep 2007 08:43:45 -0000	1.38
+++ bfd/elf32-d10v.c	22 Oct 2010 14:20:22 -0000
@@ -464,15 +464,8 @@ elf32_d10v_relocate_section (bfd *output
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-fr30.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-fr30.c,v
retrieving revision 1.39
diff -u -p -r1.39 elf32-fr30.c
--- bfd/elf32-fr30.c	2 Sep 2009 07:18:36 -0000	1.39
+++ bfd/elf32-fr30.c	22 Oct 2010 14:20:22 -0000
@@ -578,15 +578,8 @@ fr30_elf_relocate_section (output_bfd, i
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.70
diff -u -p -r1.70 elf32-frv.c
--- bfd/elf32-frv.c	11 Oct 2010 09:11:34 -0000	1.70
+++ bfd/elf32-frv.c	22 Oct 2010 14:20:23 -0000
@@ -2813,15 +2813,8 @@ elf32_frv_relocate_section (output_bfd, 
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-h8300.c,v
retrieving revision 1.57
diff -u -p -r1.57 elf32-h8300.c
--- bfd/elf32-h8300.c	27 Jun 2010 04:07:51 -0000	1.57
+++ bfd/elf32-h8300.c	22 Oct 2010 14:20:23 -0000
@@ -461,15 +461,8 @@ elf32_h8_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.175
diff -u -p -r1.175 elf32-hppa.c
--- bfd/elf32-hppa.c	24 Sep 2010 12:14:24 -0000	1.175
+++ bfd/elf32-hppa.c	22 Oct 2010 14:20:23 -0000
@@ -3741,17 +3741,10 @@ elf32_hppa_relocate_section (bfd *output
 	}
 
       if (sym_sec != NULL && elf_discarded_section (sym_sec))
-	{
-	  /* For relocs against symbols from removed linkonce
-	     sections, or sections discarded by a linker script,
-	     we just want the section contents zeroed.  Avoid any
-	     special processing.  */
-	  _bfd_clear_contents (elf_hppa_howto_table + r_type, input_bfd,
-			       contents + rela->r_offset);
-	  rela->r_info = 0;
-	  rela->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rela, relend,
+					 elf_hppa_howto_table + r_type,
+					 contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i370.c,v
retrieving revision 1.66
diff -u -p -r1.66 elf32-i370.c
--- bfd/elf32-i370.c	24 Sep 2010 12:14:24 -0000	1.66
+++ bfd/elf32-i370.c	22 Oct 2010 14:20:23 -0000
@@ -1141,15 +1141,8 @@ i370_elf_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-i860.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i860.c,v
retrieving revision 1.41
diff -u -p -r1.41 elf32-i860.c
--- bfd/elf32-i860.c	3 Jul 2007 14:26:41 -0000	1.41
+++ bfd/elf32-i860.c	22 Oct 2010 14:20:23 -0000
@@ -1129,15 +1129,8 @@ elf32_i860_relocate_section (bfd *output
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-ip2k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ip2k.c,v
retrieving revision 1.27
diff -u -p -r1.27 elf32-ip2k.c
--- bfd/elf32-ip2k.c	27 Jun 2010 04:07:51 -0000	1.27
+++ bfd/elf32-ip2k.c	22 Oct 2010 14:20:23 -0000
@@ -1437,15 +1437,8 @@ ip2k_elf_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-iq2000.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-iq2000.c,v
retrieving revision 1.26
diff -u -p -r1.26 elf32-iq2000.c
--- bfd/elf32-iq2000.c	30 Jul 2008 04:34:56 -0000	1.26
+++ bfd/elf32-iq2000.c	22 Oct 2010 14:20:23 -0000
@@ -634,15 +634,8 @@ iq2000_elf_relocate_section (bfd *		    
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-lm32.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-lm32.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-lm32.c
--- bfd/elf32-lm32.c	25 Aug 2010 14:53:42 -0000	1.7
+++ bfd/elf32-lm32.c	22 Oct 2010 14:20:23 -0000
@@ -894,15 +894,8 @@ lm32_elf_relocate_section (bfd *output_b
         }
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
         {
Index: bfd/elf32-m32c.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32c.c,v
retrieving revision 1.22
diff -u -p -r1.22 elf32-m32c.c
--- bfd/elf32-m32c.c	4 Aug 2010 03:42:45 -0000	1.22
+++ bfd/elf32-m32c.c	22 Oct 2010 14:20:23 -0000
@@ -435,15 +435,8 @@ m32c_elf_relocate_section
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.100
diff -u -p -r1.100 elf32-m32r.c
--- bfd/elf32-m32r.c	4 Oct 2010 14:13:09 -0000	1.100
+++ bfd/elf32-m32r.c	22 Oct 2010 14:20:23 -0000
@@ -2626,15 +2626,8 @@ m32r_elf_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable && !use_rel)
 	{
Index: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.38
diff -u -p -r1.38 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c	27 Jun 2010 04:07:51 -0000	1.38
+++ bfd/elf32-m68hc1x.c	22 Oct 2010 14:20:23 -0000
@@ -971,15 +971,8 @@ elf32_m68hc11_relocate_section (bfd *out
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.123
diff -u -p -r1.123 elf32-m68k.c
--- bfd/elf32-m68k.c	24 Sep 2010 12:14:24 -0000	1.123
+++ bfd/elf32-m68k.c	22 Oct 2010 14:20:23 -0000
@@ -3716,15 +3716,8 @@ elf_m68k_relocate_section (output_bfd, i
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-mcore.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mcore.c,v
retrieving revision 1.52
diff -u -p -r1.52 elf32-mcore.c
--- bfd/elf32-mcore.c	28 Sep 2007 08:43:45 -0000	1.52
+++ bfd/elf32-mcore.c	22 Oct 2010 14:20:23 -0000
@@ -467,15 +467,8 @@ mcore_elf_relocate_section (bfd * output
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-mep.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mep.c,v
retrieving revision 1.13
diff -u -p -r1.13 elf32-mep.c
--- bfd/elf32-mep.c	2 Sep 2009 07:18:36 -0000	1.13
+++ bfd/elf32-mep.c	22 Oct 2010 14:20:23 -0000
@@ -500,15 +500,8 @@ mep_elf_relocate_section
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-moxie.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-moxie.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-moxie.c
--- bfd/elf32-moxie.c	27 Jun 2010 04:07:51 -0000	1.3
+++ bfd/elf32-moxie.c	22 Oct 2010 14:20:23 -0000
@@ -251,15 +251,8 @@ moxie_elf_relocate_section (bfd *output_
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-msp430.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-msp430.c,v
retrieving revision 1.21
diff -u -p -r1.21 elf32-msp430.c
--- bfd/elf32-msp430.c	27 Jun 2010 04:07:51 -0000	1.21
+++ bfd/elf32-msp430.c	22 Oct 2010 14:20:23 -0000
@@ -455,15 +455,8 @@ elf32_msp430_relocate_section (bfd * out
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-mt.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mt.c,v
retrieving revision 1.12
diff -u -p -r1.12 elf32-mt.c
--- bfd/elf32-mt.c	30 Jul 2008 04:34:56 -0000	1.12
+++ bfd/elf32-mt.c	22 Oct 2010 14:20:23 -0000
@@ -355,15 +355,8 @@ mt_elf_relocate_section
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-openrisc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-openrisc.c,v
retrieving revision 1.30
diff -u -p -r1.30 elf32-openrisc.c
--- bfd/elf32-openrisc.c	28 Sep 2007 08:43:45 -0000	1.30
+++ bfd/elf32-openrisc.c	22 Oct 2010 14:20:23 -0000
@@ -374,15 +374,8 @@ openrisc_elf_relocate_section (bfd *outp
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.289
diff -u -p -r1.289 elf32-ppc.c
--- bfd/elf32-ppc.c	4 Oct 2010 14:13:09 -0000	1.289
+++ bfd/elf32-ppc.c	22 Oct 2010 14:20:23 -0000
@@ -6817,10 +6817,8 @@ ppc_elf_relocate_section (bfd *output_bf
 	  howto = NULL;
 	  if (r_type < R_PPC_max)
 	    howto = ppc_elf_howto_table[r_type];
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
+	  RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					   rel, relend, howto, contents);
 	}
 
       if (info->relocatable)
Index: bfd/elf32-rx.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-rx.c,v
retrieving revision 1.4
diff -u -p -r1.4 elf32-rx.c
--- bfd/elf32-rx.c	8 Oct 2010 14:00:47 -0000	1.4
+++ bfd/elf32-rx.c	22 Oct 2010 14:20:23 -0000
@@ -502,15 +502,8 @@ rx_elf_relocate_section
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.106
diff -u -p -r1.106 elf32-s390.c
--- bfd/elf32-s390.c	25 Aug 2010 14:53:43 -0000	1.106
+++ bfd/elf32-s390.c	22 Oct 2010 14:20:23 -0000
@@ -2292,15 +2292,8 @@ elf_s390_relocate_section (output_bfd, i
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-score.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-score.c,v
retrieving revision 1.20
diff -u -p -r1.20 elf32-score.c
--- bfd/elf32-score.c	24 Sep 2010 12:14:24 -0000	1.20
+++ bfd/elf32-score.c	22 Oct 2010 14:20:23 -0000
@@ -2675,15 +2675,8 @@ s3_bfd_score_elf_relocate_section (bfd *
         }
 
       if (sec != NULL && elf_discarded_section (sec))
-        {
-          /* For relocs against symbols from removed linkonce sections,
-             or sections discarded by a linker script, we just want the
-             section contents zeroed.  Avoid any special processing.  */
-          _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-          rel->r_info = 0;
-          rel->r_addend = 0;
-          continue;
-        }
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
         {
Index: bfd/elf32-score7.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-score7.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-score7.c
--- bfd/elf32-score7.c	24 Sep 2010 12:14:24 -0000	1.7
+++ bfd/elf32-score7.c	22 Oct 2010 14:20:23 -0000
@@ -2447,15 +2447,8 @@ s7_bfd_score_elf_relocate_section (bfd *
         }
 
       if (sec != NULL && elf_discarded_section (sec))
-        {
-          /* For relocs against symbols from removed linkonce sections,
-             or sections discarded by a linker script, we just want the
-             section contents zeroed.  Avoid any special processing.  */
-          _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-          rel->r_info = 0;
-          rel->r_addend = 0;
-          continue;
-        }
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
         {
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.169
diff -u -p -r1.169 elf32-sh.c
--- bfd/elf32-sh.c	24 Sep 2010 12:14:24 -0000	1.169
+++ bfd/elf32-sh.c	22 Oct 2010 14:20:23 -0000
@@ -4246,15 +4246,8 @@ sh_elf_relocate_section (bfd *output_bfd
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.99
diff -u -p -r1.99 elf32-spu.c
--- bfd/elf32-spu.c	4 Oct 2010 14:13:09 -0000	1.99
+++ bfd/elf32-spu.c	22 Oct 2010 14:20:23 -0000
@@ -4896,15 +4896,8 @@ spu_elf_relocate_section (bfd *output_bf
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-tic6x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-tic6x.c,v
retrieving revision 1.7
diff -u -p -r1.7 elf32-tic6x.c
--- bfd/elf32-tic6x.c	21 Oct 2010 21:16:50 -0000	1.7
+++ bfd/elf32-tic6x.c	22 Oct 2010 14:20:23 -0000
@@ -1467,15 +1467,8 @@ elf32_tic6x_relocate_section (bfd *outpu
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf32-v850.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-v850.c,v
retrieving revision 1.79
diff -u -p -r1.79 elf32-v850.c
--- bfd/elf32-v850.c	23 Jul 2010 14:52:46 -0000	1.79
+++ bfd/elf32-v850.c	22 Oct 2010 14:20:24 -0000
@@ -2094,15 +2094,8 @@ v850_elf_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.62
diff -u -p -r1.62 elf32-vax.c
--- bfd/elf32-vax.c	24 Sep 2010 12:14:24 -0000	1.62
+++ bfd/elf32-vax.c	22 Oct 2010 14:20:24 -0000
@@ -1453,15 +1453,8 @@ elf_vax_relocate_section (bfd *output_bf
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-xc16x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xc16x.c,v
retrieving revision 1.8
diff -u -p -r1.8 elf32-xc16x.c
--- bfd/elf32-xc16x.c	27 Jun 2010 04:07:53 -0000	1.8
+++ bfd/elf32-xc16x.c	22 Oct 2010 14:20:24 -0000
@@ -385,13 +385,11 @@ elf32_xc16x_relocate_section (bfd *outpu
 	{
 	  /* For relocs against symbols from removed linkonce sections,
 	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
+	     section contents cleared.  Avoid any special processing.  */
 	  reloc_howto_type *howto;
 	  howto = xc16x_reloc_type_lookup (input_bfd, r_type);
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
+	  RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					   rel, relend, howto, contents);
 	}
 
       if (info->relocatable)
Index: bfd/elf32-xstormy16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
retrieving revision 1.41
diff -u -p -r1.41 elf32-xstormy16.c
--- bfd/elf32-xstormy16.c	26 Sep 2007 13:45:32 -0000	1.41
+++ bfd/elf32-xstormy16.c	22 Oct 2010 14:20:24 -0000
@@ -832,15 +832,8 @@ xstormy16_elf_relocate_section (bfd *   
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.127
diff -u -p -r1.127 elf32-xtensa.c
--- bfd/elf32-xtensa.c	8 Oct 2010 14:00:47 -0000	1.127
+++ bfd/elf32-xtensa.c	22 Oct 2010 14:20:24 -0000
@@ -2660,15 +2660,8 @@ elf_xtensa_relocate_section (bfd *output
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.173
diff -u -p -r1.173 elf64-alpha.c
--- bfd/elf64-alpha.c	4 Oct 2010 14:13:09 -0000	1.173
+++ bfd/elf64-alpha.c	22 Oct 2010 14:20:24 -0000
@@ -4025,16 +4025,10 @@ elf64_alpha_relocate_section_r (bfd *out
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  */
-	  _bfd_clear_contents (elf64_alpha_howto_table + r_type,
-			       input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend,
+					 elf64_alpha_howto_table + r_type,
+					 contents);
 
       if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
 	rel->r_addend += sec->output_offset;
@@ -4240,15 +4234,8 @@ elf64_alpha_relocate_section (bfd *outpu
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       addend = rel->r_addend;
       value += addend;
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.100
diff -u -p -r1.100 elf64-hppa.c
--- bfd/elf64-hppa.c	4 Oct 2010 14:13:09 -0000	1.100
+++ bfd/elf64-hppa.c	22 Oct 2010 14:20:24 -0000
@@ -3944,15 +3944,8 @@ elf64_hppa_relocate_section (bfd *output
 	}
 
       if (sym_sec != NULL && elf_discarded_section (sym_sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.62
diff -u -p -r1.62 elf64-mmix.c
--- bfd/elf64-mmix.c	27 Jun 2010 04:07:53 -0000	1.62
+++ bfd/elf64-mmix.c	22 Oct 2010 14:20:24 -0000
@@ -1408,15 +1408,8 @@ mmix_elf_relocate_section (output_bfd, i
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	{
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.338
diff -u -p -r1.338 elf64-ppc.c
--- bfd/elf64-ppc.c	4 Oct 2010 14:13:09 -0000	1.338
+++ bfd/elf64-ppc.c	22 Oct 2010 14:20:24 -0000
@@ -11624,16 +11624,10 @@ ppc64_elf_relocate_section (bfd *output_
       h = (struct ppc_link_hash_entry *) h_elf;
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (ppc64_elf_howto_table[r_type], input_bfd,
-			       contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend,
+					 ppc64_elf_howto_table[r_type],
+					 contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.106
diff -u -p -r1.106 elf64-s390.c
--- bfd/elf64-s390.c	25 Aug 2010 14:53:45 -0000	1.106
+++ bfd/elf64-s390.c	22 Oct 2010 14:20:24 -0000
@@ -2280,15 +2280,8 @@ elf_s390_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.85
diff -u -p -r1.85 elf64-sh64.c
--- bfd/elf64-sh64.c	4 Feb 2010 09:16:41 -0000	1.85
+++ bfd/elf64-sh64.c	22 Oct 2010 14:20:24 -0000
@@ -1658,15 +1658,8 @@ sh_elf64_relocate_section (bfd *output_b
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.227
diff -u -p -r1.227 elfxx-ia64.c
--- bfd/elfxx-ia64.c	4 Oct 2010 14:13:09 -0000	1.227
+++ bfd/elfxx-ia64.c	22 Oct 2010 14:20:24 -0000
@@ -4662,16 +4662,9 @@ elfNN_ia64_relocate_section (bfd *output
 	    continue;
 	}
 
-      /* For relocs against symbols from removed linkonce sections,
-	 or sections discarded by a linker script, we just want the
-	 section contents zeroed.  Avoid any special processing.  */
       if (sym_sec != NULL && elf_discarded_section (sym_sec))
-	{
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.276
diff -u -p -r1.276 elfxx-mips.c
--- bfd/elfxx-mips.c	4 Oct 2010 14:13:09 -0000	1.276
+++ bfd/elfxx-mips.c	22 Oct 2010 14:20:25 -0000
@@ -9000,15 +9000,8 @@ _bfd_mips_elf_relocate_section (bfd *out
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce sections,
-	     or sections discarded by a linker script, we just want the
-	     section contents zeroed.  Avoid any special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (r_type == R_MIPS_64 && ! NEWABI_P (input_bfd))
 	{
Index: bfd/elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.56
diff -u -p -r1.56 elfxx-sparc.c
--- bfd/elfxx-sparc.c	22 Oct 2010 12:08:28 -0000	1.56
+++ bfd/elfxx-sparc.c	22 Oct 2010 14:20:25 -0000
@@ -2964,16 +2964,8 @@ _bfd_sparc_elf_relocate_section (bfd *ou
 	}
 
       if (sec != NULL && elf_discarded_section (sec))
-	{
-	  /* For relocs against symbols from removed linkonce
-	     sections, or sections discarded by a linker script, we
-	     just want the section contents zeroed.  Avoid any
-	     special processing.  */
-	  _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-	  rel->r_info = 0;
-	  rel->r_addend = 0;
-	  continue;
-	}
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, relend, howto, contents);
 
       if (info->relocatable)
 	continue;
Index: bfd/libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.84
diff -u -p -r1.84 libbfd-in.h
--- bfd/libbfd-in.h	18 Aug 2010 12:24:07 -0000	1.84
+++ bfd/libbfd-in.h	22 Oct 2010 14:20:25 -0000
@@ -628,7 +628,7 @@ extern bfd_reloc_status_type _bfd_reloca
 
 /* Clear a given location using a given howto.  */
 extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
-				 bfd_byte *location);
+				 asection *input_section, bfd_byte *location);
 
 /* Link stabs in sections in the first pass.  */
 
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.240
diff -u -p -r1.240 libbfd.h
--- bfd/libbfd.h	8 Oct 2010 22:34:37 -0000	1.240
+++ bfd/libbfd.h	22 Oct 2010 14:20:25 -0000
@@ -633,7 +633,7 @@ extern bfd_reloc_status_type _bfd_reloca
 
 /* Clear a given location using a given howto.  */
 extern void _bfd_clear_contents (reloc_howto_type *howto, bfd *input_bfd,
-				 bfd_byte *location);
+				 asection *input_section, bfd_byte *location);
 
 /* Link stabs in sections in the first pass.  */
 
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.206
diff -u -p -r1.206 reloc.c
--- bfd/reloc.c	8 Oct 2010 22:34:37 -0000	1.206
+++ bfd/reloc.c	22 Oct 2010 14:20:25 -0000
@@ -1544,14 +1544,15 @@ _bfd_relocate_contents (reloc_howto_type
   return flag;
 }
 
-/* Clear a given location using a given howto, by applying a relocation value
-   of zero and discarding any in-place addend.  This is used for fixed-up
+/* Clear a given location using a given howto, by applying a fixed relocation
+   value and discarding any in-place addend.  This is used for fixed-up
    relocations against discarded symbols, to make ignorable debug or unwind
    information more obvious.  */
 
 void
 _bfd_clear_contents (reloc_howto_type *howto,
 		     bfd *input_bfd,
+		     asection *input_section,
 		     bfd_byte *location)
 {
   int size;
@@ -1585,6 +1586,13 @@ _bfd_clear_contents (reloc_howto_type *h
   /* Zero out the unwanted bits of X.  */
   x &= ~howto->dst_mask;
 
+  /* For a range list, use 1 instead of 0 as placeholder.  0
+     would terminate the list, hiding any later entries.  */
+  if (strcmp (bfd_get_section_name (input_bfd, input_section),
+	      ".debug_ranges") == 0
+      && (howto->dst_mask & 1) != 0)
+    x |= 1;
+
   /* Put the relocated value back in the object file.  */
   switch (size)
     {
@@ -5756,7 +5764,8 @@ bfd_generic_get_relocated_section_conten
 			 "unused", FALSE, 0, 0, FALSE);
 
 	      p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
-	      _bfd_clear_contents ((*parent)->howto, input_bfd, p);
+	      _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
+				   p);
 	      (*parent)->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
 	      (*parent)->addend = 0;
 	      (*parent)->howto = &none_howto;
Index: ld/testsuite/ld-discard/zero-range.d
===================================================================
RCS file: ld/testsuite/ld-discard/zero-range.d
diff -N ld/testsuite/ld-discard/zero-range.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-discard/zero-range.d	22 Oct 2010 14:20:25 -0000
@@ -0,0 +1,8 @@
+#source: zero-range.s
+#ld: -T discard.ld
+#objdump: -s -j .debug_ranges
+
+.*:     file format .*elf.*
+
+Contents of section .debug_ranges:
+ 0000 (01)?000000(01)? (01)?000000(01)? 00000000 00000000 .*
Index: ld/testsuite/ld-discard/zero-range.s
===================================================================
RCS file: ld/testsuite/ld-discard/zero-range.s
diff -N ld/testsuite/ld-discard/zero-range.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-discard/zero-range.s	22 Oct 2010 14:20:25 -0000
@@ -0,0 +1,13 @@
+	.text
+	.globl _start
+_start:
+
+	.section	.debug_ranges
+	.long	.Ltext
+	.long	.Ltext + 2
+	.long	0
+	.long	0
+
+	.section	.text.exit,"ax"
+.Ltext:
+	.long	0


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