Hello!

I'm trying to understand how the TLS is setup for the root server on x64 (to access for example the IPC buffer)
but I'm failing to connect the pieces and how the server is correctly setting the FS register.

For example the sel4_Send function is codegen like this (using -ftls-model=local-exec)

Function: seL4_Send
push      r15
mov       rdx,0FFFFFFFFFFFFFFFDh
push      rbx
mov       rax,[fs:0]
mov       r10,[rax+8]
mov       r8,[rax+10h]
mov       r9,[rax+18h]
mov       r15,[rax+20h]
mov       rbx,rsp
syscall
mov       rsp,rbx
pop       rbx
pop       r15
ret

The instruction `mov       rax,[fs:0]`  is accessing the seL4_IPCBuffer* and the the executable has a TLS segments of 8 bytes for the pointer. all good.
Now, I'm failing to find in the codebase where the ELF loader is actually detecting the TLS segment and the according setup with the TLS register.
And I'm wondering if the setup for the codegen is not wrong on my side (e.g the local-exec is not working), so that instead of having a FS register
it would be a direct memory access.

Does anyone have a clue about this?
Thank you!