wingo pushed a commit to branch master in repository guile. commit ffba9b08c471568f1d7e24a0cae889a954cae515 Author: Andy Wingo <wi...@igalia.com> AuthorDate: Fri Jun 19 16:14:52 2020 +0200
Fix undefined behavior in ARMv7 assembler * lightening/arm-cpu.c (rotate_left): Fix the case of rotating by zero, which produced undefined behavior. Many thanks to Andrew Gierth (andrew at tao11 riddles org uk) for the debugging and the fix. --- lightening/arm-cpu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lightening/arm-cpu.c b/lightening/arm-cpu.c index d96d57b..39123c7 100644 --- a/lightening/arm-cpu.c +++ b/lightening/arm-cpu.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2017, 2019 Free Software Foundation, Inc. + * Copyright (C) 2012-2017,2019-2020 Free Software Foundation, Inc. * * This file is part of GNU lightning. * @@ -193,8 +193,15 @@ emit_wide_thumb(jit_state_t *_jit, uint32_t inst) emit_u16_with_pool(_jit, inst & 0xffff); } -/* from binutils */ -# define rotate_left(v, n) (v << n | v >> (32 - n)) +static uint32_t +rotate_left(uint32_t v, uint32_t n) { + if (n == 0) { + return v; + } + ASSERT(n < 32); + return (v << n | v >> (32 - n)); +} + static int encode_arm_immediate(unsigned int v) {