This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Proposal: Switch mips64 from REL to RELA
- To: binutils at sources dot redhat dot com
- Subject: Proposal: Switch mips64 from REL to RELA
- From: Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de>
- Date: Fri, 14 Sep 2001 07:11:06 +0200
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