From 2d0ce6779c25fb28b3b35cee02871b9a8d4cd29b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 26 Aug 2020 20:02:07 +0930 Subject: [PATCH] PR26498 UBSAN: elf32-spu.c:2292 left shift overflow PR 26498 * elf32-spu.c (find_function_stack_adjust): Use unsigned vars to avoid UB left shift. --- bfd/ChangeLog | 6 ++++++ bfd/elf32-spu.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index cbce5be495a..1cd7943abc3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-08-26 Alan Modra + + PR 26498 + * elf32-spu.c (find_function_stack_adjust): Use unsigned vars to + avoid UB left shift. + 2020-08-26 Alan Modra PR 26484 diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index 13cff2c5e09..167b90d6a2f 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)) -- 2.30.2