Skip to content

Commit c1e2793

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

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
@@ -539,7 +539,22 @@ fn main() -> Result<(), String> {
539539
for pd in &system.protection_domains {
540540
match get_full_path(&pd.program_image, &search_paths) {
541541
Some(path) => {
542-
system_elfs.push(ElfFile::from_path(&path)?);
542+
let path_for_symbols = pd
543+
.program_image_for_symbols
544+
.as_ref()
545+
.map(|path_suffix| {
546+
get_full_path(path_suffix, &search_paths).ok_or_else(|| {
547+
format!(
548+
"unable to find program image for symbols: '{}'",
549+
path_suffix.display()
550+
)
551+
})
552+
})
553+
.transpose()?;
554+
system_elfs.push(ElfFile::from_split_paths(
555+
&path,
556+
path_for_symbols.as_deref(),
557+
)?);
543558
}
544559
None => {
545560
return Err(format!(

tool/microkit/src/sdf.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ pub struct ProtectionDomain {
246246
pub stack_size: u64,
247247
pub smc: bool,
248248
pub program_image: PathBuf,
249+
pub program_image_for_symbols: Option<PathBuf>,
249250
pub maps: Vec<SysMap>,
250251
pub irqs: Vec<SysIrq>,
251252
pub ioports: Vec<IOPort>,
@@ -560,6 +561,7 @@ impl ProtectionDomain {
560561
let mut child_pds = Vec::new();
561562

562563
let mut program_image = None;
564+
let mut program_image_for_symbols = None;
563565
let mut virtual_machine = None;
564566

565567
// Default to minimum priority
@@ -584,7 +586,7 @@ impl ProtectionDomain {
584586

585587
match child.tag_name().name() {
586588
"program_image" => {
587-
check_attributes(xml_sdf, &child, &["path"])?;
589+
check_attributes(xml_sdf, &child, &["path", "path_for_symbols"])?;
588590
if program_image.is_some() {
589591
return Err(value_error(
590592
xml_sdf,
@@ -595,6 +597,9 @@ impl ProtectionDomain {
595597

596598
let program_image_path = checked_lookup(xml_sdf, &child, "path")?;
597599
program_image = Some(Path::new(program_image_path).to_path_buf());
600+
601+
program_image_for_symbols =
602+
child.attribute("path_for_symbols").map(PathBuf::from);
598603
}
599604
"map" => {
600605
let map_max_vaddr = config.pd_map_max_vaddr(stack_size);
@@ -1043,6 +1048,7 @@ impl ProtectionDomain {
10431048
stack_size,
10441049
smc,
10451050
program_image: program_image.unwrap(),
1051+
program_image_for_symbols,
10461052
maps,
10471053
irqs,
10481054
ioports,

0 commit comments

Comments
 (0)