PR26498 UBSAN: elf32-spu.c:2292 left shift overflow

Alan Modra amodra@gmail.com
Wed Aug 26 13:50:55 GMT 2020


	PR 26498
	* elf32-spu.c (find_function_stack_adjust): Use unsigned vars to
	avoid UB left shift.

diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index 13cff2c5e0..167b90d6a2 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -2209,14 +2209,14 @@ find_function_stack_adjust (asection *sec,
 			    bfd_vma *lr_store,
 			    bfd_vma *sp_adjust)
 {
-  int reg[128];
+  int32_t reg[128];
 
   memset (reg, 0, sizeof (reg));
   for ( ; offset + 4 <= sec->size; offset += 4)
     {
       unsigned char buf[4];
       int rt, ra;
-      int imm;
+      uint32_t imm;
 
       /* Assume no relocs on stack adjusing insns.  */
       if (!bfd_get_section_contents (sec->owner, sec, buf, offset, 4))

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list