SPRAB89A September 2011 – March 2014
Each thread has its own instance of all the thread-local variables (even the ones it doesn't declare or use). An access to a thread-local variable should access the current thread’s instance of that thread-local variable. This means the thread-local access needs to find the current thread’s TLS and access the variable using an offset into the TLS block where the variable is defined.
There are six models for accessing TLS data, depending on factors such as whether DLLs/DSOs are supported (separate linking), whether dlopen() is supported, and whether the access is to own or imported data. Table 7-1 summarizes various characteristics of the TLS access models.
Model | General Dynamic | Local Dynamic | Initial Exec | Local Exec | Static Exec | Bare Metal Dynamic |
---|---|---|---|---|---|---|
System has DLLs or DSOs | yes | yes | yes | yes | no | yes |
Can access another module's TLS data | yes | no | yes | no | no | yes |
TLS access from DLLs or DSOs | yes | yes | yes | no | no | yes |
TLS access from dlopened modules | yes | yes | no | no | no | no |
TLS initialization performed by | loader | loader | loader | loader | linker | loader |
Supports weak references | yes | yes | no | no | no | no |
Use case | Access another module's TLS data | Access own TLS data from DLL or DSO | Access TLS data of module loaded at load-time | Access own TLS data from executable | No DLLs or DSOs | Access TLS data of module loaded at load-time |
Section | Section 7.6.1.1 | Section 7.6.1.2 | Section 7.6.1.3 | Section 7.6.1.4 | Section 7.6.2 | Section 7.6.3 |
The C6x Linux TLS access model needs to satisfy more constraints and can be complex. It needs to conform to already-established conventions. The static executable access model, on the other hand, is simple—there is only one TLS block, and any thread-local variable can be accessed using Thread Pointer Relative (TPR) addressing. It is useful to first describe the more complex C6x Linux TLS model (Section 7.6.1) and then describe the static executable TLS model as a simpler case (Section 7.6.2). Finally, the bare-metal dynamic linking case is described (Section 7.6.3).
There are four widely-used TLS access models discussed in the literature. (3)(4)These are:
The full list of relocations used for TLS are listed in Table 13-5 and Table 13-6. The sections that follow show the use of these relocations.