Skip to content

Commit 4ef80cb

Browse files
committed
tool: add support for split program image
Signed-off-by: Nick Spinale <nick@nickspinale.com>
1 parent 61e5a86 commit 4ef80cb

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

tool/microkit/src/elf.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use crate::sel4::PageSize;
88
use crate::util::{bytes_to_struct, round_down, struct_to_bytes};
9+
use std::borrow::Cow;
910
use std::collections::HashMap;
1011
use std::fs::{self, metadata, File};
1112
use std::io::Write;
@@ -190,9 +191,20 @@ pub struct ElfFile {
190191

191192
impl ElfFile {
192193
pub fn from_path(path: &Path) -> Result<ElfFile, String> {
194+
Self::from_split_paths(path, None)
195+
}
196+
197+
pub fn from_split_paths(
198+
path: &Path,
199+
path_for_symbols: Option<&Path>,
200+
) -> Result<ElfFile, String> {
193201
let reader = ElfFileReader::from_path(path)?;
202+
let reader_for_symbols = match path_for_symbols {
203+
Some(path_for_symbols) => Cow::Owned(ElfFileReader::from_path(path_for_symbols)?),
204+
None => Cow::Borrowed(&reader),
205+
};
194206
let segments = reader.segments()?;
195-
let symbols = reader.symbols()?;
207+
let symbols = reader_for_symbols.symbols()?;
196208
Ok(ElfFile {
197209
path: path.to_owned(),
198210
word_size: reader.word_size,

tool/microkit/src/main.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,22 @@ fn main() -> Result<(), String> {
518518
for pd in &system.protection_domains {
519519
match get_full_path(&pd.program_image, &search_paths) {
520520
Some(path) => {
521-
system_elfs.push(ElfFile::from_path(&path)?);
521+
let path_for_symbols = pd
522+
.program_image_for_symbols
523+
.as_ref()
524+
.map(|path_suffix| {
525+
get_full_path(path_suffix, &search_paths).ok_or_else(|| {
526+
format!(
527+
"unable to find program image for symbols: '{}'",
528+
path_suffix.display()
529+
)
530+
})
531+
})
532+
.transpose()?;
533+
system_elfs.push(ElfFile::from_split_paths(
534+
&path,
535+
path_for_symbols.as_deref(),
536+
)?);
522537
}
523538
None => {
524539
return Err(format!(

tool/microkit/src/sdf.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ pub struct ProtectionDomain {
225225
pub stack_size: u64,
226226
pub smc: bool,
227227
pub program_image: PathBuf,
228+
pub program_image_for_symbols: Option<PathBuf>,
228229
pub maps: Vec<SysMap>,
229230
pub irqs: Vec<SysIrq>,
230231
pub ioports: Vec<IOPort>,
@@ -536,6 +537,7 @@ impl ProtectionDomain {
536537
let mut child_pds = Vec::new();
537538

538539
let mut program_image = None;
540+
let mut program_image_for_symbols = None;
539541
let mut virtual_machine = None;
540542

541543
// Default to minimum priority
@@ -560,7 +562,7 @@ impl ProtectionDomain {
560562

561563
match child.tag_name().name() {
562564
"program_image" => {
563-
check_attributes(xml_sdf, &child, &["path"])?;
565+
check_attributes(xml_sdf, &child, &["path", "path_for_symbols"])?;
564566
if program_image.is_some() {
565567
return Err(value_error(
566568
xml_sdf,
@@ -571,6 +573,9 @@ impl ProtectionDomain {
571573

572574
let program_image_path = checked_lookup(xml_sdf, &child, "path")?;
573575
program_image = Some(Path::new(program_image_path).to_path_buf());
576+
577+
program_image_for_symbols =
578+
child.attribute("path_for_symbols").map(PathBuf::from);
574579
}
575580
"map" => {
576581
let map_max_vaddr = config.pd_map_max_vaddr(stack_size);
@@ -973,6 +978,7 @@ impl ProtectionDomain {
973978
stack_size,
974979
smc,
975980
program_image: program_image.unwrap(),
981+
program_image_for_symbols,
976982
maps,
977983
irqs,
978984
ioports,

0 commit comments

Comments
 (0)