diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index ba052f641946244441efc549ece9d96bcdf0f66a..acf22736aef5b1fb1c97565d3fef63e67da9cee0 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -230,8 +230,10 @@ impl Linker { if self.next_tls_module_id == 0 { // Hack to allocate TCB on the first TLS module unsafe { - let tcb = Tcb::new(master.offset).expect_notls("failed to allocate TCB"); - tcb.activate(); + if Tcb::current().is_none() { + let tcb = Tcb::new(master.offset).expect_notls("failed to allocate TCB"); + tcb.activate(); + } } } self.next_tls_module_id += 1;