aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-09-03 23:16:54 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-09-03 23:16:54 +0200
commit90fecaa84ff317e30c3339d3edb17b13211e3e64 (patch)
treed49d799f5f6b750d68f3b574d4b453289192aaf7
parent112d5a7f51ea8f4d16b15032b2bdc5b9888d9372 (diff)
downloadtools.nes-90fecaa84ff317e30c3339d3edb17b13211e3e64.tar.gz
tools.nes-90fecaa84ff317e30c3339d3edb17b13211e3e64.zip
asan: Add fixes on absolute/indirect addressing
The check was not being applied on certain conditions. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rw-r--r--lib/xixanta/src/assembler.rs7
-rw-r--r--tests/bare_accesses.s4
-rw-r--r--tests/expected/bare_accesses.txt1
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index 28a2313..89ad3ac 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -2398,7 +2398,9 @@ impl<'a> Assembler<'a> {
global: false,
});
}
- self.asan_check_arm(evaluated_node, &val)?;
+ if !matches!(node.value.value.as_str(), "jmp" | "jsr") {
+ self.asan_check_arm(evaluated_node, &val)?;
+ }
Ok((AddressingMode::Indirect, val))
}
},
@@ -2514,6 +2516,9 @@ impl<'a> Assembler<'a> {
val.size = 1;
Ok((AddressingMode::RelativeOrZeropage, val))
} else {
+ if !matches!(base.value.value.as_str(), "jmp" | "jsr") {
+ self.asan_check_arm(left_arm, &val)?;
+ }
Ok((AddressingMode::Absolute, val))
}
}
diff --git a/tests/bare_accesses.s b/tests/bare_accesses.s
index 49628b4..61ae7c6 100644
--- a/tests/bare_accesses.s
+++ b/tests/bare_accesses.s
@@ -37,3 +37,7 @@ palettes:
.byte $0F
lda $200 ; asan:ignore
+lda $200
+
+jmp $8000
+jmp ($8000)
diff --git a/tests/expected/bare_accesses.txt b/tests/expected/bare_accesses.txt
index 4c14629..0eab60f 100644
--- a/tests/expected/bare_accesses.txt
+++ b/tests/expected/bare_accesses.txt
@@ -1,4 +1,5 @@
warning: accessing a memory region without using a variable (bare_accesses.s: line 22)
warning: accessing a memory region without a proper name ('whatever') (bare_accesses.s: line 23)
+warning: accessing a memory region without using a variable (bare_accesses.s: line 40)
error: out of bounds memory access for 'zp_used' ($00-$01) (bare_accesses.s: line 27)
error: out of bounds memory access for 'zp_used' ($00-$01) (bare_accesses.s: line 28)