From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id BEBCC3857B82; Mon, 4 Jul 2022 06:33:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BEBCC3857B82 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: restore masking of displacement kinds X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 9386188e95f4dee6319c51b30e2ea64b27ae0084 X-Git-Newrev: 02b83698ef04a33a8c606efeceb8fe7cd9a9b344 Message-Id: <20220704063305.BEBCC3857B82@sourceware.org> Date: Mon, 4 Jul 2022 06:33:05 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 06:33:05 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D02b83698ef04= a33a8c606efeceb8fe7cd9a9b344 commit 02b83698ef04a33a8c606efeceb8fe7cd9a9b344 Author: Jan Beulich Date: Mon Jul 4 08:32:20 2022 +0200 x86: restore masking of displacement kinds =20 Commit 7d5e4556a375 rendered the check near the end of what is now i386_finalize_displacement() entirely dead for AT&T mode, since for operands involving a displacement .unspecified will always be set. But the logic there is bogus anyway - Intel syntax operand size specifiers are of no interest there either. The only thing which matters in the "displacement only" determination is .baseindex. =20 Of course when masking displacement kinds we should not at the same time also mask off other attributes. =20 Furthermore the type mask returned by lex_got() also needs to be adjusted: The only case where we want Disp32 (rather than Disp32S) is when dealing with 32-bit addressing mode in 64-bit code. Diff: --- gas/config/tc-i386.c | 31 +++++++++++++++---------------- opcodes/i386-gen.c | 12 ++++++------ opcodes/i386-init.h | 12 ++++++------ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 8b245cc4d34..4cb7f179f4a 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -10380,7 +10380,7 @@ lex_got (enum bfd_reloc_code_real *rel, OPERAND_TYPE_IMM64, true }, { STRING_COMMA_LEN ("PLT"), { BFD_RELOC_386_PLT32, BFD_RELOC_X86_64_PLT32 }, - OPERAND_TYPE_IMM32_32S_DISP32, false }, + OPERAND_TYPE_IMM32_32S_DISP32S, false }, { STRING_COMMA_LEN ("GOTPLT"), { _dummy_first_bfd_reloc_code_real, BFD_RELOC_X86_64_GOTPLT64 }, OPERAND_TYPE_IMM64_DISP64, true }, @@ -10389,28 +10389,28 @@ lex_got (enum bfd_reloc_code_real *rel, OPERAND_TYPE_IMM64_DISP64, true }, { STRING_COMMA_LEN ("GOTPCREL"), { _dummy_first_bfd_reloc_code_real, BFD_RELOC_X86_64_GOTPCREL }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, { STRING_COMMA_LEN ("TLSGD"), { BFD_RELOC_386_TLS_GD, BFD_RELOC_X86_64_TLSGD }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, { STRING_COMMA_LEN ("TLSLDM"), { BFD_RELOC_386_TLS_LDM, _dummy_first_bfd_reloc_code_real }, OPERAND_TYPE_NONE, true }, { STRING_COMMA_LEN ("TLSLD"), { _dummy_first_bfd_reloc_code_real, BFD_RELOC_X86_64_TLSLD }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, { STRING_COMMA_LEN ("GOTTPOFF"), { BFD_RELOC_386_TLS_IE_32, BFD_RELOC_X86_64_GOTTPOFF }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, { STRING_COMMA_LEN ("TPOFF"), { BFD_RELOC_386_TLS_LE_32, BFD_RELOC_X86_64_TPOFF32 }, - OPERAND_TYPE_IMM32_32S_64_DISP32_64, true }, + OPERAND_TYPE_IMM32_32S_64_DISP32S_64, true }, { STRING_COMMA_LEN ("NTPOFF"), { BFD_RELOC_386_TLS_LE, _dummy_first_bfd_reloc_code_real }, OPERAND_TYPE_NONE, true }, { STRING_COMMA_LEN ("DTPOFF"), { BFD_RELOC_386_TLS_LDO_32, BFD_RELOC_X86_64_DTPOFF32 }, - OPERAND_TYPE_IMM32_32S_64_DISP32_64, true }, + OPERAND_TYPE_IMM32_32S_64_DISP32S_64, true }, { STRING_COMMA_LEN ("GOTNTPOFF"),{ BFD_RELOC_386_TLS_GOTIE, _dummy_first_bfd_reloc_code_real }, OPERAND_TYPE_NONE, true }, @@ -10419,17 +10419,17 @@ lex_got (enum bfd_reloc_code_real *rel, OPERAND_TYPE_NONE, true }, { STRING_COMMA_LEN ("GOT"), { BFD_RELOC_386_GOT32, BFD_RELOC_X86_64_GOT32 }, - OPERAND_TYPE_IMM32_32S_64_DISP32, true }, + OPERAND_TYPE_IMM32_32S_64_DISP32S, true }, { STRING_COMMA_LEN ("TLSDESC"), { BFD_RELOC_386_TLS_GOTDESC, BFD_RELOC_X86_64_GOTPC32_TLSDESC }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, { STRING_COMMA_LEN ("TLSCALL"), { BFD_RELOC_386_TLS_DESC_CALL, BFD_RELOC_X86_64_TLSDESC_CALL }, - OPERAND_TYPE_IMM32_32S_DISP32, true }, + OPERAND_TYPE_IMM32_32S_DISP32S, true }, #else /* TE_PE */ { STRING_COMMA_LEN ("SECREL32"), { BFD_RELOC_32_SECREL, BFD_RELOC_32_SECREL }, - OPERAND_TYPE_IMM32_32S_64_DISP32_64, false }, + OPERAND_TYPE_IMM32_32S_64_DISP32S_64, false }, #endif }; char *cp; @@ -11143,7 +11143,6 @@ static int i386_finalize_displacement (segT exp_seg ATTRIBUTE_UNUSED, expressionS *ex= p, i386_operand_type types, const char *disp_start) { - i386_operand_type bigdisp; int ret =3D 1; =20 /* We do this to make sure that the section symbol is in @@ -11208,10 +11207,10 @@ i386_finalize_displacement (segT exp_seg ATTRIBUT= E_UNUSED, expressionS *exp, i.types[this_operand].bitfield.disp8 =3D 1; =20 /* Check if this is a displacement only operand. */ - bigdisp =3D operand_type_and_not (i.types[this_operand], anydisp); - if (operand_type_all_zero (&bigdisp)) - i.types[this_operand] =3D operand_type_and (i.types[this_operand], - types); + if (!i.types[this_operand].bitfield.baseindex) + i.types[this_operand] =3D + operand_type_or (operand_type_and_not (i.types[this_operand], anydis= p), + operand_type_and (i.types[this_operand], types)); =20 return ret; } diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c index d18a7d27545..1fe59e6cc14 100644 --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -529,14 +529,14 @@ static initializer operand_type_init[] =3D "Imm16|Imm32|Imm32S" }, { "OPERAND_TYPE_IMM32_64", "Imm32|Imm64" }, - { "OPERAND_TYPE_IMM32_32S_DISP32", - "Imm32|Imm32S|Disp32" }, + { "OPERAND_TYPE_IMM32_32S_DISP32S", + "Imm32|Imm32S|Disp32S" }, { "OPERAND_TYPE_IMM64_DISP64", "Imm64|Disp64" }, - { "OPERAND_TYPE_IMM32_32S_64_DISP32", - "Imm32|Imm32S|Imm64|Disp32" }, - { "OPERAND_TYPE_IMM32_32S_64_DISP32_64", - "Imm32|Imm32S|Imm64|Disp32|Disp64" }, + { "OPERAND_TYPE_IMM32_32S_64_DISP32S", + "Imm32|Imm32S|Imm64|Disp32S" }, + { "OPERAND_TYPE_IMM32_32S_64_DISP32S_64", + "Imm32|Imm32S|Imm64|Disp32S|Disp64" }, { "OPERAND_TYPE_ANYIMM", "Imm1|Imm8|Imm8S|Imm16|Imm32|Imm32S|Imm64" }, }; diff --git a/opcodes/i386-init.h b/opcodes/i386-init.h index df2f7bcd498..84ed54e2d14 100644 --- a/opcodes/i386-init.h +++ b/opcodes/i386-init.h @@ -1964,20 +1964,20 @@ { { 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0 } } =20 -#define OPERAND_TYPE_IMM32_32S_DISP32 \ - { { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, \ +#define OPERAND_TYPE_IMM32_32S_DISP32S \ + { { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0 } } =20 #define OPERAND_TYPE_IMM64_DISP64 \ { { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0 } } =20 -#define OPERAND_TYPE_IMM32_32S_64_DISP32 \ - { { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, \ +#define OPERAND_TYPE_IMM32_32S_64_DISP32S \ + { { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0 } } =20 -#define OPERAND_TYPE_IMM32_32S_64_DISP32_64 \ - { { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, \ +#define OPERAND_TYPE_IMM32_32S_64_DISP32S_64 \ + { { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0 } } =20 #define OPERAND_TYPE_ANYIMM \