From a25cf92162fc943207ff7d912c83bacf339e519c Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 29 Nov 2025 15:22:39 +0000 Subject: [PATCH 1/2] update header reference and add references to functions --- src/header/dlfcn/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/header/dlfcn/mod.rs b/src/header/dlfcn/mod.rs index 8e3d7903c3..630dbeaa03 100644 --- a/src/header/dlfcn/mod.rs +++ b/src/header/dlfcn/mod.rs @@ -1,4 +1,6 @@ -//! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html +//! `dlfcn.h` implementation. +//! +//! See . #![deny(unsafe_op_in_unsafe_fn)] // FIXME(andypython): remove this when #![allow(warnings, unused_variables)] is @@ -36,6 +38,7 @@ fn set_last_error(error: DlError) { ERROR.store(error.repr().as_ptr() as usize, Ordering::SeqCst); } +/// See . #[repr(C)] #[allow(non_camel_case_types)] pub struct Dl_info { @@ -45,6 +48,7 @@ pub struct Dl_info { dli_saddr: *mut c_void, } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn dladdr(_addr: *mut c_void, info: *mut Dl_info) -> c_int { //TODO @@ -57,6 +61,7 @@ pub unsafe extern "C" fn dladdr(_addr: *mut c_void, info: *mut Dl_info) -> c_int 0 } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn dlopen(cfilename: *const c_char, flags: c_int) -> *mut c_void { //TODO support all sort of flags @@ -111,6 +116,7 @@ pub unsafe extern "C" fn dlopen(cfilename: *const c_char, flags: c_int) -> *mut } } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void { let handle = ObjectHandle::from_ptr(handle); @@ -150,6 +156,7 @@ pub unsafe extern "C" fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *m } } +/// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn dlclose(handle: *mut c_void) -> c_int { let tcb = match unsafe { Tcb::current() } { @@ -177,6 +184,7 @@ pub unsafe extern "C" fn dlclose(handle: *mut c_void) -> c_int { 0 } +/// See . #[unsafe(no_mangle)] pub extern "C" fn dlerror() -> *mut c_char { ERROR.swap(0, Ordering::SeqCst) as *mut c_char From 329db0dd9c91849d6f5de536b6c07e4c6d39797e Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 29 Nov 2025 15:33:31 +0000 Subject: [PATCH 2/2] add Dl_info_t alias for Dl_info --- src/header/dlfcn/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/header/dlfcn/mod.rs b/src/header/dlfcn/mod.rs index 630dbeaa03..a22d88f0b2 100644 --- a/src/header/dlfcn/mod.rs +++ b/src/header/dlfcn/mod.rs @@ -48,9 +48,12 @@ pub struct Dl_info { dli_saddr: *mut c_void, } +/// alias as per spec update: https://www.austingroupbugs.net/view.php?id=1847 +pub type Dl_info_t = Dl_info; + /// See . #[unsafe(no_mangle)] -pub unsafe extern "C" fn dladdr(_addr: *mut c_void, info: *mut Dl_info) -> c_int { +pub unsafe extern "C" fn dladdr(_addr: *mut c_void, info: *mut Dl_info_t) -> c_int { //TODO unsafe { (*info).dli_fname = ptr::null();