From 112d5a7f51ea8f4d16b15032b2bdc5b9888d9372 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 3 Sep 2025 22:40:38 +0200 Subject: Apply asan:ignore also when bundling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- lib/xixanta/src/assembler.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/xixanta/src') 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> { 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(()); } -- cgit v1.2.3