+2020-10-29 Nick Clifton <nickc@redhat.com>
+
+ PR 26809
+ * elf.c (_bfd_elf_slurp_secondary_reloc_section): Use the correct
+ sized reloc reading function.
+ (_bfd_elf_write_secondary_reloc_section): Use the correct sized
+ reloc writing function.
+
2020-10-28 Nick Clifton <nickc@redhat.com>
PR 26774
bfd_boolean res;
Elf_Internal_Rela rela;
- ebd->s->swap_reloca_in (abfd, native_reloc, & rela);
+ if (entsize == ebd->s->sizeof_rel)
+ ebd->s->swap_reloc_in (abfd, native_reloc, & rela);
+ else /* entsize == ebd->s->sizeof_rela */
+ ebd->s->swap_reloca_in (abfd, native_reloc, & rela);
/* The address of an ELF reloc is section relative for an object
file, and absolute for an executable file or shared library.
int last_sym_idx;
unsigned int reloc_count;
unsigned int idx;
+ unsigned int entsize;
arelent * src_irel;
bfd_byte * dst_rela;
continue;
}
- if (hdr->sh_entsize == 0)
+ entsize = hdr->sh_entsize;
+ if (entsize == 0)
{
_bfd_error_handler
/* xgettext:c-format */
result = FALSE;
continue;
}
+ else if (entsize != ebd->s->sizeof_rel
+ && entsize != ebd->s->sizeof_rela)
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA): error: secondary reloc section has non-standard sized entries"),
+ abfd, relsec);
+ bfd_set_error (bfd_error_bad_value);
+ result = FALSE;
+ continue;
+ }
- reloc_count = hdr->sh_size / hdr->sh_entsize;
+ reloc_count = hdr->sh_size / entsize;
if (reloc_count <= 0)
{
_bfd_error_handler
continue;
}
- for (idx = 0; idx < reloc_count; idx++, dst_rela += hdr->sh_entsize)
+ for (idx = 0; idx < reloc_count; idx++, dst_rela += entsize)
{
Elf_Internal_Rela src_rela;
arelent *ptr;
else
src_rela.r_info = r_info (n, ptr->howto->type);
src_rela.r_addend = ptr->addend;
- ebd->s->swap_reloca_out (abfd, &src_rela, dst_rela);
+
+ if (entsize == ebd->s->sizeof_rel)
+ ebd->s->swap_reloc_out (abfd, &src_rela, dst_rela);
+ else /* entsize == ebd->s->sizeof_rela */
+ ebd->s->swap_reloca_out (abfd, &src_rela, dst_rela);
}
}
}