mn10300: ubsan: shift exponent too large
authorAlan Modra <amodra@gmail.com>
Sun, 30 Aug 2020 22:39:23 +0000 (08:09 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 31 Aug 2020 10:58:08 +0000 (20:28 +0930)
* elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate
alignment from reloc addend after reloc type R_MN10300_ALIGN is
found.

bfd/ChangeLog
bfd/elf-m10300.c

index 31c74bf8bee3485b13becc2ea2e566e0767f7ca4..5d004cd7df03a67f2f367835d882f1c82e654c12 100644 (file)
@@ -1,3 +1,9 @@
+2020-08-31  Alan Modra  <amodra@gmail.com>
+
+       * 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  <amodra@gmail.com>
 
        PR 26435
index 7c63ce4cd12f2898a06ed066fec6472e7b17ec6c..7a2b67569b075c7cacd07a8ee11070b3863079b9 100644 (file)
@@ -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;
+               }
            }
        }
     }