[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] gas value truncation warning reports truncated values, doesn't l
From: |
Bart Samwel |
Subject: |
[PATCH] gas value truncation warning reports truncated values, doesn't look at signedness. |
Date: |
Sun, 11 Jan 2004 15:11:57 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031221 Thunderbird/0.4 |
Hi guys,
We've had a discussion on the linux-kernel mailing list about a warning
that was generated by gas. The warning was correct, but it reported the
same value for the truncated and the original value. It turns out that
the warning prints unsigned longs, while the truncated values were
unsigned long longs. Then I found another issue: the warning is issued
for ~0x80000000 (which is correct, because this yields
0xffffffff7fffffff) but not for ~0x7fffffff (which is incorrect, because
this yields 0xffffffff80000000). The problem: the warning code assumes
that the value is signed, even if it is really unsigned (like ~0x7fffffff).
The attached patch (against binutils 2.14) fixes this by upgrading the
warning's format string to %Lx, and by taking into account the
(un)signedness of the truncated value (through exp->X_unsigned). I hope
this helps you to fix the problem.
If you reply to this message, please send it to my personal address as
well, as I'm not subscribed to the list. Thanks!
-- Bart
diff -aur binutils-2.14.orig/gas/read.c binutils-2.14/gas/read.c
--- binutils-2.14.orig/gas/read.c 2003-06-02 22:35:23.000000000 +0200
+++ binutils-2.14/gas/read.c 2004-01-11 15:03:33.000000000 +0100
@@ -3641,11 +3641,12 @@
get = exp->X_add_number;
use = get & unmask;
if ((get & mask) != 0
- && ((get & mask) != mask
+ && (exp->X_unsigned
+ || (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);
+ as_warn (_("value 0x%Lx truncated to 0x%Lx"),
+ (unsigned long long) get, (unsigned long long) use);
}
/* Put bytes in right order. */
md_number_to_chars (p, use, (int) nbytes);
- [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness.,
Bart Samwel <=
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Alan Modra, 2004/01/11
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Bart Samwel, 2004/01/11
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Bart Samwel, 2004/01/11
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Alan Modra, 2004/01/11
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Bart Samwel, 2004/01/12
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Alan Modra, 2004/01/12
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Bart Samwel, 2004/01/12
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Alan Modra, 2004/01/12
- Re: [PATCH] gas value truncation warning reports truncated values, doesn't look at signedness., Bart Samwel, 2004/01/12