]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* read.c (emit_expr): Check for overflow of a negative value
authorIan Lance Taylor <ian@airs.com>
Thu, 9 Jan 1997 19:13:42 +0000 (19:13 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 9 Jan 1997 19:13:42 +0000 (19:13 +0000)
correctly.
* write.c (fixup_segment): Likewise.
* config/obj-coff.c (fixup_segment): Likewise.
PR 11411.

gas/ChangeLog
gas/read.c

index adbeaeae049038a5e52ab3ce85a380a22952c2c4..777616304d2cfeb4b0c092f792f7c90a72710072 100644 (file)
@@ -1,5 +1,10 @@
 Thu Jan  9 09:08:43 1997  Ian Lance Taylor  <ian@cygnus.com>
 
+       * read.c (emit_expr): Check for overflow of a negative value
+       correctly.
+       * write.c (fixup_segment): Likewise.
+       * config/obj-coff.c (fixup_segment): Likewise.
+
        * config/tc-m68k.c (struct label_line): Define.
        (labels, current_label): New static variables.
        (md_assemble): Mark current_label as text, and clear it.
index f63bae405c4ce5a1e162b6543d10c37e074b5c74..7488ddcceb25f3ca918152394686ed91ffc8be26 100644 (file)
@@ -3198,14 +3198,25 @@ emit_expr (exp, nbytes)
       register valueT get;
       register valueT use;
       register valueT mask;
+      valueT hibit;
       register valueT unmask;
 
       /* JF << of >= number of bits in the object is undefined.  In
         particular SPARC (Sun 4) has problems */
       if (nbytes >= sizeof (valueT))
-       mask = 0;
+       {
+         mask = 0;
+         if (nbytes > sizeof (valueT))
+           hibit = 0;
+         else
+           hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
+       }
       else
-       mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */
+       {
+         /* Don't store these bits. */
+         mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);
+         hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
+       }
 
       unmask = ~mask;          /* Do store these bits. */
 
@@ -3216,7 +3227,9 @@ emit_expr (exp, nbytes)
 
       get = exp->X_add_number;
       use = get & unmask;
-      if ((get & mask) != 0 && (get & mask) != mask)
+      if ((get & mask) != 0
+         && ((get & mask) != mask
+             || (get & hibit) == 0))
        {               /* Leading bits contain both 0s & 1s. */
          as_warn ("Value 0x%lx truncated to 0x%lx.",
                   (unsigned long) get, (unsigned long) use);