[PATCH v2] x86/Intel: avoid infinite recursion in i386_intel_simplify_symbol() (again)

Jan Beulich jbeulich@suse.com
Mon May 18 06:02:49 GMT 2026


On 16.05.2026 06:16, Alan Modra wrote:
> On Fri, May 15, 2026 at 03:03:32PM +0200, Jan Beulich wrote:
>> @@ -405,6 +409,11 @@ i386_intel_simplify_symbol (symbolS *sym
>>  	  if (e->X_op == O_symbol && !e->X_add_number)
>>  	    {
>>  	      sym = e->X_add_symbol;
>> +	      if (symbol_resolving_p (sym))
>> +		return sym;
>> +	      seg = S_GET_SEGMENT (sym);
>> +	      if (seg != expr_section && seg != reg_section)
>> +		return sym;
>>  	      continue;
>>  	    }
>>  	  sym = make_expr_symbol (e);
> 
> I suspect that trying to cut the loop like this is wrong.

I further suspect that looking for just O_symbol is insufficient here,
too. As mentioned in the bug, what I'm lacking is a good idea towards
making all of this more sane. (Quite likely expression walking like
what we do for Intel syntax parsing would better exist somewhere in
common code anyway.)

> I don't have a testcase specific to this change but in trying to
> create one I found the following:
> 
>  .intel_syntax noprefix
> a=b
> b=esi
> x=a
> a=1
> b=2
>  mov eax,[x]
> 
> Contrast with:
>  .intel_syntax noprefix
> x=esi
>  mov eax,[x]

I'll take a look at what you mean here.

Jan


More information about the Binutils mailing list