Skip to content
Snippets Groups Projects
Commit 3aacc160 authored by Ahmed Abd El Mawgood's avatar Ahmed Abd El Mawgood
Browse files

Remove dependency on errno in ld.so

During early parts of ld.so, errno and other thread local variables are
not yet initialized so we cannot use function (such as unistd::access)
that depends on such thread local variables (errno). For this reason
this patch creates small wrapper around the syscall that doesn't not
touch the errno
parent 1b10c3d2
No related branches found
No related tags found
1 merge request!275Ld library path
......@@ -29,6 +29,7 @@ use super::{
debug::{RTLDDebug, RTLDState, _dl_debug_state, _r_debug},
tcb::{Master, Tcb},
PAGE_SIZE,
access,
};
#[cfg(target_os = "redox")]
......@@ -169,7 +170,9 @@ impl Linker {
})?;
// TODO: Use R_OK | X_OK
unistd::access(path_c.as_ptr(), unistd::F_OK) == 0
// We cannot use unix stdlib because errno is thead local variable
// and fs:[0] is not set yet.
access(path_c.as_ptr(), unistd::F_OK) == 0
};
if access {
......
use goblin::elf::program_header::{self, program_header32, program_header64, ProgramHeader};
use self::tcb::{Master, Tcb};
use crate::start::Stack;
use crate::{
start::Stack,
c_str::CStr,
platform::types::*
};
pub const PAGE_SIZE: usize = 4096;
pub mod debug;
......@@ -80,6 +83,12 @@ pub fn static_init(sp: &'static Stack) {
}
}
// Wrapper over the systemcall, Do not use outside of ld_so
pub unsafe fn access(path: *const c_char, mode: c_int) -> c_int {
let path = CStr::from_ptr(path);
syscall!(ACCESS, (path).as_ptr(), mode) as c_int
  • Contributor

    The syscall! macro does not exist on the redox target, and this commit stops compilation of redox.

  • Please register or sign in to reply
}
#[cfg(target_os = "linux")]
pub unsafe fn init(sp: &'static Stack) {
let mut tp = 0usize;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment