MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / load

Method load

core/src/mm.rs:152–173  ·  view source on GitHub ↗
(loc: Location)

Source from the content-addressed store, hash-verified

150
151impl ElfCacheEntry {
152 fn load(loc: Location) -> AxResult<Result<Self, Vec<u8>>> {
153 let cache = CachedFile::get_or_create(loc);
154
155 let mut data = vec![0; 4096];
156 let read = cache.read_at(&mut data[..], 0)?;
157 data.truncate(read);
158 match ElfCacheEntry::try_new_or_recover::<AxError>(cache.clone(), data, |data| {
159 let builder = ELFHeadersBuilder::new(data).map_err(map_elf_error)?;
160 let range = builder.ph_range();
161 if range.end as usize <= data.len() {
162 builder.build(&data[range.start as usize..range.end as usize])
163 } else {
164 let mut buf = vec![0; (range.end - range.start) as usize];
165 cache.read_at(&mut buf[..], range.start)?;
166 builder.build(&buf)
167 }
168 .map_err(map_elf_error)
169 }) {
170 Ok(e) => Ok(Ok(e)),
171 Err((_, heads)) => Ok(Err(heads.data)),
172 }
173 }
174}
175
176struct ElfLoader(LRUCache<ElfCacheEntry, 32>);

Callers 15

clear_child_tidMethod · 0.80
robust_list_headMethod · 0.80
oom_score_adjMethod · 0.80
pending_exitMethod · 0.80
get_heap_topMethod · 0.80
umaskMethod · 0.80
load_user_appFunction · 0.80
irq_cntFunction · 0.80
write_atMethod · 0.80
ioctlMethod · 0.80
pty_numberMethod · 0.80

Calls 5

map_trampolineFunction · 0.85
map_elfFunction · 0.85
insertMethod · 0.80
read_atMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected