Boost logo

Boost :

Subject: Re: [boost] [thread] Any way to avoid creating the .tls section on Windows
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-08-31 04:03:45

Rush Manbert <rush_at_[hidden]> writes:

> 1) Why does the code force a .tls section to be created, even when
> static tls is not being used?

The static TLS section is used to register the on-thread-exit
callbacks. These are used to ensure cleanup of thread-local data
belonging to boost.thread on threads not wrapped in a boost::thread
object (such as the main thread, or any threads launched with
CreateThread or _beginthread)

> 2) If we know that static tls is not used in any of the code, is it
> safe to remove the .tls section from the PE file? (We know a lot about
> manipulating PE files, so definitely know how to do this.)

Only if you don't use thread_specific_ptr or this_thread::get_id() or
at_thread_exit (and possibly something else, I can't remember if that's
the full list) from a thread not started with boost::thread (such as the
main thread).


Author of C++ Concurrency in Action
just::thread C++0x thread library   
Just Software Solutions Ltd
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at, gregod at, cpdaniel at, john at