summaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-11-19 20:52:32 +0000
committerAlexandre Oliva <aoliva@redhat.com>2002-11-19 20:52:32 +0000
commit2097068f6161e211c3dacc81e0249db1a89caf1f (patch)
treed8de61d1b3317ddf064c4e30768977683ad10620 /bfd/elfxx-mips.c
parenta5f9598ed1f79690793a5dad0d171d08bf8cc0ef (diff)
downloadgdb-2097068f6161e211c3dacc81e0249db1a89caf1f.tar.gz
* elfxx-mips.c (MIPS_RELOC_RELA_P): New macro.
(_bfd_mips_elf_relocate_section): Use it.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 2b27f5671aa..98dfdd85478 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -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)
@@ -5044,7 +5061,10 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
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)
{