diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-11-16 07:21:11 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-11-16 07:34:46 -0800 |
commit | d7e3e627027fcf37d63e284144fe27ff4eba36b5 (patch) | |
tree | 2d179da6a560fbb1f9bfe14a2f493e4954e7e889 | |
parent | 3b2934856f1370b320d8be5e1d4d82ef0c628f01 (diff) | |
download | gdb-d7e3e627027fcf37d63e284144fe27ff4eba36b5.zip gdb-d7e3e627027fcf37d63e284144fe27ff4eba36b5.tar.gz gdb-d7e3e627027fcf37d63e284144fe27ff4eba36b5.tar.bz2 |
x86: Don't allow KMOV in TLS code sequences
Don't allow KMOV in TLS code sequences which require integer MOV
instructions.
PR target/28595
* config/tc-i386.c (match_template): Don't allow KMOV in TLS
code sequences.
* testsuite/gas/i386/i386.exp: Run inval-tls and x86-64-inval-tls
tests.
* testsuite/gas/i386/inval-tls.l: New file.
* testsuite/gas/i386/inval-tls.s: Likewise.
* testsuite/gas/i386/x86-64-inval-tls.l: Likewise.
* testsuite/gas/i386/x86-64-inval-tls.s: Likewise.
-rw-r--r-- | gas/config/tc-i386.c | 24 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/i386.exp | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-tls.l | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-tls.s | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-inval-tls.l | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-inval-tls.s | 4 |
6 files changed, 35 insertions, 5 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 320ea7e..9674ec4 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -6639,11 +6639,25 @@ match_template (char mnem_suffix) } } - /* Force 0x8b encoding for "mov foo@GOT, %eax". */ - if (i.reloc[0] == BFD_RELOC_386_GOT32 - && t->base_opcode == 0xa0 - && t->opcode_modifier.opcodespace == SPACE_BASE) - continue; + switch (i.reloc[0]) + { + case BFD_RELOC_386_GOT32: + /* Force 0x8b encoding for "mov foo@GOT, %eax". */ + if (t->base_opcode == 0xa0 + && t->opcode_modifier.opcodespace == SPACE_BASE) + continue; + break; + case BFD_RELOC_386_TLS_GOTIE: + case BFD_RELOC_386_TLS_LE_32: + case BFD_RELOC_X86_64_GOTTPOFF: + case BFD_RELOC_X86_64_TLSLD: + /* Don't allow KMOV in TLS code sequences. */ + if (t->opcode_modifier.vex) + continue; + break; + default: + break; + } /* We check register size if needed. */ if (t->opcode_modifier.checkregsize) diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 378e32b..864624b 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -616,6 +616,7 @@ if [gas_32_check] then { run_dump_test "tlsd" run_dump_test "tlspic" run_dump_test "tlsnopic" + run_list_test "inval-tls" run_dump_test "bss" run_dump_test "reloc32" run_list_test "reloc32" "--defsym _bad_=1" @@ -1276,6 +1277,7 @@ if [gas_64_check] then { run_dump_test "reloc64" run_list_test "reloc64" "--defsym _bad_=1" + run_list_test "x86-64-inval-tls" run_dump_test "mixed-mode-reloc64" run_dump_test "rela" run_dump_test "x86-64-ifunc" diff --git a/gas/testsuite/gas/i386/inval-tls.l b/gas/testsuite/gas/i386/inval-tls.l new file mode 100644 index 0000000..dc8a326 --- /dev/null +++ b/gas/testsuite/gas/i386/inval-tls.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:3: Error: operand size mismatch for `kmovd' +.*:4: Error: operand size mismatch for `kmovd' diff --git a/gas/testsuite/gas/i386/inval-tls.s b/gas/testsuite/gas/i386/inval-tls.s new file mode 100644 index 0000000..3fe85c3 --- /dev/null +++ b/gas/testsuite/gas/i386/inval-tls.s @@ -0,0 +1,4 @@ + .text +# All the following should be illegal + kmovd foo@gotntpoff(%eax), %k0 + kmovd foo@tpoff(%eax), %k0 diff --git a/gas/testsuite/gas/i386/x86-64-inval-tls.l b/gas/testsuite/gas/i386/x86-64-inval-tls.l new file mode 100644 index 0000000..11fa63e --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-inval-tls.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:3: Error: operand size mismatch for `kmovq' +.*:4: Error: operand size mismatch for `kmovq' diff --git a/gas/testsuite/gas/i386/x86-64-inval-tls.s b/gas/testsuite/gas/i386/x86-64-inval-tls.s new file mode 100644 index 0000000..71e1927 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-inval-tls.s @@ -0,0 +1,4 @@ + .text +# All the following should be illegal + kmovq foo@gottpoff(%rip), %k0 + kmovq foo@tlsld(%rip), %k0 |