Never mind, I discovered that I in order to access a TLS variable you need to call `seL4_TCB_SetTLSBase` on seL4_CapInitThreadTCB first in the root server, as I'm trying to work on a bare bone usage of seL4 to better understand it, this part was not obvious
from the existing more complex samples!
From: Devel <firstname.lastname@example.org> on behalf of Alexandre Mutel <email@example.com>
Sent: Friday, November 22, 2019 22:12
To: firstname.lastname@example.org <email@example.com>
Subject: [seL4] Understand how TLS is setup in the root server for x64
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)
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.
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?