This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
mips newabi rel/rela detection
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: 19 Nov 2002 17:03:27 -0200
- Subject: mips newabi rel/rela detection
- Organization: GCC Team, Red Hat
This patch fixes a number of problems I've encountered while
attempting to bootstrap a toolchain on IRIX6, using the SGI toolchain
as the bootstrap tools. The problem is that the SGI assembler uses
REL relocations in a number of situations, but since we assumed all
NEWABI relocations were RELA, we ended up dropping the in-place
addends.
This patch works even if a single section has both rel and rela
sections, regardless of their order of appearance, as long as there
are not two rel or two rela relocation sections for the same section
(I'm not even sure this is possible). I'm still checking whether this
was the last bootstrapping problem on IRIX6, but I don't see a reason
to not submit this before the bootstrap on IRIX completes (it's still
going to take a couple of hours), since I've already tested this on
another mips64 port.
Ok to install?
Index: bfd/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* elfxx-mips.c (MIPS_RELOC_RELA_P): New macro.
(_bfd_mips_elf_relocate_section): Use it.
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.29
diff -u -p -r1.29 elfxx-mips.c
--- bfd/elfxx-mips.c 22 Oct 2002 22:17:11 -0000 1.29
+++ bfd/elfxx-mips.c 19 Nov 2002 18:57:26 -0000
@@ -443,6 +443,23 @@ static bfd *reldyn_sorting_bfd;
#define MIPS_ELF_RTYPE_TO_HOWTO(abfd, rtype, rela) \
(get_elf_backend_data (abfd)->elf_backend_mips_rtype_to_howto (rtype, rela))
+/* Determine whether the internal relocation of index REL_IDX is REL
+ (zero) or RELA (non-zero). The assumption is that, if there are
+ two relocation sections for this section, one of them is REL and
+ the other is RELA. If the index of the relocation we're testing is
+ in range for the first relocation section, check that the external
+ relocation size is that for RELA. It is also assumed that, if
+ rel_idx is not in range for the first section, and this first
+ section contains REL relocs, then the relocation is in the second
+ section, that is RELA. */
+#define MIPS_RELOC_RELA_P(abfd, sec, rel_idx) \
+ ((NUM_SHDR_ENTRIES (&elf_section_data (sec)->rel_hdr) \
+ * get_elf_backend_data (abfd)->s->int_rels_per_ext_rel \
+ > (bfd_vma)(rel_idx)) \
+ == (elf_section_data (sec)->rel_hdr.sh_entsize \
+ == (ABI_64_P (abfd) ? sizeof (Elf64_External_Rela) \
+ : sizeof (Elf32_External_Rela))))
+
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
from smaller values. Start with zero, widen, *then* decrement. */
#define MINUS_ONE (((bfd_vma)0) - 1)
@@ -5041,7 +5058,10 @@ _bfd_mips_elf_relocate_section (output_b
else
/* NewABI defaults to RELA relocations. */
howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, r_type,
- NEWABI_P (input_bfd));
+ NEWABI_P (input_bfd)
+ && (MIPS_RELOC_RELA_P
+ (input_bfd, input_section,
+ rel - relocs)));
if (!use_saved_addend_p)
{
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer