public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: tc-mips.c:9606 shift exponent 32 is too large
@ 2020-09-02  8:42 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-09-02  8:42 UTC (permalink / raw)
  To: binutils

	* config/tc-mips.c (load_register): Avoid too large shift.

diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 7d0d5a1991..81e2370eee 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -9603,8 +9603,11 @@ load_register (int reg, expressionS *ep, int dbl)
 	      lo >>= 1;
 	      ++bit;
 	    }
-	  lo |= (hi & (((unsigned long) 1 << bit) - 1)) << (32 - bit);
-	  hi >>= bit;
+	  if (bit != 0)
+	    {
+	      lo |= (hi & ((2UL << (bit - 1)) - 1)) << (32 - bit);
+	      hi >>= bit;
+	    }
 	}
       else
 	{
-- 
Alan Modra
Australia Development Lab, IBM


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-02  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02  8:42 ubsan: tc-mips.c:9606 shift exponent 32 is too large Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).