mirror of
git://repo.or.cz/tinycc.git
synced 2026-07-08 04:18:40 +08:00
arm64-asm.c: reject invalid registers in address operands
parse_addr_operand() silently accepted invalid register names like [xyz] without error. Now explicitly validates the register and calls tcc_error() if arm64_parse_regvar() returns -1 or >= 32. Before: invalid registers caused silent wrong code or confusing errors After: clear error message 'invalid register in address operand'
This commit is contained in:
parent
a702dcce9e
commit
7fe9c22cf2
20
arm64-asm.c
20
arm64-asm.c
@ -293,17 +293,19 @@ static void parse_addr_operand(TCCState *s1, Operand *op)
|
|||||||
|
|
||||||
skip('[');
|
skip('[');
|
||||||
reg = arm64_parse_regvar(tok);
|
reg = arm64_parse_regvar(tok);
|
||||||
if (reg >= 0 && reg < 32) {
|
if (reg < 0 || reg >= 32) {
|
||||||
op->reg = reg;
|
tcc_error("invalid register in address operand");
|
||||||
op->reg_tok = tok;
|
return;
|
||||||
|
}
|
||||||
|
op->reg = reg;
|
||||||
|
op->reg_tok = tok;
|
||||||
|
next();
|
||||||
|
/* Check for offset */
|
||||||
|
if (tok == ',') {
|
||||||
next();
|
next();
|
||||||
/* Check for offset */
|
if (tok == '#' || tok == '@' || tok == '$')
|
||||||
if (tok == ',') {
|
|
||||||
next();
|
next();
|
||||||
if (tok == '#' || tok == '@' || tok == '$')
|
asm_expr(s1, &op->e);
|
||||||
next();
|
|
||||||
asm_expr(s1, &op->e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
skip(']');
|
skip(']');
|
||||||
if (tok == '!') {
|
if (tok == '!') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user