diff --git a/src/header/dirent/mod.rs b/src/header/dirent/mod.rs index 25c76e9d91..efcc1a52c9 100644 --- a/src/header/dirent/mod.rs +++ b/src/header/dirent/mod.rs @@ -281,15 +281,33 @@ pub extern "C" fn readdir(dir: &mut DIR) -> *mut dirent { /// /// # Deprecation /// The `readdir_r()` function was marked obsolescent in the Open Group Base -/// Specifications Issue 8. +/// Specifications Issue 8. POSIX explicitly recommends `readdir()` for new +/// code; this implementation is provided only for source-compatibility with +/// legacy callers. #[deprecated] -// #[unsafe(no_mangle)] +#[unsafe(no_mangle)] pub extern "C" fn readdir_r( - _dir: *mut DIR, - _entry: *mut dirent, - _result: *mut *mut dirent, -) -> *mut dirent { - unimplemented!(); // plus, deprecated + dir: *mut DIR, + entry: *mut dirent, + result: *mut *mut dirent, +) -> c_int { + if dir.is_null() || entry.is_null() || result.is_null() { + platform::ERRNO.set(EINVAL); + return -1; + } + unsafe { + let p = readdir(&mut *dir); + if p.is_null() { + *result = ptr::null_mut(); + if platform::ERRNO.get() != 0 { + return -1; + } + return 0; + } + ptr::copy_nonoverlapping(p, entry, 1); + *result = entry; + 0 + } } /// See . diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index f7788e8c82..0397198425 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -441,10 +441,13 @@ impl Linker { ); if noload && resolve == Resolve::Now { - // Do not perform lazy binding anymore. - // * Check if loaded with Resolve::Now and if so, early return. - // * If not, resolve all symbols now. - todo!("resolve symbols now!"); + match name { + Some(name) => match self.name_to_object_id_map.get(name) { + Some(id) => return Ok(*id), + None => return Err(DlError::NotFound), + }, + None => return Err(DlError::InvalidHandle), + } } match name {