diff --git a/src/header/dlfcn/mod.rs b/src/header/dlfcn/mod.rs index 33e33ab9c7..d1ca5c0470 100644 --- a/src/header/dlfcn/mod.rs +++ b/src/header/dlfcn/mod.rs @@ -123,10 +123,7 @@ pub unsafe extern "C" fn dlopen(cfilename: *const c_char, flags: c_int) -> *mut let mut linker = unsafe { (*tcb.linker_ptr).lock() }; - let cbs_c = linker.cbs.clone(); - let cbs = cbs_c.borrow(); - - match (cbs.load_library)(&mut linker, filename, resolve, scope, noload) { + match linker.load_library(filename, resolve, scope, noload) { Ok(handle) => handle.as_ptr().cast_mut(), Err(error) => { set_last_error(error); @@ -161,9 +158,8 @@ pub unsafe extern "C" fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *m } let linker = unsafe { (*tcb.linker_ptr).lock() }; - let cbs_c = linker.cbs.clone(); - let cbs = cbs_c.borrow(); - match (cbs.get_sym)(&linker, handle, symbol_str) { + + match linker.get_sym(handle, symbol_str) { Some(sym) => sym, _ => { ERROR.store(ERROR_NOT_SUPPORTED.as_ptr() as usize, Ordering::SeqCst); @@ -191,9 +187,7 @@ pub unsafe extern "C" fn dlclose(handle: *mut c_void) -> c_int { }; let mut linker = unsafe { (*tcb.linker_ptr).lock() }; - let cbs_c = linker.cbs.clone(); - let cbs = cbs_c.borrow(); - (cbs.unload)(&mut linker, handle); + linker.unload(handle); 0 } diff --git a/src/ld_so/callbacks.rs b/src/ld_so/callbacks.rs deleted file mode 100644 index 5b322ef440..0000000000 --- a/src/ld_so/callbacks.rs +++ /dev/null @@ -1,39 +0,0 @@ -use super::linker::{Linker, ObjectHandle, Resolve, Result, ScopeKind}; -use crate::platform::types::c_void; -use alloc::boxed::Box; - -pub struct LinkerCallbacks { - pub unload: Box, - pub load_library: - Box, Resolve, ScopeKind, bool) -> Result>, - pub get_sym: Box, &str) -> Option<*mut c_void>>, -} - -impl LinkerCallbacks { - #[allow(clippy::new_without_default)] - pub fn new() -> LinkerCallbacks { - LinkerCallbacks { - unload: Box::new(unload), - load_library: Box::new(load_library), - get_sym: Box::new(get_sym), - } - } -} - -fn unload(linker: &mut Linker, handle: ObjectHandle) { - linker.unload(handle) -} - -fn load_library( - linker: &mut Linker, - name: Option<&str>, - resolve: Resolve, - scope: ScopeKind, - noload: bool, -) -> Result { - linker.load_library(name, resolve, scope, noload) -} - -fn get_sym(linker: &Linker, handle: Option, name: &str) -> Option<*mut c_void> { - linker.get_sym(handle, name) -} diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index 05375e5132..fdd0b51123 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -1,6 +1,5 @@ use alloc::{ collections::BTreeMap, - rc::Rc, string::{String, ToString}, sync::{Arc, Weak}, vec::Vec, @@ -12,10 +11,7 @@ use object::{ read::elf::{Rela as _, Sym}, }; -use core::{ - cell::RefCell, - ptr::{self, NonNull}, -}; +use core::ptr::{self, NonNull}; use crate::{ ALLOCATOR, @@ -43,7 +39,6 @@ use super::dso::Rela; use super::{ PATH_SEP, access::accessible, - callbacks::LinkerCallbacks, debug::{_dl_debug_state, _r_debug, RTLDState}, dso::{DSO, ProgramHeader}, tcb::{Master, Tcb}, @@ -433,7 +428,6 @@ pub struct Linker { tls_size: usize, objects: BTreeMap>, name_to_object_id_map: BTreeMap, - pub cbs: Rc>, } const ROOT_ID: usize = 1; @@ -448,7 +442,6 @@ impl Linker { tls_size: 0, objects: BTreeMap::new(), name_to_object_id_map: BTreeMap::new(), - cbs: Rc::new(RefCell::new(LinkerCallbacks::new())), } } diff --git a/src/ld_so/mod.rs b/src/ld_so/mod.rs index f8b90af0f6..43d6b96787 100644 --- a/src/ld_so/mod.rs +++ b/src/ld_so/mod.rs @@ -21,7 +21,6 @@ use crate::{ pub const PATH_SEP: char = ':'; mod access; -pub mod callbacks; pub mod debug; mod dso; pub mod linker;