* [binutils-gdb] x86/gas: replace inappropriate assertion when parsing registers
@ 2023-02-16 8:40 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-02-16 8:40 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ccade1ae2c00337d2b0bba2a175a060b93728a8
commit 0ccade1ae2c00337d2b0bba2a175a060b93728a8
Author: Jan Beulich <jbeulich@suse.com>
Date: Thu Feb 16 09:40:08 2023 +0100
x86/gas: replace inappropriate assertion when parsing registers
PR gas/30117
Once a symbol had its expression evaluated, the "segment" of the symbol
may be reg_section if a register is merely involved in the expression,
not just when the expression references a "plain" register. Therefore
the first of the assertions put in place by 4d1bb7955a8b was too strict.
Convert it to an if() to deal with situations like this one found by
fuzzing:
x=s
s=%eax+0
y=s
or $6,x
In non-debug builds this also avoids potentially silently generating bad
code.
Diff:
---
gas/config/tc-i386.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index e421a1718db..7cd50f5e267 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -13057,17 +13057,19 @@ parse_register (char *reg_string, char **end_op)
{
const expressionS *e = symbol_get_value_expression (symbolP);
- know (e->X_op == O_register);
- know (e->X_add_number >= 0
- && (valueT) e->X_add_number < i386_regtab_size);
- r = i386_regtab + e->X_add_number;
- if (!check_register (r))
+ if (e->X_op == O_register)
+ {
+ know (e->X_add_number >= 0
+ && (valueT) e->X_add_number < i386_regtab_size);
+ r = i386_regtab + e->X_add_number;
+ *end_op = input_line_pointer;
+ }
+ if (r && !check_register (r))
{
as_bad (_("register '%s%s' cannot be used here"),
register_prefix, r->reg_name);
r = &bad_reg;
}
- *end_op = input_line_pointer;
}
*input_line_pointer = c;
input_line_pointer = save;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-16 8:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 8:40 [binutils-gdb] x86/gas: replace inappropriate assertion when parsing registers Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).