[PATCH] x86-64: Relax BFD_RELOC_X86_64_GOTTPOFF check

Jan Beulich jbeulich@suse.com
Thu Jun 27 09:24:54 GMT 2024


On 27.06.2024 08:06, Kong, Lingling wrote:
>> --- a/gas/config/tc-i386.c
>> +++ b/gas/config/tc-i386.c
>> @@ -7137,7 +7137,8 @@ md_assemble (char *line)
>>  		&& i.base_reg
>>  		&& i.base_reg->reg_num == RegIP
>>  		&& i.tm.operand_types[0].bitfield.class == Reg
>> -		&& i.tm.operand_types[2].bitfield.class == Reg)
>> +		&& (i.tm.operand_types[2].bitfield.class == Reg
>> +		    || (i.tm.operands == 2 && i.tm.opcode_modifier.nf)))
>>  	      /* Allow APX: add %reg1, foo@gottpoff(%rip), %reg2.  */
>>  	      break;

What does the i.tm.opcode_modifier.nf check achieve here? All EVexMap4
ADD forms permit {nf}. The comment also needs updating, to avoid it
going further stale (it already hasn't been quite accurate). With the
comment properly updated to list all permissible forms, I think you'll
also note that what you add to the condition is too lax: Aiui

	add %rax, foo@GOTTPOFF(%rip)

is not supposed to be permitted (according to the testsuite additions
you make).

Finally a question perhaps more for H.J. than for you: Why is it that
ADD is special-cased here for the APX EVEX-encoded case, when there's
no similar special casing for legacy encodings?

>> --- a/gas/testsuite/gas/i386/x86-64-gottpoff.s
>> +++ b/gas/testsuite/gas/i386/x86-64-gottpoff.s
>> @@ -18,8 +18,22 @@ _start:
>>
>>  	addq	%r8, foo@GOTTPOFF(%rip), %r16
>>  	addq	foo@GOTTPOFF(%rip), %rax, %r12
>> +	{nf} addq	%r8, foo@GOTTPOFF(%rip), %r16
>> +	{nf} addq	foo@GOTTPOFF(%rip), %rax, %r12
>>
>>  	.intel_syntax noprefix
>>
>>  	add	r16, QWORD PTR [rip + foo@GOTTPOFF], r8
>>  	add	r12, rax, QWORD PTR [rip + foo@GOTTPOFF]
>> +	{nf} addq	r16, QWORD PTR [rip + foo@GOTTPOFF], r8
>> +	{nf} addq	r12, rax, QWORD PTR [rip + foo@GOTTPOFF]
> 
>  +	{nf} add		r16, QWORD PTR [rip + foo@GOTTPOFF], r8
>  +	{nf} add 	r12, rax, QWORD PTR [rip + foo@GOTTPOFF]
> 
>> +
>> +	.att_syntax prefix
>> +
>> +	{nf} addq	foo@GOTTPOFF(%rip), %rax
>> +	{nf} addq	foo@GOTTPOFF(%rip), %r16

Isn't the {evex} form similarly permitted by the change you make to tc-i386.c?

Jan


More information about the Binutils mailing list