[PATCH v3] CSKY: Fix sprintf argument overlaping destination error.

Cooper Qu cooper.qu@linux.alibaba.com
Thu Sep 10 12:09:04 GMT 2020


Hi Cheers,

Thanks for your patch to fix the build failure. The part of the code I 
wrote is indeed not suitable, I will improve it later.


Regards

Cooper


On 9/10/20 4:59 PM, Nick Clifton wrote:
> Hi Cooper,
>
>    One of your recent CSKY patches triggered a build failure for 32-bit
>    hosts, because the definition of the CSKY_ISA_FLOAT_7E60 constant does
>    not fit into a long int.  There was also a small issue with one of the
>    sprintf's trying to put long long values into a long format conversion
>    operator.  I have applied the patch below as an obvious fix.
>
> Cheers
>    Nick
>
> include/ChangeLog
> 2020-09-10  Nick Clifton  <nickc@redhat.com>
>
> 	* opcode/csky.h (CSKY_ISA_FLOAT_7E60): Use a long long type for
> 	this value.
>
> opcodes/ChangeLog
> 2020-09-10  Nick Clifton  <nickc@redhat.com>
>
> 	* csky-dis.c (csky_output_operand): Coerce the immediate values to
> 	long before printing.
>
>
> diff --git a/include/opcode/csky.h b/include/opcode/csky.h
> index 421454383e..717e8a949d 100644
> --- a/include/opcode/csky.h
> +++ b/include/opcode/csky.h
> @@ -58,7 +58,7 @@
>   /* 807 support (803f & 807f).  */
>   #define CSKY_ISA_FLOAT_3E4  (1L << 28)
>   /* 860 support.  */
> -#define CSKY_ISA_FLOAT_7E60 (1L << 36)
> +#define CSKY_ISA_FLOAT_7E60 (1LL << 36)
>   /* Vector DSP support.  */
>   #define CSKY_ISA_VDSP       (1L << 29)
>   #define CSKY_ISA_VDSP_2     (1L << 30)
> diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
> index 78ff055c3d..450a9bed0b 100644
> --- a/opcodes/csky-dis.c
> +++ b/opcodes/csky-dis.c
> @@ -675,7 +675,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, imm8, imm4);
> +	sprintf (buf, "%lf\t// imm9:%4ld, imm4:%2ld", d, (long) imm8, (long) imm4);
>   	strcat (str, buf);
>   	break;
>         }


More information about the Binutils mailing list