From: Alan Modra Date: Sun, 30 Aug 2020 22:39:23 +0000 (+0930) Subject: mn10300: ubsan: shift exponent too large X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8f383897b69c58e02bc447b3c0813361f04bdc1e;p=binutils-gdb.git mn10300: ubsan: shift exponent too large * elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate alignment from reloc addend after reloc type R_MN10300_ALIGN is found. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 31c74bf8bee..5d004cd7df0 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-08-31 Alan Modra + + * elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate + alignment from reloc addend after reloc type R_MN10300_ALIGN is + found. + 2020-08-30 Alan Modra PR 26435 diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 7c63ce4cd12..7a2b67569b0 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -2418,17 +2418,19 @@ mn10300_elf_relax_delete_bytes (bfd *abfd, are deleting. */ for (; irel < irelend; irel++) { - int alignment = 1 << irel->r_addend; - if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_ALIGN && irel->r_offset > addr - && irel->r_offset < toaddr - && (count < alignment - || alignment % count != 0)) + && irel->r_offset < toaddr) { - irelalign = irel; - toaddr = irel->r_offset; - break; + int alignment = 1 << irel->r_addend; + + if (count < alignment + || alignment % count != 0) + { + irelalign = irel; + toaddr = irel->r_offset; + break; + } } } }