mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
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.
This commit is contained in:
@ -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)
|
||||
|
@ -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"
|
||||
|
3
gas/testsuite/gas/i386/inval-tls.l
Normal file
3
gas/testsuite/gas/i386/inval-tls.l
Normal file
@ -0,0 +1,3 @@
|
||||
.*: Assembler messages:
|
||||
.*:3: Error: operand size mismatch for `kmovd'
|
||||
.*:4: Error: operand size mismatch for `kmovd'
|
4
gas/testsuite/gas/i386/inval-tls.s
Normal file
4
gas/testsuite/gas/i386/inval-tls.s
Normal file
@ -0,0 +1,4 @@
|
||||
.text
|
||||
# All the following should be illegal
|
||||
kmovd foo@gotntpoff(%eax), %k0
|
||||
kmovd foo@tpoff(%eax), %k0
|
3
gas/testsuite/gas/i386/x86-64-inval-tls.l
Normal file
3
gas/testsuite/gas/i386/x86-64-inval-tls.l
Normal file
@ -0,0 +1,3 @@
|
||||
.*: Assembler messages:
|
||||
.*:3: Error: operand size mismatch for `kmovq'
|
||||
.*:4: Error: operand size mismatch for `kmovq'
|
4
gas/testsuite/gas/i386/x86-64-inval-tls.s
Normal file
4
gas/testsuite/gas/i386/x86-64-inval-tls.s
Normal file
@ -0,0 +1,4 @@
|
||||
.text
|
||||
# All the following should be illegal
|
||||
kmovq foo@gottpoff(%rip), %k0
|
||||
kmovq foo@tlsld(%rip), %k0
|
Reference in New Issue
Block a user