x86: restrict use of register aliases
authorJan Beulich <jbeulich@suse.com>
Mon, 8 Jun 2020 06:37:47 +0000 (08:37 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 Jun 2020 06:37:47 +0000 (08:37 +0200)
commit8a6fb3f9bb5105e58f6800de9089a4bdb0cc0cd6
treeb4be5b526c1cb1048b525fa880b8315b643f34a1
parent334a017304f03fdc77a2d8893396ed9bfa40382f
x86: restrict use of register aliases

Register aliases (created e.g. via .set) check their target register at
the time of creation of the alias. While this makes sense, it's not
enough: The underlying register must also be "visible" at the time of
use. Wrong use of such aliases would lead to internal errors in e.g.
add_prefix() or build_modrm_byte().

Split the checking part of parse_real_register() into a new helper
function and use it also from the latter part of parse_register() (at
the same time replacing a minor open coded part of it).

Since parse_register() returning NULL already has a meaning, a fake new
"bad register" indicator gets added, which all callers need to check
for.
gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/equ-bad.l [new file with mode: 0644]
gas/testsuite/gas/i386/equ-bad.s [new file with mode: 0644]
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/x86-64-equ-bad.l [new file with mode: 0644]
gas/testsuite/gas/i386/x86-64-equ-bad.s [new file with mode: 0644]
opcodes/ChangeLog
opcodes/i386-opc.h