diff options
author | Tristan Gingold <gingold@adacore.com> | 2017-01-09 15:50:32 +0100 |
---|---|---|
committer | Tristan Gingold <gingold@adacore.com> | 2017-01-10 10:23:23 +0100 |
commit | 74def31dcd248441a49755721da81ca73d99c4fb (patch) | |
tree | 8cacf56ca2cd374af1b699f9969f0325cc50ff0d /gas/read.c | |
parent | f7fd19e2b83c06cf1590d2ac8d0e9fc1ea4739c2 (diff) | |
download | fsf-binutils-gdb-74def31dcd248441a49755721da81ca73d99c4fb.zip fsf-binutils-gdb-74def31dcd248441a49755721da81ca73d99c4fb.tar.gz fsf-binutils-gdb-74def31dcd248441a49755721da81ca73d99c4fb.tar.bz2 |
This patch ensure same output for sleb128 with large number.
gas/
* read.c (emit_leb128_expr): Extended unsigned big number for
sleb128.
* testsuite/gas/all/gas.exp (test_cond): Add sleb128-8 test.
* testsuite/gas/all/sleb128.d: New test.
* testsuite/gas/all/sleb128.s: New test source.
Diffstat (limited to 'gas/read.c')
-rw-r--r-- | gas/read.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -5344,13 +5344,21 @@ emit_leb128_expr (expressionS *exp, int sign) else if (op == O_big) { /* O_big is a different sort of constant. */ - + int nbr_digits = exp->X_add_number; unsigned int size; char *p; - size = output_big_leb128 (NULL, generic_bignum, exp->X_add_number, sign); + /* If the leading littenum is 0xffff, prepend a 0 to avoid confusion with + a signed number. Unary operators like - or ~ always extend the + bignum to its largest size. */ + if (exp->X_unsigned + && nbr_digits < SIZE_OF_LARGE_NUMBER + && generic_bignum[nbr_digits - 1] == LITTLENUM_MASK) + generic_bignum[nbr_digits++] = 0; + + size = output_big_leb128 (NULL, generic_bignum, nbr_digits, sign); p = frag_more (size); - if (output_big_leb128 (p, generic_bignum, exp->X_add_number, sign) > size) + if (output_big_leb128 (p, generic_bignum, nbr_digits, sign) > size) abort (); } else |