Fix an error when calculating elf memory usage
VMLayout was mistakenly used to calculate the memory usage. This commit is to fix this and seperate VMLayout "add" and "extend" methods.
This commit is contained in:
parent
f9bafa23a4
commit
3612442adc
@ -101,7 +101,7 @@ impl<'a, 'b> ProcessVMBuilder<'a, 'b> {
|
||||
let process_layout = elf_layouts.iter().chain(other_layouts.iter()).fold(
|
||||
VMLayout::new_empty(),
|
||||
|mut process_layout, sub_layout| {
|
||||
process_layout.extend(&sub_layout);
|
||||
process_layout.add(&sub_layout);
|
||||
process_layout
|
||||
},
|
||||
);
|
||||
|
@ -21,7 +21,8 @@ impl VMLayout {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extend(&mut self, more_space: &VMLayout) -> &mut Self {
|
||||
// This is used to add "more_space" to VM layout
|
||||
pub fn add(&mut self, more_space: &VMLayout) -> &mut Self {
|
||||
if more_space.size == 0 {
|
||||
return self;
|
||||
}
|
||||
@ -31,6 +32,20 @@ impl VMLayout {
|
||||
self
|
||||
}
|
||||
|
||||
// This is used to get the bigger and aligned VM layout
|
||||
pub fn extend(&mut self, new_space: &VMLayout) -> &mut Self {
|
||||
if new_space.size == 0 {
|
||||
return self;
|
||||
}
|
||||
|
||||
self.align = max(self.align, new_space.align);
|
||||
self.size = {
|
||||
let size = max(self.size, new_space.size);
|
||||
align_up(size, self.align)
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn size(&self) -> usize {
|
||||
self.size
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user