* 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.
This commit is contained in:
Daniel Jacobowitz 2010-10-25 15:54:16 +00:00
parent c0621d88b0
commit e4067dbb2a
59 changed files with 222 additions and 479 deletions

View File

@ -1,3 +1,70 @@
2010-10-25 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.
2010-10-25 Nathan Sidwell <nathan@codesourcery.com>
* elf32-tic6x.c: Add attribution.

View File

@ -2355,6 +2355,9 @@ extern asection _bfd_elf_large_com_section;
#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_section;
} \
} \
\
_bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); \
rel->r_info = 0; \
rel->r_addend = 0; \
continue; \

View File

@ -402,15 +402,8 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_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;

View File

@ -1510,15 +1510,8 @@ mn10300_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;

View File

@ -9032,15 +9032,8 @@ elf32_arm_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)
{

View File

@ -1232,15 +1232,8 @@ elf32_avr_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -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_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;

View File

@ -1432,15 +1432,8 @@ elf32_cr16_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
}
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;

View File

@ -724,15 +724,8 @@ elf32_cr16c_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)
{

View File

@ -1181,15 +1181,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -874,15 +874,8 @@ elf32_crx_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
}
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;

View File

@ -464,15 +464,8 @@ elf32_d10v_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;

View File

@ -578,15 +578,8 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_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;

View File

@ -2813,15 +2813,8 @@ elf32_frv_relocate_section (output_bfd, info, input_bfd, input_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;

View File

@ -461,15 +461,8 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
}
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;

View File

@ -3741,17 +3741,10 @@ elf32_hppa_relocate_section (bfd *output_bfd,
}
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;

View File

@ -1141,15 +1141,8 @@ i370_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;

View File

@ -1129,15 +1129,8 @@ elf32_i860_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -1437,15 +1437,8 @@ ip2k_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -634,15 +634,8 @@ iq2000_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -894,15 +894,8 @@ lm32_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)
{

View File

@ -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)
{

View File

@ -2626,15 +2626,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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)
{

View File

@ -971,15 +971,8 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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)
{

View File

@ -3716,15 +3716,8 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_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;

View File

@ -467,15 +467,8 @@ mcore_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;

View File

@ -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;

View File

@ -251,15 +251,8 @@ moxie_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;

View File

@ -455,15 +455,8 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -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;

View File

@ -374,15 +374,8 @@ openrisc_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;

View File

@ -6817,10 +6817,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
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)

View File

@ -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)
{

View File

@ -2292,15 +2292,8 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_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;

View File

@ -2675,15 +2675,8 @@ s3_bfd_score_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)
{

View File

@ -2447,15 +2447,8 @@ s7_bfd_score_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)
{

View File

@ -4246,15 +4246,8 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
}
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;

View File

@ -4896,15 +4896,8 @@ spu_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;

View File

@ -1469,15 +1469,8 @@ elf32_tic6x_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)
{

View File

@ -2094,15 +2094,8 @@ v850_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;

View File

@ -1453,15 +1453,8 @@ elf_vax_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;

View File

@ -385,13 +385,11 @@ elf32_xc16x_relocate_section (bfd *output_bfd,
{
/* 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)

View File

@ -832,15 +832,8 @@ xstormy16_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNU
}
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;

View File

@ -2660,15 +2660,8 @@ elf_xtensa_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)
{

View File

@ -4025,16 +4025,10 @@ elf64_alpha_relocate_section_r (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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 *output_bfd, struct bfd_link_info *info,
}
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;

View File

@ -3944,15 +3944,8 @@ elf64_hppa_relocate_section (bfd *output_bfd,
}
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;

View File

@ -1408,15 +1408,8 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_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)
{

View File

@ -11624,16 +11624,10 @@ ppc64_elf_relocate_section (bfd *output_bfd,
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;

View File

@ -2280,15 +2280,8 @@ elf_s390_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;

View File

@ -1658,15 +1658,8 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
}
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;

View File

@ -4662,16 +4662,9 @@ elfNN_ia64_relocate_section (bfd *output_bfd,
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;

View File

@ -9000,15 +9000,8 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
}
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))
{

View File

@ -2964,16 +2964,8 @@ _bfd_sparc_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;

View File

@ -624,7 +624,7 @@ extern bfd_reloc_status_type _bfd_relocate_contents
/* 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. */

View File

@ -629,7 +629,7 @@ extern bfd_reloc_status_type _bfd_relocate_contents
/* 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. */

View File

@ -1544,14 +1544,15 @@ _bfd_relocate_contents (reloc_howto_type *howto,
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 *howto,
/* 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_contents (bfd *abfd,
"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;

View File

@ -1,3 +1,7 @@
2010-10-25 Daniel Jacobowitz <dan@codesourcery.com>
* ld-discard/zero-range.d, ld-discard/zero-range.s: New files.
2010-10-23 Mark Mitchell <mark@codesourcery.com>
* ld-elf/group10.d: Expect ".group" for the name of group

View File

@ -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 .*

View File

@ -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