1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-27 10:03:20 +00:00

Fix undefined behavior in gas/contrib/tc-arm.c's rotate_left() macro,

similar to https://svnweb.freebsd.org/base?view=revision&revision=274856

This fixes possible "invalid constant after fixup" errors from gas, when
it has been compiled with high levels of optimization.

Obtained from:	binutils commit d840c081f8082e8b9e63fead5306643975a97bb3
PR:		197806
Approved by:	maintainer (bapt)
This commit is contained in:
Dimitry Andric 2015-02-18 22:23:06 +00:00
parent db5c3b0a00
commit 739c18f83e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=379320

View File

@ -0,0 +1,17 @@
From d840c081f8082e8b9e63fead5306643975a97bb3 Mon Sep 17 00:00:00 2001
From: Richard Earnshaw <Richard.Earnshaw@arm.com>
Date: Thu, 20 Nov 2014 17:02:47 +0000
Subject: [PATCH] * config/tc-arm.c (rotate_left): Avoid undefined behaviour
when N = 0.
--- gas/config/tc-arm.c.orig 2014-10-14 09:32:03.000000000 +0200
+++ gas/config/tc-arm.c 2015-02-18 21:13:40.720573000 +0100
@@ -7251,7 +7251,7 @@
/* Functions for operand encoding. ARM, then Thumb. */
-#define rotate_left(v, n) (v << n | v >> (32 - n))
+#define rotate_left(v, n) (v << (n & 31) | v >> ((32 - n) & 31))
/* If VAL can be encoded in the immediate field of an ARM instruction,
return the encoded form. Otherwise, return FAIL. */