public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores
@ 2010-10-03 19:40 Maciej W. Rozycki
  2010-10-04 20:21 ` Richard Sandiford
  0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2010-10-03 19:40 UTC (permalink / raw)
  To: binutils

Hi,

 This is a fix for the original issue that made me prepare this series of 
patches.  We have a problem with some doubleword memory access macros such 
as LD.  

 Considering the following program:

$ cat ld.s
	ld	$4,foo+4096

we get the following output:

$ mips-linux-as -32 -o ld.o ld.s
$ mips-linux-objdump -dr ld.o

ld.o:     file format elf32-tradbigmips


Disassembly of section .text:

00000000 <.text>:
   0:	3c010000 	lui	at,0x0
   4:	8c24fffc 	lw	a0,-4(at)
   8:	8c250000 	lw	a1,0(at)
   c:	00000000 	nop

Oops!

 This is fixed by the following change.  It looks like a piece of leftover 
code from old relaxation support has stayed and triggers when a forward 
reference turns out to require absolute addressing.  It also shows how our 
test coverage for these macros is insufficient.  Improving the coverage 
will be the point of the following patches.

2010-10-03  Maciej W. Rozycki  <macro@linux-mips.org>

	gas/
	* config/tc-mips.c (macro)[ldd_std]: Fix the relaxation variant 
	for absolute addressing.

 OK to apply?

  Maciej

binutils-2.20.51-20100925-mips-l-d-reloc.patch
Index: binutils-2.20.51/gas/config/tc-mips.c
===================================================================
--- binutils-2.20.51.orig/gas/config/tc-mips.c
+++ binutils-2.20.51/gas/config/tc-mips.c
@@ -7200,26 +7200,7 @@ macro (struct mips_cl_insn *ip)
 
 	      relax_switch ();
 
-	      /* We just generated two relocs.  When tc_gen_reloc
-		 handles this case, it will skip the first reloc and
-		 handle the second.  The second reloc already has an
-		 extra addend of 4, which we added above.  We must
-		 subtract it out, and then subtract another 4 to make
-		 the first reloc come out right.  The second reloc
-		 will come out right because we are going to add 4 to
-		 offset_expr when we build its instruction below.
-
-		 If we have a symbol, then we don't want to include
-		 the offset, because it will wind up being included
-		 when we generate the reloc.  */
-
-	      if (offset_expr.X_op == O_constant)
-		offset_expr.X_add_number -= 8;
-	      else
-		{
-		  offset_expr.X_add_number = -4;
-		  offset_expr.X_op = O_constant;
-		}
+	      offset_expr.X_add_number -= 4;
 	    }
 	  used_at = 1;
 	  macro_build_lui (&offset_expr, AT);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores
  2010-10-03 19:40 [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores Maciej W. Rozycki
@ 2010-10-04 20:21 ` Richard Sandiford
  2010-10-18  0:19   ` Maciej W. Rozycki
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2010-10-04 20:21 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@linux-mips.org> writes:
> 2010-10-03  Maciej W. Rozycki  <macro@linux-mips.org>
>
> 	gas/
> 	* config/tc-mips.c (macro)[ldd_std]: Fix the relaxation variant 
> 	for absolute addressing.

OK, thanks.

Richard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores
  2010-10-04 20:21 ` Richard Sandiford
@ 2010-10-18  0:19   ` Maciej W. Rozycki
  0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2010-10-18  0:19 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

On Mon, 4 Oct 2010, Richard Sandiford wrote:

> OK, thanks.

 Committed now, thanks.

  Maciej

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-18  0:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-03 19:40 [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores Maciej W. Rozycki
2010-10-04 20:21 ` Richard Sandiford
2010-10-18  0:19   ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).