`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>
Init no longer changes the default scheme to initfs at any point in
time. And for sandboxing you would be switching scheme namespace, not
default scheme.
It should be possible to mix and match relibc version from before and
after this change without breaking exec, though I haven't tested it.
Calculating it earlier is a micro-optimization that doesn't seem like it
matters at all compared to all other costs of spawning a process. But at
the same time it makes things more fragile. And in fact bootstrap
actually passed the wrong value. It passed the
total_args_envs_auxvpointee_size that it computed rather than the
total_args_envs_size. While over-approximation doesn't cause UB, it
unnecessarily increases the amount of memory used after exec.
In addition pass &[&[u8]] rather than iterators for args and envs to
enable precomputing the total arg and env size. This also prevents you
from forgetting to pass a reversed iterator.
There are a few functions where I allowed the lint. The lower level and
FFI nature of relibc means that there are areas with a lot of unsafe.
Some functions are basically long blocks of unsafe or contain lots of
small blocks of unsafe. unsafe_op_in_unsafe_fn doesn't add clarity to
these functions. Instead, it reduces readability by adding an indent or
small "unsafe { .. }" clutter.