Notes on ELF Thread Local Storage (TLS)
There are three "dialects" of how TLS variables are accessed:
sun: The original scheme implemented by Sun.
gnu: Similar to the Sun scheme, but more concise instruction sequences on i386. This is the default in gcc.
gnu2: New scheme, supported by gcc/binutils/glibc, but not yet the default. Can be switched on by passing -mtls-dialect=gnu2 to gcc.
TLS access models
The sun and gnu dialects have four types of TLS access:
- General Dynamic (GD)
- Local Dynamic (LD)
- Initial Exec (IE)
- Local Exec (LE)
The gnu2 dialect introduces another type which replaces General Dynamic:
- GDesc
TLS model transitions
References
ELF Handling For Thread-Local Storage, Ulrich Drepper, 2005
Ian Lance Taylor's blog post on TLS and linker rewriting; part 7 in his series of posts on linkers.
gnu2 TLS scheme: various docs by Alexandre Oliva
Original 2005 post, "Thread Local Storage Descriptors for IA32 and AMD64/EM64T"

