PR 32721, internal error in tc-i386.c:parse_register

Jan Beulich jbeulich@suse.com
Thu Feb 20 07:58:22 GMT 2025


On 20.02.2025 02:33, Alan Modra wrote:
> pr30117 showed one of the assertions added by 4d1bb7955a8b was too
> strict.  oss-fuzz also found the second assertion to be too strict,
> with this testcase distilled from 7k of garbage source:
> 
>  A=%eax%%!
>  Y=A
>  Z=A
>  or $6,Z
> 
> 	PR 32721
> 	* config/tc-i386.c (parse_register): Move "know" into
> 	condition.  Simplify.

Hmm, I will want to look into this in more detail. We better wouldn't ...

> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -16838,10 +16838,9 @@ parse_register (const char *reg_string, char **end_op)
>  	{
>  	  const expressionS *e = symbol_get_value_expression (symbolP);
>  
> -	  if (e->X_op == O_register)
> +	  if (e->X_op == O_register
> +	      && (valueT) e->X_add_number < i386_regtab_size)
>  	    {
> -	      know (e->X_add_number >= 0
> -		    && (valueT) e->X_add_number < i386_regtab_size);

... manufacture O_register expressions not representing any valid register.
IOW I think the assertion is legitimate and a fix is going to be needed
elsewhere.

Jan


More information about the Binutils mailing list