diff --git a/tool/microkit/src/elf.rs b/tool/microkit/src/elf.rs index 6c19eb18..aa1af3cf 100644 --- a/tool/microkit/src/elf.rs +++ b/tool/microkit/src/elf.rs @@ -5,6 +5,7 @@ // use crate::util::bytes_to_struct; +use std::borrow::Cow; use std::collections::HashMap; use std::fs; use std::path::Path; @@ -144,9 +145,21 @@ pub struct ElfFile { impl ElfFile { pub fn from_path(path: &Path) -> Result { + Self::from_split_paths(path, None) + } + + pub fn from_split_paths(path: &Path, path_for_symbols: Option<&Path>) -> Result { let reader = ElfFileReader::from_path(path)?; + let reader_for_symbols = match path_for_symbols { + Some(path_for_symbols) => { + Cow::Owned(ElfFileReader::from_path(path_for_symbols)?) + } + None => { + Cow::Borrowed(&reader) + } + }; let segments = reader.segments(); - let symbols = reader.symbols()?; + let symbols = reader_for_symbols.symbols()?; Ok(ElfFile { word_size: reader.word_size, entry: reader.hdr.entry, diff --git a/tool/microkit/src/main.rs b/tool/microkit/src/main.rs index fc02bebe..e6816ccf 100644 --- a/tool/microkit/src/main.rs +++ b/tool/microkit/src/main.rs @@ -3315,7 +3315,12 @@ fn main() -> Result<(), String> { for pd in &system.protection_domains { match get_full_path(&pd.program_image, &search_paths) { Some(path) => { - let elf = ElfFile::from_path(&path).unwrap(); + let path_for_symbols = pd.program_image_for_symbols.as_ref().map(|path_suffix| { + get_full_path(path_suffix, &search_paths).ok_or_else(|| { + format!("unable to find program image for symbols: '{}'", path_suffix.display()) + }) + }).transpose()?; + let elf = ElfFile::from_split_paths(&path, path_for_symbols.as_deref()).unwrap(); pd_elf_files.push(elf); } None => { diff --git a/tool/microkit/src/sdf.rs b/tool/microkit/src/sdf.rs index e6540b35..2d465096 100644 --- a/tool/microkit/src/sdf.rs +++ b/tool/microkit/src/sdf.rs @@ -162,6 +162,7 @@ pub struct ProtectionDomain { pub passive: bool, pub stack_size: u64, pub program_image: PathBuf, + pub program_image_for_symbols: Option, pub maps: Vec, pub irqs: Vec, pub setvars: Vec, @@ -397,6 +398,7 @@ impl ProtectionDomain { let mut child_pds = Vec::new(); let mut program_image = None; + let mut program_image_for_symbols = None; let mut virtual_machine = None; // Default to minimum priority @@ -421,7 +423,7 @@ impl ProtectionDomain { match child.tag_name().name() { "program_image" => { - check_attributes(xml_sdf, &child, &["path"])?; + check_attributes(xml_sdf, &child, &["path", "path_for_symbols"])?; if program_image.is_some() { return Err(value_error( xml_sdf, @@ -432,6 +434,8 @@ impl ProtectionDomain { let program_image_path = checked_lookup(xml_sdf, &child, "path")?; program_image = Some(Path::new(program_image_path).to_path_buf()); + + program_image_for_symbols = child.attribute("path_for_symbols").map(PathBuf::from); } "map" => { let map = SysMap::from_xml(xml_sdf, &child, true)?; @@ -567,6 +571,7 @@ impl ProtectionDomain { passive, stack_size, program_image: program_image.unwrap(), + program_image_for_symbols, maps, irqs, setvars,