// Bionic TCB / TLS slots: // // - TLS_SLOT_SELF: On x86-{32,64}, the kernel makes TLS memory available via // the gs/fs segments. To get the address of a TLS variable, the first slot // of TLS memory (accessed using %gs:0 / %fs:0) holds the address of the // gs/fs segment. This slot is used by: // - OpenGL and compiler-rt // - Accesses of x86 ELF TLS variables // // - TLS_SLOT_OPENGL and TLS_SLOT_OPENGL_API: These two aren't used by bionic // itself, but allow the graphics code to access TLS directly rather than // using the pthread API. // // - TLS_SLOT_STACK_GUARD: Used for -fstack-protector by: // - Clang targeting Android/arm64 // - gcc targeting Linux/x86-{32,64} // // - TLS_SLOT_SANITIZER: Lets sanitizers avoid using pthread_getspecific for // finding the current thread state. // // - TLS_SLOT_DTV: Pointer to ELF TLS dynamic thread vector. // // - TLS_SLOT_ART_THREAD_SELF: Fast storage for Thread::Current() in ART. // // - TLS_SLOT_BIONIC_TLS: Optimizes accesses to bionic_tls by one load versus // finding it using __get_thread(). // // - TLS_SLOT_APP: Available for use by apps in API level 29 and later. // (This slot was used for errno in API level 28 and earlier.) // // - TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE: Pointer to the guest state for native // bridge implementations. It is (to be) used by debuggerd to access this // state for guest aware crash reporting of the binary translated code. // (Introduced in V)
#ifdefined(__arm__) || defined(__aarch64__)
// The ARM ELF TLS ABI specifies[1] that the thread pointer points at a 2-word // TCB followed by the executable's TLS segment. Both the TCB and the // executable's segment are aligned according to the segment, so Bionic requires // a minimum segment alignment, which effectively reserves an 8-word TCB. The // ARM spec allocates the first TCB word to the DTV. // // [1] "Addenda to, and Errata in, the ABI for the ARM Architecture". Section 3. // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0045e/IHI0045E_ABI_addenda.pdf
#define MIN_TLS_SLOT (-3) // update this value when reserving a slot #define TLS_SLOT_STACK_MTE (-3) #define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE (-2) #define TLS_SLOT_BIONIC_TLS (-1) #define TLS_SLOT_DTV 0 #define TLS_SLOT_THREAD_ID 1 #define TLS_SLOT_APP 2// was historically used for errno #define TLS_SLOT_OPENGL 3 #define TLS_SLOT_OPENGL_API 4 #define TLS_SLOT_STACK_GUARD 5 #define TLS_SLOT_SANITIZER 6// was historically used for dlerror #define TLS_SLOT_ART_THREAD_SELF 7
// The maximum slot is fixed by the minimum TLS alignment in Bionic executables. #define MAX_TLS_SLOT 7
#elifdefined(__i386__) || defined(__x86_64__)
// x86 uses variant 2 ELF TLS layout, which places the executable's TLS segment // immediately before the thread pointer. New slots are allocated at positive // offsets from the thread pointer.
#define MIN_TLS_SLOT 0
#define TLS_SLOT_SELF 0 #define TLS_SLOT_THREAD_ID 1 #define TLS_SLOT_APP 2// was historically used for errno #define TLS_SLOT_OPENGL 3 #define TLS_SLOT_OPENGL_API 4 #define TLS_SLOT_STACK_GUARD 5 #define TLS_SLOT_SANITIZER 6// was historically used for dlerror #define TLS_SLOT_ART_THREAD_SELF 7 #define TLS_SLOT_DTV 8 #define TLS_SLOT_BIONIC_TLS 9 #define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE 10 #define MAX_TLS_SLOT 10// update this value when reserving a slot
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.