public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Proposal: Switch mips64 from REL to RELA
@ 2001-09-13 22:11 Thiemo Seufer
  2001-09-14  8:30 ` H . J . Lu
  2001-10-04  2:18 ` Eric M. Christopher
  0 siblings, 2 replies; 6+ messages in thread
From: Thiemo Seufer @ 2001-09-13 22:11 UTC (permalink / raw)
  To: binutils

Hi All,

I herewith propose to switch mips64 from REL to RELA as default
relocation type. The reasons are threefold:
  - ABI64 requires it.
  - It allows to produce better code.
  - It makes implementation easier.

The longer story: The ABI64 draft states about AHL operands
(as used in R_MIPS_{HI,LO} with REL):

  "AHL operands are forbidden in a 64-bit SHT_REL section and
   discouraged in a 32-bit SHT_REL section. [...] Also note
   that some relocations (e.g. R_MIPS_HIGHER, R_MIPS_HIGHEST)
   will normally be impossible to specify in a SHT_REL section
   unless the required addend is small."

A cross-check with IRIX 6.5 gave the following behaviour.
The native tools expand

	dla	$4,a+0x100000000

to

	li	at,1
	dsll32	at,at,0x0
	lui	a0,0x0	 	# R_MIPS_HIGHEST (RELA)
	daddiu	a0,a0,0		# R_MIPS_HIGHER (RELA)
	dsll	a0,a0,0x10
	daddiu	a0,a0,0	  	# R_MIPS_HI16 (RELA)
	dsll	a0,a0,0x10
	daddiu	a0,a0,0	  	# R_MIPS_LO16 (REL)
	dadd	a0,a0,at

while my experimental version of gas does already

	lui	a0,0x0		# R_MIPS_HIGHEST (RELA)
	lui	at,0x0		# R_MIPS_HIGHER (RELA)
	daddiu	a0,a0,0		# R_MIPS_HI16 (RELA)
	daddiu	at,at,0		# R_MIPS_LO16 (RELA)
	dsll32	a0,a0,0x0
	dadd	a0,a0,at

which is a critical path length of four instead of seven on a
superscalar processor. They use a REL relocation for R_MIPS_LO16,
which violates their draft standard and requires to add in the
constant early instead of using an addend. It also requires the
R_MIPS_LO16 to follow immediately after R_MIPS_HI16, a case which
is handled in binutils (for 32bit) with a GNU extension to
re-sort the relocations in the expected order.

Using RELA istead of REL as default avoids these problems.
This affects only writing of object files, reading both relocation
types in the same file should remain possible, as required by the
ABI draft and for compatibility with other tools.


Thiemo


2001-09-14  Thiemo Seufer  <seufer@csv.ica.uni-stuttgart.de>

	/bfd/ChangeLog
	* elf64-mips.c (elf_backend_may_use_rela_p): New define.
	(elf_backend_default_use_rela_p): New define.


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/bfd/elf64-mips.c src/bfd/elf64-mips.c
--- src-orig/bfd/elf64-mips.c	Fri Sep  7 06:47:05 2001
+++ src/bfd/elf64-mips.c	Mon Sep 10 03:09:46 2001
@@ -2074,6 +6322,11 @@ const struct elf_size_info mips_elf64_si
 #define elf_backend_got_header_size	(4*MIPS_RESERVED_GOTNO)
 #define elf_backend_plt_header_size	0
-#define elf_backend_may_use_rel_p       1
+
+/* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
+ * work better/work only in RELA, so we default to this.  */
+#define elf_backend_may_use_rel_p	1
+#define elf_backend_may_use_rela_p	1
+#define elf_backend_default_use_rela_p	1
 
 /* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit
    MIPS-specific function only applies to IRIX5, which had no 64-bit

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

* Re: Proposal: Switch mips64 from REL to RELA
  2001-09-13 22:11 Proposal: Switch mips64 from REL to RELA Thiemo Seufer
@ 2001-09-14  8:30 ` H . J . Lu
  2001-09-14 11:15   ` Eric Christopher
  2001-10-04  2:18 ` Eric M. Christopher
  1 sibling, 1 reply; 6+ messages in thread
From: H . J . Lu @ 2001-09-14  8:30 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils

On Fri, Sep 14, 2001 at 07:11:06AM +0200, Thiemo Seufer wrote:
> Hi All,
> 
> I herewith propose to switch mips64 from REL to RELA as default
> relocation type. The reasons are threefold:
>   - ABI64 requires it.
>   - It allows to produce better code.
>   - It makes implementation easier.
> 

Does any current working mips target use the 64bit ELF? As I understand
now, so called "mips64-*" targets just use 32bit ELF with R_MIPS_64.


H.J.

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

* Re: Proposal: Switch mips64 from REL to RELA
  2001-09-14  8:30 ` H . J . Lu
@ 2001-09-14 11:15   ` Eric Christopher
  2001-09-14 11:19     ` H . J . Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Christopher @ 2001-09-14 11:15 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils

> 
> Does any current working mips target use the 64bit ELF? As I understand
> now, so called "mips64-*" targets just use 32bit ELF with R_MIPS_64.

This is correct.

-eric

-- 
Look out behind you!

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

* Re: Proposal: Switch mips64 from REL to RELA
  2001-09-14 11:15   ` Eric Christopher
@ 2001-09-14 11:19     ` H . J . Lu
  2001-09-14 11:32       ` Eric Christopher
  0 siblings, 1 reply; 6+ messages in thread
From: H . J . Lu @ 2001-09-14 11:19 UTC (permalink / raw)
  To: Eric Christopher; +Cc: binutils

On Fri, Sep 14, 2001 at 11:14:53AM -0700, Eric Christopher wrote:
> 
> > 
> > Does any current working mips target use the 64bit ELF? As I understand
> > now, so called "mips64-*" targets just use 32bit ELF with R_MIPS_64.
> 
> This is correct.

In that cae, we should make RELA as default relocation for 64bit mips
ELF.


H.J.

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

* Re: Proposal: Switch mips64 from REL to RELA
  2001-09-14 11:19     ` H . J . Lu
@ 2001-09-14 11:32       ` Eric Christopher
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Christopher @ 2001-09-14 11:32 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils

On Fri, 2001-09-14 at 11:19, H . J . Lu wrote:
> On Fri, Sep 14, 2001 at 11:14:53AM -0700, Eric Christopher wrote:
> > 
> > > 
> > > Does any current working mips target use the 64bit ELF? As I understand
> > > now, so called "mips64-*" targets just use 32bit ELF with R_MIPS_64.
> > 
> > This is correct.
> 
> In that cae, we should make RELA as default relocation for 64bit mips
> ELF.

I don't mind, if anyone has any objections speak now or forever hold
your peace.

-eric

-- 
Look out behind you!

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

* Re: Proposal: Switch mips64 from REL to RELA
  2001-09-13 22:11 Proposal: Switch mips64 from REL to RELA Thiemo Seufer
  2001-09-14  8:30 ` H . J . Lu
@ 2001-10-04  2:18 ` Eric M. Christopher
  1 sibling, 0 replies; 6+ messages in thread
From: Eric M. Christopher @ 2001-10-04  2:18 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils

> 2001-09-14  Thiemo Seufer  <seufer@csv.ica.uni-stuttgart.de>
> 
> 	/bfd/ChangeLog
> 	* elf64-mips.c (elf_backend_may_use_rela_p): New define.
> 	(elf_backend_default_use_rela_p): New define.
> 
> 

Ok.

Make sure you can do a bootstrap on irix with this, but it looks fine.

-eric


-- 
Look out behind you!

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

end of thread, other threads:[~2001-10-04  2:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-13 22:11 Proposal: Switch mips64 from REL to RELA Thiemo Seufer
2001-09-14  8:30 ` H . J . Lu
2001-09-14 11:15   ` Eric Christopher
2001-09-14 11:19     ` H . J . Lu
2001-09-14 11:32       ` Eric Christopher
2001-10-04  2:18 ` Eric M. Christopher

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