Skip to content

Commit caad5c4

Browse files
committed
tool: add support for split program image
Signed-off-by: Nick Spinale <nick@nickspinale.com>
1 parent 9d2ec50 commit caad5c4

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

tool/microkit/src/elf.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
use crate::util::bytes_to_struct;
8+
use std::borrow::Cow;
89
use std::collections::HashMap;
910
use std::fs;
1011
use std::path::Path;
@@ -144,9 +145,21 @@ pub struct ElfFile {
144145

145146
impl ElfFile {
146147
pub fn from_path(path: &Path) -> Result<ElfFile, String> {
148+
Self::from_split_paths(path, None)
149+
}
150+
151+
pub fn from_split_paths(path: &Path, path_for_symbols: Option<&Path>) -> Result<ElfFile, String> {
147152
let reader = ElfFileReader::from_path(path)?;
153+
let reader_for_symbols = match path_for_symbols {
154+
Some(path_for_symbols) => {
155+
Cow::Owned(ElfFileReader::from_path(path_for_symbols)?)
156+
}
157+
None => {
158+
Cow::Borrowed(&reader)
159+
}
160+
};
148161
let segments = reader.segments();
149-
let symbols = reader.symbols()?;
162+
let symbols = reader_for_symbols.symbols()?;
150163
Ok(ElfFile {
151164
word_size: reader.word_size,
152165
entry: reader.hdr.entry,

tool/microkit/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3315,7 +3315,12 @@ fn main() -> Result<(), String> {
33153315
for pd in &system.protection_domains {
33163316
match get_full_path(&pd.program_image, &search_paths) {
33173317
Some(path) => {
3318-
let elf = ElfFile::from_path(&path).unwrap();
3318+
let path_for_symbols = pd.program_image_for_symbols.as_ref().map(|path_suffix| {
3319+
get_full_path(path_suffix, &search_paths).ok_or_else(|| {
3320+
format!("unable to find program image for symbols: '{}'", path_suffix.display())
3321+
})
3322+
}).transpose()?;
3323+
let elf = ElfFile::from_split_paths(&path, path_for_symbols.as_deref()).unwrap();
33193324
pd_elf_files.push(elf);
33203325
}
33213326
None => {

tool/microkit/src/sdf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub struct ProtectionDomain {
162162
pub passive: bool,
163163
pub stack_size: u64,
164164
pub program_image: PathBuf,
165+
pub program_image_for_symbols: Option<PathBuf>,
165166
pub maps: Vec<SysMap>,
166167
pub irqs: Vec<SysIrq>,
167168
pub setvars: Vec<SysSetVar>,
@@ -397,6 +398,7 @@ impl ProtectionDomain {
397398
let mut child_pds = Vec::new();
398399

399400
let mut program_image = None;
401+
let mut program_image_for_symbols = None;
400402
let mut virtual_machine = None;
401403

402404
// Default to minimum priority
@@ -421,7 +423,7 @@ impl ProtectionDomain {
421423

422424
match child.tag_name().name() {
423425
"program_image" => {
424-
check_attributes(xml_sdf, &child, &["path"])?;
426+
check_attributes(xml_sdf, &child, &["path", "path_for_symbols"])?;
425427
if program_image.is_some() {
426428
return Err(value_error(
427429
xml_sdf,
@@ -432,6 +434,8 @@ impl ProtectionDomain {
432434

433435
let program_image_path = checked_lookup(xml_sdf, &child, "path")?;
434436
program_image = Some(Path::new(program_image_path).to_path_buf());
437+
438+
program_image_for_symbols = child.attribute("path_for_symbols").map(PathBuf::from);
435439
}
436440
"map" => {
437441
let map = SysMap::from_xml(xml_sdf, &child, true)?;
@@ -567,6 +571,7 @@ impl ProtectionDomain {
567571
passive,
568572
stack_size,
569573
program_image: program_image.unwrap(),
574+
program_image_for_symbols,
570575
maps,
571576
irqs,
572577
setvars,

0 commit comments

Comments
 (0)