aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1997-01-09 19:13:42 +0000
committerIan Lance Taylor <ian@airs.com>1997-01-09 19:13:42 +0000
commit6468dabdecc5e692fcd9d179d802ac6c37d985ec (patch)
tree69aa9f539f19efc9d0c248e0fffd394799b56ef9 /gas/read.c
parentd703b5a78346f088ca265c96b58e23b14b220c09 (diff)
downloadgdb-6468dabdecc5e692fcd9d179d802ac6c37d985ec.zip
gdb-6468dabdecc5e692fcd9d179d802ac6c37d985ec.tar.gz
gdb-6468dabdecc5e692fcd9d179d802ac6c37d985ec.tar.bz2
* read.c (emit_expr): Check for overflow of a negative value
correctly. * write.c (fixup_segment): Likewise. * config/obj-coff.c (fixup_segment): Likewise. PR 11411.
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/gas/read.c b/gas/read.c
index f63bae4..7488ddc 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -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);