mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-20 03:44:19 +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('[');
|
||||
reg = arm64_parse_regvar(tok);
|
||||
if (reg >= 0 && reg < 32) {
|
||||
op->reg = reg;
|
||||
op->reg_tok = tok;
|
||||
if (reg < 0 || reg >= 32) {
|
||||
tcc_error("invalid register in address operand");
|
||||
return;
|
||||
}
|
||||
op->reg = reg;
|
||||
op->reg_tok = tok;
|
||||
next();
|
||||
/* Check for offset */
|
||||
if (tok == ',') {
|
||||
next();
|
||||
/* Check for offset */
|
||||
if (tok == ',') {
|
||||
if (tok == '#' || tok == '@' || tok == '$')
|
||||
next();
|
||||
if (tok == '#' || tok == '@' || tok == '$')
|
||||
next();
|
||||
asm_expr(s1, &op->e);
|
||||
}
|
||||
asm_expr(s1, &op->e);
|
||||
}
|
||||
skip(']');
|
||||
if (tok == '!') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user