From 6894b01b22e848b5fdbb2fafae88e9459232ced2 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 5 Feb 2026 18:53:20 +0100 Subject: asan: don't complain on arithmetic with addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was already the case for plain addresses, but it was not being considered in the case of an arithmetic operation. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 96fdd01..507f5e1 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -2948,13 +2948,26 @@ impl<'a> Assembler<'a> { } NodeType::Operation(OperationType::Add) | NodeType::Operation(OperationType::Sub) => { // Get the name of the variable involved. - let left_name = &node.left.as_ref().unwrap().value.value; - let right_name = &node.left.as_ref().unwrap().value.value; - let name = if is_asan_friendly_name(left_name) { + let left_name = &node.left.as_ref().unwrap().value; + let right_name = &node.left.as_ref().unwrap().value; + let name = if is_asan_friendly_name(&left_name.value) { node.left.as_ref().unwrap() - } else if is_asan_friendly_name(right_name) { + } else if is_asan_friendly_name(&right_name.value) { node.right.as_ref().unwrap() } else { + // If everything failed but because it was an address + // (e.g. 'lda palettes + 1, x'), then return early. + if let Ok(var) = self.context.get_variable(left_name, &self.mappings) { + if matches!(var.object_type, ObjectType::Address) { + return Ok(()); + } + } + if let Ok(var) = self.context.get_variable(right_name, &self.mappings) { + if matches!(var.object_type, ObjectType::Address) { + return Ok(()); + } + } + self.warnings.push(Error { line: node.value.line, message: "accessing a memory region without a proper name".to_string(), -- cgit v1.2.3