The error handling was already in place. The reason it was page faulting
is that, on failure, the function exits as soon as it encounters an
`Err` variant. When that happens, the DSO object for which the
dependency was being loaded is dropped. Dropping it calls `munmap` to
unload the executable and also runs the functions in `.fini`. However,
`run_fini` should only be called if the `DSO` is being unloaded after it
has been successfully loaded (i.e. all dependencies were satisfied and
all init functions had run).
Closes#1599
Signed-off-by: Anhad Singh <andypython@protonmail.com>
The dynamic linker now works on aarch64. You can also try it on Linux by
setting `TEST_RUNNER` to `qemu-aarch64` when running `make test
TARGET=aarch64-unknown-linux-gnu`
Co-authored-by: @willnode
Signed-off-by: Anhad Singh <andypython@protonmail.com>
Workaround for a bug inside `cbindgen`. For some reason it does not like
us exporting constants that depend on other constants that are *not*
defined as a part of the same module.
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.
`timespec_get` and `timespec_getres` are both C23 functions. They're
similar to the POSIX functions `clock_gettime` and `clock_getres`, but
both sets of functions define extra, exclusive features. I didn't
implement the extra features yet, partially because Redox doesn't seem
to support them yet either.
This commit fixes multiple issues with `fstatat` implementation for
Redox.
1. `flags` are now properly handled. The `flags` argument specifies AT_* flags
not O_* flags.
2. Open with O_PATH to avoid actually *opening* the file which may block
or cause permission issues.
3. Close the temporary file descriptor regardless of success of failure.
Signed-off-by: Anhad Singh <andypython@protonmail.com>