aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/assembler.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-09-03 22:40:38 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-09-03 22:40:38 +0200
commit112d5a7f51ea8f4d16b15032b2bdc5b9888d9372 (patch)
tree8234be3061263466677c0c7b3fa7d8ad1ff42c1e /lib/xixanta/src/assembler.rs
parente0b1faf993bab97288540769f6f5f7955b3e0996 (diff)
downloadtools.nes-112d5a7f51ea8f4d16b15032b2bdc5b9888d9372.tar.gz
tools.nes-112d5a7f51ea8f4d16b15032b2bdc5b9888d9372.zip
Apply asan:ignore also when bundling
This way instructions which might make use of bare memory numbers can freely ignore the address sanitizer when it actually makes sense. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/assembler.rs')
-rw-r--r--lib/xixanta/src/assembler.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs
index 01a1982..28a2313 100644
--- a/lib/xixanta/src/assembler.rs
+++ b/lib/xixanta/src/assembler.rs
@@ -706,6 +706,7 @@ impl<'a> Assembler<'a> {
fn bundle(&mut self, nodes: &'a [PNode]) -> Result<(), Vec<Error>> {
let mut errors = Vec::new();
+ let mut next_ignore = false;
self.stage = Stage::Bundling;
@@ -753,6 +754,10 @@ impl<'a> Assembler<'a> {
self.bundle(args)?;
}
}
+ NodeType::Comment(CommentType::AsanIgnore) => {
+ next_ignore = true;
+ self.asan_next_ignore = true;
+ }
NodeType::Instruction => {
self.literal_mode = None;
match self.evaluate_node(node) {
@@ -810,6 +815,13 @@ impl<'a> Assembler<'a> {
_ => {}
}
+
+ // Keep `self.asan_next_ignore` to false if possible.
+ if next_ignore {
+ next_ignore = false;
+ } else {
+ self.asan_next_ignore = false;
+ }
}
if errors.is_empty() {
@@ -2543,7 +2555,7 @@ impl<'a> Assembler<'a> {
// called by `jmp` or `jsr` kind of instructions on the absolute addressing
// mode, as they operate on another level.
fn asan_check_arm(&mut self, node: &PNode, value: &Bundle) -> Result<(), Error> {
- if !self.asan_enabled {
+ if !self.asan_enabled || self.asan_next_ignore {
return Ok(());
}