aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorLifang Xia <lifang_xia@c-sky.com>2021-08-10 11:16:57 +0800
committerLifang Xia <lifang_xia@c-sky.com>2021-08-13 14:13:58 +0800
commit1374be23274d0d569ca160b8172b2c02fc37becc (patch)
tree0fdc9b02fafdfa1bb46b1eb8255ea99aea3491f2 /opcodes
parentaf29a8abcf50ff9cb465a136c68b06bfc2ca7b75 (diff)
downloadbinutils-1374be23274d0d569ca160b8172b2c02fc37becc.zip
binutils-1374be23274d0d569ca160b8172b2c02fc37becc.tar.gz
binutils-1374be23274d0d569ca160b8172b2c02fc37becc.tar.bz2
PR28168: [CSKY] Fix stack overflow in disassembler
PR 28168: Stack overflow with a large float. %f is not a goot choice for this. %f should be replaced with %.7g. gas/ * testsuite/gas/csky/pr28168.d: New testcase for PR 28168. * testsuite/gas/csky/pr28168.s: Likewise. * testsuite/gas/csky/v2_float_part2.d: Following the new format. * opcodes/csky-dis.c (csky_output_operand): %.7g replaces %f.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/csky-dis.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index cdd911b..cca8d36 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -565,7 +565,7 @@ csky_output_operand (char *str, struct operand const *oprnd,
? &floatformat_ieee_double_big
: &floatformat_ieee_double_little),
ibytes, &f);
- sprintf (buf, "%f", f);
+ sprintf (buf, "%.7g", f);
}
else
{
@@ -645,7 +645,7 @@ csky_output_operand (char *str, struct operand const *oprnd,
floatformat_to_double (&floatformat_ieee_double_little, valbytes,
&fvalue);
- sprintf (buf, "%f", fvalue);
+ sprintf (buf, "%.7g", fvalue);
strcat (str, buf);
break;
}
@@ -673,7 +673,7 @@ csky_output_operand (char *str, struct operand const *oprnd,
float f = 0;
memcpy (&f, &value, sizeof (float));
- sprintf (buf, "%f\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
+ sprintf (buf, "%.7g\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
strcat (str, buf);
break;
@@ -702,7 +702,7 @@ csky_output_operand (char *str, struct operand const *oprnd,
}
double d = 0;
memcpy (&d, &dvalue, sizeof (double));
- sprintf (buf, "%lf\t// imm9:%4ld, imm4:%2ld", d, (long) imm8, (long) imm4);
+ sprintf (buf, "%.7g\t// imm9:%4ld, imm4:%2ld", d, (long) imm8, (long) imm4);
strcat (str, buf);
break;