PR gas/3041
authorNick Clifton <nickc@redhat.com>
Thu, 3 May 2007 15:55:38 +0000 (15:55 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 3 May 2007 15:55:38 +0000 (15:55 +0000)
* 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.

bfd/ChangeLog
bfd/aoutx.h
gas/ChangeLog
gas/config/tc-m68k.c

index 1c00088371e3a1754e93b1d261d4ac07c80de20c..00ae68efa8124b731ea7f74423c5cd5b7ebd923b 100644 (file)
@@ -1,3 +1,10 @@
+2007-05-03  Vincent Riviere  <vincent.riviere@freesbee.fr>
+           Nick Clifton  <nickc@redhat.com>
+
+       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  <amodra@bigpond.net.au>
 
        * elf.c (assign_file_positions_for_load_sections): Set sh_offset
index 98d5213234fab20e50d9803bf44f0f8ae8f76a96..09331aa0ca24d2924de8a3b87b256262aa0f9726 100644 (file)
@@ -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)
        {
index f0a4faafc2e5514aa9c5380aad61b75dfc115a6b..3a38e5ede5ba395106312233fa14dcdade76ab34 100644 (file)
@@ -1,3 +1,12 @@
+2007-05-03  Vincent Riviere  <vincent.riviere@freesbee.fr>
+           Nick Clifton  <nickc@redhat.com>
+
+       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  <amodra@bigpond.net.au>
 
        PR 4448
index fedbafcc56c0b3b2bda8d7cf6414864d954020a0..dd95139f1b4e531f2bdb044cfe904df52ef7f4c7 100644 (file)
@@ -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
This page took 0.055061 seconds and 4 git commands to generate.