From: Daniel Jacobowitz Date: Mon, 25 Oct 2010 15:54:16 +0000 (+0000) Subject: bfd/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4067dbb2a3368dbf908b39c5435c84d51abc9f3;p=binutils-gdb.git bfd/ * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 18a3a67be3a..8fbaed21fa2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,70 @@ +2010-10-25 Daniel Jacobowitz + + * 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 * elf32-tic6x.c: Add attribution. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 0527bbd38a0..e306f8d5657 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -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; \ diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index 0fafe556883..a38f4db8a0a 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -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; diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index a4da9d52a62..bdca122e40f 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -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; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 739a79d7f69..24a50a3d44e 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -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) { diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 7334340fd98..07568a45077 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -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; diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index ac41d63b3fa..237391b201e 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -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; diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 4c6e3c00e80..0118131bead 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -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; diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c index 5016c6e66a9..ca2d7cbb4a3 100644 --- a/bfd/elf32-cr16c.c +++ b/bfd/elf32-cr16c.c @@ -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) { diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index f3ed80d18e9..9644e9b902d 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -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; diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c index 11c1f564b32..d48932d5e00 100644 --- a/bfd/elf32-crx.c +++ b/bfd/elf32-crx.c @@ -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; diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c index a5e5395163c..7d6539524ac 100644 --- a/bfd/elf32-d10v.c +++ b/bfd/elf32-d10v.c @@ -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; diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index f96b1f6661e..97b0d299f7f 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -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; diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index f6975f3fba9..bce05403af9 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -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; diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c index e05efbdba93..95d398356d9 100644 --- a/bfd/elf32-h8300.c +++ b/bfd/elf32-h8300.c @@ -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; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 3a3a355d6e6..81bc042a614 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -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; diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 01f9fb86124..a17a0fe8be2 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -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; diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index 41d5e93f6fb..00c8ca79e8b 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -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; diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c index 2ef22b680a9..0a251b84589 100644 --- a/bfd/elf32-ip2k.c +++ b/bfd/elf32-ip2k.c @@ -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; diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c index 4dcc866e89f..63ef3dcfc82 100644 --- a/bfd/elf32-iq2000.c +++ b/bfd/elf32-iq2000.c @@ -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; diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 49b21307547..b6e8ba0f399 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -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) { diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index c9bfb64d2b1..e9cabaa963a 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -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) { diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index db7dcf9d9a5..0b114bd9968 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -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) { diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index 21074868868..40b0c86af38 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -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) { diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 8d1ee7f5e72..1d9d6a43ebc 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -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; diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index 8bdb2663465..0863b44b207 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -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; diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c index 1993b033980..a6afcb569f1 100644 --- a/bfd/elf32-mep.c +++ b/bfd/elf32-mep.c @@ -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; diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c index b43f396d61f..8463599775c 100644 --- a/bfd/elf32-moxie.c +++ b/bfd/elf32-moxie.c @@ -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; diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index 285475cf0cc..9a5fb2a9104 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -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; diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c index 9b2758e65e3..a3172bcda01 100644 --- a/bfd/elf32-mt.c +++ b/bfd/elf32-mt.c @@ -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; diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c index af7bc25b041..ada738e066f 100644 --- a/bfd/elf32-openrisc.c +++ b/bfd/elf32-openrisc.c @@ -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; diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 58e98071268..77a9d1e7f7c 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -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) diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 4b31a35a778..d7e15a0e523 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -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) { diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index bc8e054a841..46e9541f07f 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -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; diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index fec177af071..1c08c8ac32b 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -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) { diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c index f780e56ab79..9ce3bf1dea0 100644 --- a/bfd/elf32-score7.c +++ b/bfd/elf32-score7.c @@ -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) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 49376434068..e15f51c20f4 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -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; diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index ed52c64e2df..bcee155fdda 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -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; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 011f32e14df..3d76648836c 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -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) { diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index e153e8305a8..29b2311b181 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -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; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index db67faf850a..78f14ecead2 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -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; diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c index 4d7ee99162f..11d984002b3 100644 --- a/bfd/elf32-xc16x.c +++ b/bfd/elf32-xc16x.c @@ -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) diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 53c40ad4540..09c894e95b1 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -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; diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 6cd396a6bcb..fd412446b3f 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -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) { diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index a6a795ddcdc..aaa6e20771d 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -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; diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index e7e61a1fe68..11289b13916 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -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; diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 3ac4950b5b2..8c00a789fe3 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -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) { diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 2cdb0a265a1..5c35dc159d7 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -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; diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 2f253b93ed2..671cb93a4a5 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -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; diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index d045d90c66e..96923046412 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -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; diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 6b52bc6d713..0ef1a442d9e 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -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; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 8feb5c48379..416890010a4 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -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)) { diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index ebe040f0ffc..33b6f136c2b 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -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; diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index f0d8fba7ff1..91d3bbd4433 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -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. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index c5fa67ffd4d..002937fdc47 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -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. */ diff --git a/bfd/reloc.c b/bfd/reloc.c index 65aa3cb3467..4e95d85f0b9 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -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; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index dbb22bd3b89..d0473623fc6 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-10-25 Daniel Jacobowitz + + * ld-discard/zero-range.d, ld-discard/zero-range.s: New files. + 2010-10-23 Mark Mitchell * ld-elf/group10.d: Expect ".group" for the name of group diff --git a/ld/testsuite/ld-discard/zero-range.d b/ld/testsuite/ld-discard/zero-range.d new file mode 100644 index 00000000000..26b709e3e8c --- /dev/null +++ b/ld/testsuite/ld-discard/zero-range.d @@ -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 .* diff --git a/ld/testsuite/ld-discard/zero-range.s b/ld/testsuite/ld-discard/zero-range.s new file mode 100644 index 00000000000..e16caf46bec --- /dev/null +++ b/ld/testsuite/ld-discard/zero-range.s @@ -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