From 5d4116881f2cc4d053fad66c1a6d00d2dcbead90 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sat, 25 Apr 2026 22:57:57 +0200 Subject: Add the context's name into memory ranges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is applied whenever a given memory range name is not under the global context. The end result is that scopes will be shown into the memory.txt file when using '--write-info'. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 10 +++++++--- lib/xixanta/src/object.rs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index a25ba41..7e5ff90 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -3,7 +3,7 @@ use crate::node::{ is_asan_friendly_name, CommentType, ControlType, EchoKind, NodeType, OperationType, PNode, PString, }; -use crate::object::{Bundle, Context, Object, ObjectType}; +use crate::object::{Bundle, Context, Object, ObjectType, GLOBAL_CONTEXT}; use crate::opcodes::{AddressingMode, INSTRUCTIONS}; use crate::parser::Parser; use crate::SourceInfo; @@ -1160,7 +1160,7 @@ impl<'a> Assembler<'a> { fn asan(&mut self, memory: &mut MemoryResult) -> Result<(), Vec> { let mut errors = vec![]; - for (_context, map) in self.context.map.iter() { + for (context_name, map) in self.context.map.iter() { for (name, bundle) in map { // Ignore this bundle if the user explicitely told us to do so. if bundle.asan_ignore { @@ -1177,7 +1177,11 @@ impl<'a> Assembler<'a> { let val = bundle.bundle.value() as usize; let range = MemoryRange { range: (val..val + bundle.asan_reserve), - name: name.clone(), + name: if context_name == GLOBAL_CONTEXT { + name.clone() + } else { + format!("{context_name}::{name}") + }, }; // Check if this variable was ever accessed and warn about diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index 5b4b235..cd1db1f 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -4,7 +4,7 @@ use crate::opcodes::CONTROL_FUNCTIONS; use std::collections::HashMap; /// The name of the global context as used internally. -const GLOBAL_CONTEXT: &str = "__internal_nasm_global_scope"; +pub const GLOBAL_CONTEXT: &str = "__internal_nasm_global_scope"; /// A Bundle represents a set of bytes that can be encoded as binary data. #[derive(Debug, Default, Clone, Eq, Ord, PartialEq, PartialOrd)] -- cgit v1.2.3