[gas]
authorRichard Sandiford <rdsandiford@googlemail.com>
Wed, 4 Jul 2001 09:49:29 +0000 (09:49 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Wed, 4 Jul 2001 09:49:29 +0000 (09:49 +0000)
* config/tc-mips.c (md_apply_fix): Prevent addend from becoming zero
if it's expected to be non-zero.
[gas/testsuite]
* gas/mips/elf-rel3.s: Add zero word to end of file.

gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/ChangeLog
gas/testsuite/gas/mips/elf-rel3.s

index a1731aae356a39f4dcd800374638de9fd8bdd14e..57290b5a02d46e21e7615c9d249dc25f3081e20f 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-04  Richard Sandiford  <rsandifo@redhat.com>
+
+       * config/tc-mips.c (md_apply_fix): Prevent addend from becoming zero
+       if it's expected to be non-zero.
+
 2001-07-03  Nick Clifton  <nickc@cambridge.redhat.com>
 
        * config/tc-sh.c (sh_frob_section): Replace symbol_get_frag() with
index ebe8d7f0fbd86b3c745b475a6c0d5298292f0ece..064a2704c33cb8fde942b6c4ad6de5f4db81fe57 100644 (file)
@@ -9612,9 +9612,44 @@ md_apply_fix (fixP, valueP)
            {
              /* In this case, the bfd_install_relocation routine will
                 incorrectly add the symbol value back in.  We just want
-                the addend to appear in the object file.
-                FIXME: If this makes VALUE zero, we're toast.  */
+                the addend to appear in the object file.  */
              value -= symval;
+
+             /* Make sure the addend is still non-zero.  If it became zero
+                after the last operation, set it to a spurious value and
+                subtract the same value from the object file's contents.  */
+             if (value == 0)
+               {
+                 value = 8;
+
+                 /* The in-place addends for LO16 relocations are signed;
+                    leave the matching HI16 in-place addends as zero.  */
+                 if (fixP->fx_r_type != BFD_RELOC_HI16_S)
+                   {
+                     reloc_howto_type *howto;
+                     bfd_vma contents, mask, field;
+
+                     howto = bfd_reloc_type_lookup (stdoutput,
+                                                    fixP->fx_r_type);
+
+                     contents = bfd_get_bits (fixP->fx_frag->fr_literal
+                                              + fixP->fx_where,
+                                              fixP->fx_size * 8,
+                                              target_big_endian);
+
+                     /* MASK has bits set where the relocation should go.
+                        FIELD is -value, shifted into the appropriate place
+                        for this relocation.  */
+                     mask = 1 << (howto->bitsize - 1);
+                     mask = (((mask - 1) << 1) | 1) << howto->bitpos;
+                     field = (-value >> howto->rightshift) << howto->bitpos;
+
+                     bfd_put_bits ((field & mask) | (contents & ~mask),
+                                   fixP->fx_frag->fr_literal + fixP->fx_where,
+                                   fixP->fx_size * 8,
+                                   target_big_endian);
+                   }
+               }
            }
        }
 
index 449367e1fc1c3982ce2f8c35c7951ece6ebdb29d..22082100e95fb32d274a2f9261028b31fa7f17cd 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-04  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gas/mips/elf-rel3.s: Add zero word to end of file.
+
 2001-07-03  H.J. Lu  <hjl@gnu.org>
 
        * gas/mips/lb-xgot-ilocks.d: Add -march=r3900.
index ddf2bef4d71359af87ef80e485e0f4a94b217ee9..d57e5a89486b7e2e09fd6649113da98ddb4a83fd 100644 (file)
@@ -9,3 +9,4 @@ x:
 b:
        .word   b+4
        .word   x
+       .word   0