From: Nick Clifton Date: Thu, 3 May 2007 15:55:38 +0000 (+0000) Subject: PR gas/3041 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22184a77bedbe9a50b48f0bc50ff1f8898699a39;p=binutils-gdb.git PR gas/3041 * gas/config/tc-m68k.c (relaxable_symbol): Do not relax weak symbols. (tc_gen_reloc): Adjust the addend of relocs against weak symbols. (md_apply_fix): Put zero values into the frags referencing weak symbols. * bfd/aoutx.h (swap_std_reloc_out): Treat relocs against weak symbols in the same way as relocs against external symbols. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1c00088371e..00ae68efa81 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2007-05-03 Vincent Riviere + Nick Clifton + + PR gas/3041 + * aoutx.h (swap_std_reloc_out): Treat relocs against weak symbols + in the same way as relocs against external symbols. + 2007-05-02 Alan Modra * elf.c (assign_file_positions_for_load_sections): Set sh_offset diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 98d5213234f..09331aa0ca2 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1952,7 +1952,10 @@ NAME (aout, swap_std_reloc_out) (bfd *abfd, if (bfd_is_com_section (output_section) || bfd_is_abs_section (output_section) - || bfd_is_und_section (output_section)) + || bfd_is_und_section (output_section) + /* PR gas/3041 a.out relocs against weak symbols + must be treated as if they were against externs. */ + || (sym->flags & BSF_WEAK)) { if (bfd_abs_section_ptr->symbol == sym) { diff --git a/gas/ChangeLog b/gas/ChangeLog index f0a4faafc2e..3a38e5ede5b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2007-05-03 Vincent Riviere + Nick Clifton + + PR gas/3041 + * config/tc-m68k.c (relaxable_symbol): Do not relax weak symbols. + (tc_gen_reloc): Adjust the addend of relocs against weak symbols. + (md_apply_fix): Put zero values into the frags referencing weak + symbols. + 2007-05-02 Alan Modra PR 4448 diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index fedbafcc56c..dd95139f1b4 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -1,6 +1,6 @@ /* tc-m68k.c -- Assemble for the m68k family Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -1059,7 +1059,9 @@ tc_m68k_fix_adjustable (fixS *fixP) #define get_reloc_code(SIZE,PCREL,OTHER) NO_RELOC -#define relaxable_symbol(symbol) 1 +/* PR gas/3041 Weak symbols are not relaxable + because they must be treated as extern. */ +#define relaxable_symbol(symbol) (!(S_IS_WEAK (symbol))) #endif /* OBJ_ELF */ @@ -1153,6 +1155,13 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) #ifndef OBJ_ELF if (fixp->fx_pcrel) reloc->addend = fixp->fx_addnumber; + else if (OUTPUT_FLAVOR == bfd_target_aout_flavour + && fixp->fx_addsy + && S_IS_WEAK (fixp->fx_addsy) + && ! bfd_is_und_section (S_GET_SEGMENT (fixp->fx_addsy))) + /* PR gas/3041 Adjust addend in order to force bfd_install_relocation() + to put a zero value into frags referencing a weak symbol. */ + reloc->addend = - S_GET_VALUE (fixp->fx_addsy); else reloc->addend = 0; #else @@ -4692,6 +4701,13 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) S_SET_WEAK (fixP->fx_addsy); return; } +#elif defined(OBJ_AOUT) + /* PR gas/3041 Always put zero values into frags referencing a weak symbol. */ + if (fixP->fx_addsy && S_IS_WEAK (fixP->fx_addsy)) + { + memset (buf, 0, fixP->fx_size); + return; + } #endif if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT