|
Message-ID: <Z2GmAZyr3-bOw74z@voyager> Date: Tue, 17 Dec 2024 17:25:37 +0100 From: Markus Wichmann <nullplan@....net> To: musl@...ts.openwall.com Cc: " ." <yedexi1996@...com> Subject: Re: Question about the TLS Am Tue, Dec 17, 2024 at 03:11:06PM +0800 schrieb .: > Hi > I have one question in TLS. > I intend to incorporate a Thread-Local Storage (TLS) variable into the musl library. However, the musl library does not currently support the > handling of TLS variables within the ldso library. Could you please advise if there are any potential risks or issues associated with adding TLS > variables and the corresponding processing logic? > Best > ye > > Main problem that I see is the bootstrapping of TLS relocations inside of LDSO at this time. LDSO bootstrapping at this point works like this: - Stage 1 (dlstart.c): Process relative ldso relocations. - Stage 2: - Initialize dynamic linking structures - Temporarily process symbolic ldso relocations - Stage 2b: Set thread pointer to builtin TLS initially. - Stage 3: - Load LD_PRELOAD + possibly app + dependencies - Process all relocations (including symbolic ldso relocs again) - Properly initialize TLS and thread pointer. The initialization of TLS requires that the allocator (malloc et al.) work already. This requires that all dependencies be loaded and symbolic relocations be done. At this point, the only way I can think of to do this would be to create a stage 4 for all the TLS stuff. You'd have to shuffle some code around, and ensure that stage 3 never calls any stuff that depends on TLS until it is set up in stage 4. What do you want TLS in libc for, anyway? Mayhaps a simpler thing would be to add a field to struct __pthread? Ciao, Markus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.