From b0c82ef0c167580db8d4e8de54454268c41a719a Mon Sep 17 00:00:00 2001 From: dim Date: Sat, 22 Nov 2014 16:30:31 +0000 Subject: Avoid undefined behaviour in gas's rotate_left() macro for n == 0. Otherwise, clang can effectively remove the first iteration of the for loops where this macro is invoked, and as a result, "cmp r0, #99" fails to assemble. Obtained from: joerg at netbsd MFC after: 3 days --- contrib/binutils/gas/config/tc-arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/binutils') diff --git a/contrib/binutils/gas/config/tc-arm.c b/contrib/binutils/gas/config/tc-arm.c index 8b470c0..37c2a90 100644 --- a/contrib/binutils/gas/config/tc-arm.c +++ b/contrib/binutils/gas/config/tc-arm.c @@ -6079,7 +6079,7 @@ parse_operands (char *str, const unsigned char *pattern) /* Functions for operand encoding. ARM, then Thumb. */ -#define rotate_left(v, n) (v << n | v >> (32 - n)) +#define rotate_left(v, n) (v << (n % 32) | v >> ((32 - n) % 32)) /* If VAL can be encoded in the immediate field of an ARM instruction, return the encoded form. Otherwise, return FAIL. */ -- cgit v1.1