* config/tc-mips.c (append_insn): Set fx_tcbit for composite relocs.
authorRichard Sandiford <rdsandiford@googlemail.com>
Thu, 7 Oct 2004 19:12:54 +0000 (19:12 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Thu, 7 Oct 2004 19:12:54 +0000 (19:12 +0000)
(md_apply_fix3): Don't treat composite relocs as done.

gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/ChangeLog
gas/testsuite/gas/mips/elf-rel21.d [new file with mode: 0644]
gas/testsuite/gas/mips/elf-rel21.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp

index 889cc59b76f91fa9c0f71b0952d586a22e94ad8a..bb63104c8ad12b843660e04340acee0eff6b16bd 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-07  Richard Sandiford  <rsandifo@redhat.com>
+
+       * config/tc-mips.c (append_insn): Set fx_tcbit for composite relocs.
+       (md_apply_fix3): Don't treat composite relocs as done.
+
 2004-10-07  Jan Beulich <jbeulich@novell.com>
 
        * macro.c (macro_expand_body): When ELF, use .LL rather than LL as
index b5aca914d1e70a4c52ff11f8355d97f41527b5d9..752a23a717a2ebefed755fac7a02f1fdd8d76070 100644 (file)
@@ -2231,6 +2231,10 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr,
                fixp[i] = fix_new_exp (frag_now, fixp[0]->fx_where,
                                       fixp[0]->fx_size, address_expr,
                                       FALSE, reloc_type[i]);
+
+               /* Use fx_tcbit to mark compound relocs.  */
+               fixp[0]->fx_tcbit = 1;
+               fixp[i]->fx_tcbit = 1;
              }
        }
     }
@@ -10897,7 +10901,6 @@ md_apply_fix3 (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 {
   bfd_byte *buf;
   long insn;
-  static int previous_fx_r_type = 0;
   reloc_howto_type *howto;
 
   /* We ignore generic BFD relocations we don't know about.  */
@@ -10915,18 +10918,20 @@ md_apply_fix3 (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 
   buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
 
-  /* We are not done if this is a composite relocation to set up gp.  */
   assert (! fixP->fx_pcrel);
-  if (fixP->fx_addsy == NULL
-      && !(fixP->fx_r_type == BFD_RELOC_MIPS_SUB
-          || (fixP->fx_r_type == BFD_RELOC_64
-              && (previous_fx_r_type == BFD_RELOC_GPREL32
-                  || previous_fx_r_type == BFD_RELOC_GPREL16))
-          || (previous_fx_r_type == BFD_RELOC_MIPS_SUB
-              && (fixP->fx_r_type == BFD_RELOC_HI16_S
-                  || fixP->fx_r_type == BFD_RELOC_LO16))))
+
+  /* Don't treat parts of a composite relocation as done.  There are two
+     reasons for this:
+
+     (1) The second and third parts will be against 0 (RSS_UNDEF) but
+        should nevertheless be emitted if the first part is.
+
+     (2) In normal usage, composite relocations are never assembly-time
+        constants.  The easiest way of dealing with the pathological
+        exceptions is to generate a relocation against STN_UNDEF and
+        leave everything up to the linker.  */
+  if (fixP->fx_addsy == NULL && fixP->fx_tcbit == 0)
     fixP->fx_done = 1;
-  previous_fx_r_type = fixP->fx_r_type;
 
   switch (fixP->fx_r_type)
     {
index 23ff4d943bbb5992c53aac60835e9f64708aeadd..647a124bca3b43b5e06f2f60a702654ec2a142f1 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-07  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gas/mips/elf-rel21.[sd]: New test.
+       * gas/mips/mips.exp: Run it.
+
 2004-10-07  Jan Beulich  <jbeulich@novell.com>
 
        * gas/cfi/cfi-common-4.[ds]: New.
diff --git a/gas/testsuite/gas/mips/elf-rel21.d b/gas/testsuite/gas/mips/elf-rel21.d
new file mode 100644 (file)
index 0000000..31e4d23
--- /dev/null
@@ -0,0 +1,9 @@
+#as: -march=mips3 -mabi=64
+#readelf: --relocs
+#name: MIPS ELF reloc 21
+
+Relocation section '\.rela\.data' .*:
+.*
+.* R_MIPS_GPREL32 * 0+00 * \.data \+ c
+ * Type2: R_MIPS_NONE *
+ * Type3: R_MIPS_NONE *
diff --git a/gas/testsuite/gas/mips/elf-rel21.s b/gas/testsuite/gas/mips/elf-rel21.s
new file mode 100644 (file)
index 0000000..b614b17
--- /dev/null
@@ -0,0 +1,7 @@
+       .abicalls
+       .data
+       .gpword foo
+       .8byte  bar - foo
+foo:
+       .word   0
+bar:
index bd36ec244eb88fba446a19176dfa1fbf86361aa2..ad3c83c7ab3016dbc22e4f84e0f4a8b02bf29ef3 100644 (file)
@@ -662,6 +662,9 @@ if { [istarget mips*-*-*] } then {
        }
        run_dump_test "elf-rel19"
        run_dump_test "elf-rel20"
+       if $has_newabi {
+           run_dump_test "elf-rel21"
+       }
 
        if { !$no_mips16 } {
            run_dump_test "${tmips}mips${el}16-e"