mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-28 15:50:26 +08:00
5536baff13
Linux supports TLS on x86 by allocating slots in the GDT, accessible via the system calls get/set_thread_area. This allows segment registers (%gs on x86) to be used to quickly access the TLS. Previously, we used PTRACE_GETREGSET with the NT_386_TLS regset. This "register set" provides access to the subarray of the GDT used for TLS. However, there are multiple slots provided and we don't know which one is being used by the threading library for the current thread's TLS. Previously, we were just using the first one, which worked for x86 on 64-bit kernels, but not 32-bit kernels. On 32-bit kernels, the first slot ended up pointing to the TLS of the main thread. The authoritative index of the current thread's TLS in the GDT is given by bits 3-15 of %gs. However, this index cannot be used with PTRACE_GETREGSET+NT386_TLS because we don't know the location of the TLS slots in the GDT. PTRACE_GET_THREAD_AREA, however, accepts an index from the start of the GDT similarly to get/set_thread_area. Bug: crashpad:30 Change-Id: Ie6dfbdd088c6816fad409812a1a97037d4b38fd7 Reviewed-on: https://chromium-review.googlesource.com/575318 Reviewed-by: Mark Mentovai <mark@chromium.org>