Set linker_ptr when using static TLS
This commit is contained in:
+3
-1
@@ -83,7 +83,9 @@ impl Linker {
|
||||
obj.use_count += 1;
|
||||
return Ok(*id);
|
||||
} else {
|
||||
let parent_runpath = &self.objects.get(&root_id).unwrap().runpath.clone();
|
||||
let parent_runpath = &self.objects.get(&root_id).and_then(|parent| {
|
||||
parent.runpath.clone()
|
||||
});
|
||||
let lib_id = self.next_object_id;
|
||||
self.load_object(name, parent_runpath, None, true)?;
|
||||
|
||||
|
||||
+16
-2
@@ -1,10 +1,11 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{boxed::Box, vec::Vec};
|
||||
use core::{intrinsics, ptr};
|
||||
|
||||
use crate::{
|
||||
header::{libgen, stdio, stdlib},
|
||||
ld_so,
|
||||
ld_so::{self, linker::Linker},
|
||||
platform::{self, get_auxvs, new_mspace, types::*, Pal, Sys},
|
||||
sync::mutex::Mutex,
|
||||
ALLOCATOR,
|
||||
};
|
||||
|
||||
@@ -162,6 +163,19 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
|
||||
// if any memory rust based memory allocation happen before this step .. we are doomed.
|
||||
alloc_init();
|
||||
|
||||
if let Some(tcb) = ld_so::tcb::Tcb::current() {
|
||||
// Update TCB mspace
|
||||
tcb.mspace = ALLOCATOR.get_book_keeper();
|
||||
|
||||
// Set linker pointer if necessary
|
||||
if tcb.linker_ptr.is_null() {
|
||||
//TODO: get ld path
|
||||
let linker = Linker::new(None);
|
||||
//TODO: load root object
|
||||
tcb.linker_ptr = Box::into_raw(Box::new(Mutex::new(linker)));
|
||||
}
|
||||
}
|
||||
|
||||
// Set up argc and argv
|
||||
let argc = sp.argc;
|
||||
let argv = sp.argv();
|
||||
|
||||
Reference in New Issue
Block a user