x86/gas: Fix APX TLS IE restrictions

Message ID DM4PR11MB54879122CB679EE660DDBB24ECDE2@DM4PR11MB5487.namprd11.prod.outlook.com
State New
Headers
Series x86/gas: Fix APX TLS IE restrictions |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Kong, Lingling July 4, 2024, 9:37 a.m. UTC
  Add the restriction in assemble for APX TLS IE that the destination can only be a register.

gas/

      * config/tc-i386.c (md_assemble): Added stricter restrictions
      for APX TLS IE.
---
 gas/config/tc-i386.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--
2.31.1
  

Comments

Kong, Lingling July 5, 2024, 3:11 a.m. UTC | #1
If there are no comments, I will check it by the end of today.

> -----Original Message-----
> From: Kong, Lingling
> Sent: Thursday, July 4, 2024 5:38 PM
> To: binutils@sourceware.org
> Cc: Beulich, Jan <JBeulich@suse.com>; H. J. Lu <hjl.tools@gmail.com>
> Subject: [PATCH] x86/gas: Fix APX TLS IE restrictions
> 
> Add the restriction in assemble for APX TLS IE that the destination can only be a
> register.
> 
> gas/
> 
>       * config/tc-i386.c (md_assemble): Added stricter restrictions
>       for APX TLS IE.
> ---
>  gas/config/tc-i386.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index
> 3b4d9cacc2e..2382db23e19 100644
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -7544,9 +7544,8 @@ md_assemble (char *line)
>  		&& i.mem_operands == 1
>  		&& 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.operands == 2))
> +		&& i.reg_operands == (i.operands - 1)
> +		&& i.types[i.operands - 1].bitfield.class == Reg)
>  	      /* Allow APX:
>  		 add %reg1, foo@gottpoff(%rip), %reg2
>  		 add foo@gottpoff(%rip), %reg, %reg2
> --
> 2.31.1
  

Patch

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 3b4d9cacc2e..2382db23e19 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -7544,9 +7544,8 @@  md_assemble (char *line)
 		&& i.mem_operands == 1
 		&& 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.operands == 2))
+		&& i.reg_operands == (i.operands - 1)
+		&& i.types[i.operands - 1].bitfield.class == Reg)
 	      /* Allow APX:
 		 add %reg1, foo@gottpoff(%rip), %reg2
 		 add foo@gottpoff(%rip), %reg, %reg2