svn commit: r276229 - head/contrib/binutils/gas
Pedro F. Giffuni
pfg at FreeBSD.org
Fri Dec 26 04:33:54 UTC 2014
Author: pfg
Date: Fri Dec 26 04:33:53 2014
New Revision: 276229
URL: https://svnweb.freebsd.org/changeset/base/276229
Log:
Backport fix for binutils 11867: .quad directive not assembled correctly
Alan Modra (and Alan's employer) graciously permitted use of his patch
under GPLv2.
Obtained from: OpenBSD
MFC after: 5 days
Modified:
head/contrib/binutils/gas/expr.c
head/contrib/binutils/gas/read.c
Modified: head/contrib/binutils/gas/expr.c
==============================================================================
--- head/contrib/binutils/gas/expr.c Fri Dec 26 03:03:41 2014 (r276228)
+++ head/contrib/binutils/gas/expr.c Fri Dec 26 04:33:53 2014 (r276229)
@@ -1040,6 +1040,15 @@ operand (expressionS *expressionP, enum
{
for (i = 0; i < expressionP->X_add_number; ++i)
generic_bignum[i] = ~generic_bignum[i];
+
+ /* Extend the bignum to at least the size of .octa. */
+ if (expressionP->X_add_number < SIZE_OF_LARGE_NUMBER)
+ {
+ expressionP->X_add_number = SIZE_OF_LARGE_NUMBER;
+ for (; i < expressionP->X_add_number; ++i)
+ generic_bignum[i] = ~(LITTLENUM_TYPE) 0;
+ }
+
if (c == '-')
for (i = 0; i < expressionP->X_add_number; ++i)
{
@@ -1050,14 +1059,12 @@ operand (expressionS *expressionP, enum
}
else if (c == '!')
{
- int nonzero = 0;
for (i = 0; i < expressionP->X_add_number; ++i)
- {
- if (generic_bignum[i])
- nonzero = 1;
- generic_bignum[i] = 0;
- }
- generic_bignum[0] = nonzero;
+ if (generic_bignum[i] != 0)
+ break;
+ expressionP->X_add_number = i >= expressionP->X_add_number;
+ expressionP->X_op = O_constant;
+ expressionP->X_unsigned = 1;
}
}
else if (expressionP->X_op != O_illegal
Modified: head/contrib/binutils/gas/read.c
==============================================================================
--- head/contrib/binutils/gas/read.c Fri Dec 26 03:03:41 2014 (r276228)
+++ head/contrib/binutils/gas/read.c Fri Dec 26 04:33:53 2014 (r276229)
@@ -4117,15 +4117,32 @@ emit_expr (expressionS *exp, unsigned in
unsigned int size;
LITTLENUM_TYPE *nums;
- know (nbytes % CHARS_PER_LITTLENUM == 0);
-
size = exp->X_add_number * CHARS_PER_LITTLENUM;
if (nbytes < size)
{
- as_warn (_("bignum truncated to %d bytes"), nbytes);
+ int i = nbytes / CHARS_PER_LITTLENUM;
+ if (i != 0)
+ {
+ LITTLENUM_TYPE sign = 0;
+ if ((generic_bignum[--i]
+ & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) != 0)
+ sign = ~(LITTLENUM_TYPE) 0;
+ while (++i < exp->X_add_number)
+ if (generic_bignum[i] != sign)
+ break;
+ }
+ if (i < exp->X_add_number)
+ as_warn (_("bignum truncated to %d bytes"), nbytes);
size = nbytes;
}
+ if (nbytes == 1)
+ {
+ md_number_to_chars (p, (valueT) generic_bignum[0], 1);
+ return;
+ }
+ know (nbytes % CHARS_PER_LITTLENUM == 0);
+
if (target_big_endian)
{
while (nbytes > size)
More information about the svn-src-all
mailing list