From f5651b22eaaff5030e23dfccbdc6c641c5f5cb4e Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Mon, 13 Feb 2023 08:31:59 -0700 Subject: [PATCH] Do not overwrite static TCB --- src/ld_so/linker.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index ba052f64..acf22736 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; -- GitLab