mn10300: ubsan: shift exponent too large
Alan Modra
amodra@gmail.com
Mon Aug 31 10:50:21 GMT 2020
* 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/elf-m10300.c b/bfd/elf-m10300.c
index 7c63ce4cd1..7a2b67569b 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -2418,13 +2418,14 @@ 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)
+ {
+ int alignment = 1 << irel->r_addend;
+
+ if (count < alignment
+ || alignment % count != 0)
{
irelalign = irel;
toaddr = irel->r_offset;
@@ -2432,6 +2433,7 @@ mn10300_elf_relax_delete_bytes (bfd *abfd,
}
}
}
+ }
/* Actually delete the bytes. */
memmove (contents + addr, contents + addr + count,
More information about the Binutils
mailing list