aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog67
-rw-r--r--bfd/elf-bfd.h4
-rw-r--r--bfd/elf-m10200.c11
-rw-r--r--bfd/elf-m10300.c11
-rw-r--r--bfd/elf32-arm.c11
-rw-r--r--bfd/elf32-avr.c11
-rw-r--r--bfd/elf32-bfin.c22
-rw-r--r--bfd/elf32-cr16.c11
-rw-r--r--bfd/elf32-cr16c.c11
-rw-r--r--bfd/elf32-cris.c11
-rw-r--r--bfd/elf32-crx.c11
-rw-r--r--bfd/elf32-d10v.c11
-rw-r--r--bfd/elf32-fr30.c11
-rw-r--r--bfd/elf32-frv.c11
-rw-r--r--bfd/elf32-h8300.c11
-rw-r--r--bfd/elf32-hppa.c15
-rw-r--r--bfd/elf32-i370.c11
-rw-r--r--bfd/elf32-i860.c11
-rw-r--r--bfd/elf32-ip2k.c11
-rw-r--r--bfd/elf32-iq2000.c11
-rw-r--r--bfd/elf32-lm32.c11
-rw-r--r--bfd/elf32-m32c.c11
-rw-r--r--bfd/elf32-m32r.c11
-rw-r--r--bfd/elf32-m68hc1x.c11
-rw-r--r--bfd/elf32-m68k.c11
-rw-r--r--bfd/elf32-mcore.c11
-rw-r--r--bfd/elf32-mep.c11
-rw-r--r--bfd/elf32-moxie.c11
-rw-r--r--bfd/elf32-msp430.c11
-rw-r--r--bfd/elf32-mt.c11
-rw-r--r--bfd/elf32-openrisc.c11
-rw-r--r--bfd/elf32-ppc.c6
-rw-r--r--bfd/elf32-rx.c11
-rw-r--r--bfd/elf32-s390.c11
-rw-r--r--bfd/elf32-score.c11
-rw-r--r--bfd/elf32-score7.c11
-rw-r--r--bfd/elf32-sh.c11
-rw-r--r--bfd/elf32-spu.c11
-rw-r--r--bfd/elf32-tic6x.c11
-rw-r--r--bfd/elf32-v850.c11
-rw-r--r--bfd/elf32-vax.c11
-rw-r--r--bfd/elf32-xc16x.c8
-rw-r--r--bfd/elf32-xstormy16.c11
-rw-r--r--bfd/elf32-xtensa.c11
-rw-r--r--bfd/elf64-alpha.c25
-rw-r--r--bfd/elf64-hppa.c11
-rw-r--r--bfd/elf64-mmix.c11
-rw-r--r--bfd/elf64-ppc.c14
-rw-r--r--bfd/elf64-s390.c11
-rw-r--r--bfd/elf64-sh64.c11
-rw-r--r--bfd/elfxx-ia64.c11
-rw-r--r--bfd/elfxx-mips.c11
-rw-r--r--bfd/elfxx-sparc.c12
-rw-r--r--bfd/libbfd-in.h2
-rw-r--r--bfd/libbfd.h2
-rw-r--r--bfd/reloc.c15
56 files changed, 197 insertions, 479 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 18a3a67..8fbaed2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 0527bbd..e306f8d 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 0fafe55..a38f4db 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 a4da9d5..bdca122 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 739a79d..24a50a3 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 7334340..07568a4 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 ac41d63..237391b 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 4c6e3c0..0118131 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 5016c6e..ca2d7cb 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 f3ed80d..9644e9b 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 11c1f56..d48932d 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 a5e5395..7d65395 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 f96b1f6..97b0d29 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 f6975f3..bce0540 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 e05efbd..95d3983 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 3a3a355..81bc042 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 01f9fb8..a17a0fe 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 41d5e93..00c8ca7 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 2ef22b6..0a251b8 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 4dcc866..63ef3dc 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 49b2130..b6e8ba0 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 c9bfb64..e9cabaa 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 db7dcf9..0b114bd 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 2107486..40b0c86 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 8d1ee7f..1d9d6a4 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 8bdb266..0863b44 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 1993b03..a6afcb5 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 b43f396..8463599 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 285475c..9a5fb2a 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 9b2758e..a3172bc 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 af7bc25..ada738e 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 58e9807..77a9d1e 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 4b31a35..d7e15a0 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 bc8e054..46e9541 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 fec177a..1c08c8a 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 f780e56..9ce3bf1 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 4937643..e15f51c 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 ed52c64..bcee155 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 011f32e..3d76648 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 e153e83..29b2311 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 db67faf..78f14ec 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 4d7ee99..11d9840 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 53c40ad..09c894e 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 6cd396a..fd41244 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 a6a795d..aaa6e20 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 e7e61a1..11289b1 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 3ac4950..8c00a78 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 2cdb0a2..5c35dc1 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 2f253b9..671cb93 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 d045d90..9692304 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 6b52bc6..0ef1a44 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 8feb5c4..4168900 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 ebe040f..33b6f13 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 f0d8fba..91d3bbd 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 c5fa67f..002937f 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 65aa3cb..4e95d85 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;