This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix MIPS ELF64 problem with .gpword/.8byte combinations


Richard Sandiford wrote:
[snip]
> >> + macro_read_relocs (va_list *args, bfd_reloc_code_real_type *r)
> >> + {
> >> +   int i, next;
> >> + 
> >> +   next = va_arg (*args, int);
> >> +   if (next >= 0)
> >> +     r[0] = (bfd_reloc_code_real_type) next;
> >> +   else
> >> +     for (i = 0; i < 3; i++)
> >> +       r[i] = (bfd_reloc_code_real_type) va_arg (*args, int);
> >> + }
> >
> > AFAICS this is likely to cause breakage if we have to support combined
> > dual relocs.
> 
> Why?  Just pass BFD_RELOC_UNUSED as the third code.

And if this isn't done, macro_read_relocs has no way to find it out and
complain about it. Hm, probably it should pass the reloc count as a
negative number, so that ..., RELOC_FOO); and ..., -1, RELOC_FOO);
become equivalents, and ..., -2, RELOC_FOO, RELOC_BAR); would be used
for two relocs.

It might also be a good idea to always blank out the rest of the
relocs. Comments?


Thiemo


Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.273
diff -u -p -r1.273 tc-mips.c
--- gas/config/tc-mips.c	7 Oct 2004 22:29:18 -0000	1.273
+++ gas/config/tc-mips.c	8 Oct 2004 13:26:53 -0000
@@ -2973,8 +2973,8 @@ macro_end (void)
 
 /* Read a macro's relocation codes from *ARGS and store them in *R.
    The first argument in *ARGS will be either the code for a single
-   relocation or -1 followed by the three codes that make up a
-   composite relocation.  */
+   relocation or the negative count of relocations followed by up to
+   three codes that make up a composite relocation.  */
 
 static void
 macro_read_relocs (va_list *args, bfd_reloc_code_real_type *r)
@@ -2983,10 +2983,17 @@ macro_read_relocs (va_list *args, bfd_re
 
   next = va_arg (*args, int);
   if (next >= 0)
-    r[0] = (bfd_reloc_code_real_type) next;
+    {
+      r[0] = (bfd_reloc_code_real_type) next;
+      r[1] = BFD_RELOC_UNUSED;
+      r[2] = BFD_RELOC_UNUSED;
+    }
   else
     for (i = 0; i < 3; i++)
-      r[i] = (bfd_reloc_code_real_type) va_arg (*args, int);
+      if (i < -next)
+	r[i] = (bfd_reloc_code_real_type) va_arg (*args, int);
+      else
+	r[i] = BFD_RELOC_UNUSED;
 }
 
 /* Build an instruction created by a macro expansion.  This is passed
@@ -11907,10 +11914,10 @@ s_cpsetup (int ignore ATTRIBUTE_UNUSED)
 		 mips_gp_register, 0);
 
   macro_build (&ex_sym, "lui", "t,u", mips_gp_register,
-	       -1, BFD_RELOC_GPREL16, BFD_RELOC_MIPS_SUB, BFD_RELOC_HI16_S);
+	       -3, BFD_RELOC_GPREL16, BFD_RELOC_MIPS_SUB, BFD_RELOC_HI16_S);
 
   macro_build (&ex_sym, "addiu", "t,r,j", mips_gp_register,
-	       mips_gp_register, -1, BFD_RELOC_GPREL16,
+	       mips_gp_register, -3, BFD_RELOC_GPREL16,
 	       BFD_RELOC_MIPS_SUB, BFD_RELOC_LO16);
 
   macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", mips_gp_register,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]