This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix Score gas bugs, please review it.
- From: ligang at sunnorth dot com dot cn
- To: binutils at sourceware dot org
- Cc: bjgnu at sunnorth dot com dot cn
- Date: Fri, 20 Oct 2006 16:44:18 +0800
- Subject: [PATCH] Fix Score gas bugs, please review it.
Hello,
I have fixed 2 gas bugs. Could it be applied?
1. Emit error message if const operand is invalid.
gas/config/
* tc-score.c (data_op2): See whether const operand is invalid except
for
internal instructions.
2. Fix error message of simm15 outof range.
gas/config/
* tc-score.c (data_op2): The immediate value in lw is 15 bit signed.
Index: tc-score.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-score.c,v
retrieving revision 1.3
diff -p -u -r1.3 tc-score.c
--- tc-score.c 19 Oct 2006 15:47:33 -0000 1.3
+++ tc-score.c 20 Oct 2006 08:33:47 -0000
@@ -1105,6 +1105,22 @@ data_op2 (char **str, int shift, enum sc
{
data_type += 24;
}
+
+ /* If const is invalid then emit error message. */
+ if ((inst.reloc.exp.X_add_number == 0)
+ && ((inst.instruction & 0x3e0e0000) != 0x020c0000) /* li/la */
+ && ((inst.instruction & 0x3e0e0000) != 0x0a0c0000) /*
ld_i32hi/ldis_pic */
+ && ((inst.instruction & 0x3e0e0001) != 0x020a0000) /* ld_i32lo
*/
+ && ((inst.instruction & 0x3e0e0001) != 0x02000000) /*
addi_s_pic/addi_u_pic */
+ && (data_type != _GP_IMM15)
+ && (((*dataptr >= 'a') && (*dataptr <= 'z'))
+ || ((*dataptr == '0') && (*(dataptr + 1) == 'x') &&
(*(dataptr + 2) != '0'))
+ || ((*dataptr == '+') && (*(dataptr + 1) != '0'))
+ || ((*dataptr == '-') && (*(dataptr + 1) != '0'))))
+ {
+ inst.error = BAD_ARGS;
+ return FAIL;
+ }
}
if ((inst.reloc.exp.X_add_symbol)
@@ -2860,7 +2876,7 @@ do_ldst_insn (char *str)
{
char err_msg[255];
- if (data_type < 27)
+ if (data_type < 30)
sprintf (err_msg,
"invalid constant: %d bit expression not in
range %d..%d",
score_df_range[data_type].bits,
@@ -2868,9 +2884,9 @@ do_ldst_insn (char *str)
else
sprintf (err_msg,
"invalid constant: %d bit expression not in
range %d..%d",
- score_df_range[data_type - 21].bits,
- score_df_range[data_type - 21].range[0],
- score_df_range[data_type - 21].range[1]);
+ score_df_range[data_type - 24].bits,
+ score_df_range[data_type - 24].range[0],
+ score_df_range[data_type - 24].range[1]);
inst.error = _(err_msg);
return;
}
Best regards
Ligang