feat(ld.so): remove LinkerCallbacks
Not necessary as ld.so has been merged with libc.so. Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
+4
-10
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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<dyn Fn(&mut Linker, ObjectHandle)>,
|
||||
pub load_library:
|
||||
Box<dyn Fn(&mut Linker, Option<&str>, Resolve, ScopeKind, bool) -> Result<ObjectHandle>>,
|
||||
pub get_sym: Box<dyn Fn(&Linker, Option<ObjectHandle>, &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<ObjectHandle> {
|
||||
linker.load_library(name, resolve, scope, noload)
|
||||
}
|
||||
|
||||
fn get_sym(linker: &Linker, handle: Option<ObjectHandle>, name: &str) -> Option<*mut c_void> {
|
||||
linker.get_sym(handle, name)
|
||||
}
|
||||
+1
-8
@@ -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<usize, Arc<DSO>>,
|
||||
name_to_object_id_map: BTreeMap<String, usize>,
|
||||
pub cbs: Rc<RefCell<LinkerCallbacks>>,
|
||||
}
|
||||
|
||||
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())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ use crate::{
|
||||
pub const PATH_SEP: char = ':';
|
||||
|
||||
mod access;
|
||||
pub mod callbacks;
|
||||
pub mod debug;
|
||||
mod dso;
|
||||
pub mod linker;
|
||||
|
||||
Reference in New Issue
Block a user