Skip to content
Snippets Groups Projects
Verified Commit b9e03cba authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Implement __tls_get_addr

parent 30aef27c
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,18 @@ pub struct dl_tls_index { ...@@ -10,7 +10,18 @@ pub struct dl_tls_index {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn __tls_get_addr(ti: *mut dl_tls_index) -> *mut c_void { pub unsafe extern "C" fn __tls_get_addr(ti: *mut dl_tls_index) -> *mut c_void {
//TODO: Figure out how to implement this trace!("__tls_get_addr({:p}: {:#x}, {:#x})", ti, (*ti).ti_module, (*ti).ti_offset);
unimplemented!(); if let Some(tcb) = Tcb::current() {
if let Some(tls) = tcb.tls() {
if let Some(masters) = tcb.masters() {
if let Some(master) = masters.get((*ti).ti_module as usize) {
let addr = tls.as_mut_ptr().add(master.offset + (*ti).ti_offset as usize);
trace!("__tls_get_addr({:p}: {:#x}, {:#x}) = {:p}", ti, (*ti).ti_module, (*ti).ti_offset, addr);
return addr as *mut c_void;
}
}
}
}
panic!("__tls_get_addr({:p}: {:#x}, {:#x}) failed", ti, (*ti).ti_module, (*ti).ti_offset);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment