fix(redox-rt/proc): min_mmap_addr being set too low
`cmp::min` -> `cmp::max` Want to make sure we set the `min_mmap_addr` to the top of the executable. `update_min_mmap_addr(STACK_TOP - STACK_SIZE, STACK_SIZE);` needs to be removed since we cannot allocate above that. Reverts to the old behaviour. In future may want to consider loading the executeable here instead of the dynamic linker (and before the dynamic linker) to avoid any further conflicts. Fixes `gcc` crashing at "failed to map /usr/libexec/gcc/x86_64-unknown-redox/13.2.0/cc1. errno: 17" (where 17 -> EEXIST). Co-authored-by: @bjorn3 Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
@@ -104,7 +104,7 @@ pub fn fexec_impl(
|
||||
// TODO: Remove clone, but this would require more as_refs and as_muts
|
||||
let mut min_mmap_addr = PAGE_SIZE;
|
||||
let mut update_min_mmap_addr = |addr: usize, size: usize| {
|
||||
min_mmap_addr = cmp::min(min_mmap_addr, (addr + size).next_multiple_of(PAGE_SIZE));
|
||||
min_mmap_addr = cmp::max(min_mmap_addr, (addr + size).next_multiple_of(PAGE_SIZE));
|
||||
};
|
||||
|
||||
pread_all(&image_file, u64::from(header.e_phoff), phs).map_err(|_| Error::new(EIO))?;
|
||||
@@ -195,7 +195,6 @@ pub fn fexec_impl(
|
||||
STACK_SIZE,
|
||||
MapFlags::PROT_READ | MapFlags::PROT_WRITE | MapFlags::MAP_FIXED_NOREPLACE,
|
||||
)?;
|
||||
update_min_mmap_addr(STACK_TOP - STACK_SIZE, STACK_SIZE);
|
||||
|
||||
let mut sp = STACK_TOP;
|
||||
let mut stack_page = Option::<MmapGuard>::None;
|
||||
|
||||
Reference in New Issue
Block a user