public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping)
@ 2005-02-24 22:31 Maciej W. Rozycki
  2005-02-26  9:40 ` Eric Christopher
  2005-02-28 10:27 ` Richard Sandiford
  0 siblings, 2 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2005-02-24 22:31 UTC (permalink / raw)
  To: binutils

Hello,

 I've reviewed my pile of patches due to the close 2.16 branch and this
patch is still needed.  OK to apply?

  Maciej

---------- Forwarded message ----------
Message-ID: <Pine.LNX.4.55.0406281823190.23162@jurand.ds.pg.gda.pl>
Date: Mon, 28 Jun 2004 18:47:46 +0200 (CEST)
From: Maciej W. Rozycki <macro@linux-mips.org>
To: binutils@sources.redhat.com
Subject: [patch] MIPS: Use the right offset for LO16 in
    add_got_offset_hilo()

Hello,

 This is a follow-on patch to the "mips-hilo-reloc-sort" one.  It changes
add_got_offset_hilo() to use the same addend for the LO16 relocation it
emits that is used for the preceding GOT16 one.  It's required for the two 
relocations to pair.

2004-06-28  Maciej W. Rozycki  <macro@linux-mips.org>

	* config/tc-mips.c (add_got_offset_hilo): Fix the addend used for 
	the LO16 reloc so that it pairs with thepreceding GOT16 one.

 This has been tested for the mipsel-linux-gnu target with no new 
regressions and fixing failures revealed by the "mips-hilo-reloc-sort" 
patch in the "la-svr4pic", "lca-svr4pic" and "elf-rel19" test cases.

 OK to apply?

  Maciej

binutils-2.15.91-20040625-mips-reloc-got-offset.patch
diff -up --recursive --new-file binutils-2.15.91-20040625.macro/gas/config/tc-mips.c binutils-2.15.91-20040625/gas/config/tc-mips.c
--- binutils-2.15.91-20040625.macro/gas/config/tc-mips.c	2004-06-15 03:25:28.000000000 +0000
+++ binutils-2.15.91-20040625/gas/config/tc-mips.c	2004-06-28 00:15:46.000000000 +0000
@@ -4104,7 +4104,9 @@ add_got_offset_hilo (int dest, expressio
   mips_optimize = 2;
   macro_build_lui (&global, tmp);
   mips_optimize = hold_mips_optimize;
+  local->X_add_number = ((local->X_add_number + 0x8000) & 0xffff) - 0x8000;
   macro_build (local, ADDRESS_ADDI_INSN, "t,r,j", tmp, tmp, BFD_RELOC_LO16);
+  local->X_add_number = global.X_add_number;
   relax_end ();
 
   macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", dest, dest, tmp);

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

* Re: [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping)
  2005-02-24 22:31 [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping) Maciej W. Rozycki
@ 2005-02-26  9:40 ` Eric Christopher
  2005-02-28 10:27 ` Richard Sandiford
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Christopher @ 2005-02-26  9:40 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

On Thu, 2005-02-24 at 20:06 +0000, Maciej W. Rozycki wrote:
> Hello,
> 
>  I've reviewed my pile of patches due to the close 2.16 branch and this
> patch is still needed.  OK to apply?

>  This has been tested for the mipsel-linux-gnu target with no new 
> regressions and fixing failures revealed by the "mips-hilo-reloc-sort" 
> patch in the "la-svr4pic", "lca-svr4pic" and "elf-rel19" test cases.

Since I don't think these are failing anymore how about a new testcase
for it?

-eric

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

* Re: [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping)
  2005-02-24 22:31 [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping) Maciej W. Rozycki
  2005-02-26  9:40 ` Eric Christopher
@ 2005-02-28 10:27 ` Richard Sandiford
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2005-02-28 10:27 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@linux-mips.org> writes:
> @@ -4104,7 +4104,9 @@ add_got_offset_hilo (int dest, expressio
>    mips_optimize = 2;
>    macro_build_lui (&global, tmp);
>    mips_optimize = hold_mips_optimize;
> +  local->X_add_number = ((local->X_add_number + 0x8000) & 0xffff) - 0x8000;
>    macro_build (local, ADDRESS_ADDI_INSN, "t,r,j", tmp, tmp, BFD_RELOC_LO16);
> +  local->X_add_number = global.X_add_number;
>    relax_end ();
>  
>    macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", dest, dest, tmp);

You asked about this patch in the other thread, so FWIW, I agree that
it does the right thing.  Obviously I can't approve it though.

My main concern is that it seems to leave things in a slightly
inconsistent state.  In the case of load_got_offset, it's the caller
that adjusts the GOT16 offset:

	      expr1.X_add_number = offset_expr.X_add_number;
	      offset_expr.X_add_number =
		((offset_expr.X_add_number + 0x8000) & 0xffff) - 0x8000;
	      load_got_offset (tempreg, &offset_expr);
	      offset_expr.X_add_number = expr1.X_add_number;

whereas the patch makes the callee adjust the LO16 offset.  I had to
stare at the patch for a while before realising that the new code is
compensating for an adjustment made by the _caller_ of load_got_offset,
not load_got_offset itself.

I agree that hiding this adjustment in add_got_offset_hilo is the right
way to go.  However, it might be better to move the offset_expr adjustment
into load_got_offset at the same time.

Richard

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

end of thread, other threads:[~2005-02-27 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 22:31 [patch] MIPS: Use the right offset for LO16 in add_got_offset_hilo() (ping) Maciej W. Rozycki
2005-02-26  9:40 ` Eric Christopher
2005-02-28 10:27 ` Richard Sandiford

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).