https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96955
Bug ID: 96955 Summary: Implement __builtin_thread_pointer Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: crazylht at gmail dot com, wwwhhhyyy333 at gmail dot com Blocks: 96200 Target Milestone: --- Target: i386,x86-64 On Linux/x86-64, The %fs segment register is used to implement the thread pointer. The linear address of the thread pointer is stored at offset 0 relative to the %fs segment register. The following code loads the thread pointer in the %rax register: movq %fs:0, %rax On Linux/i386, the %gs segment register is used: movl %gs:0, %eax We need to 1. Implement __builtin_thread_pointer for Linux/x86. 2. Document its behavior. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96200 [Bug 96200] Implement __builtin_thread_pointer() and __builtin_set_thread_pointer() if TLS is supported