ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.89k stars 286 forks source link

for help! : two question about tls #351

Closed ifquant closed 2 years ago

ifquant commented 2 years ago

i was puzzle by code in x64tls.c i have three question. first, tls data access problem. if a native lib has some tls data, and a emulated lib access the tls data use fs register, while native lib use arm style access the tls data, how this worked?

second: in setupTlsdata , i saw index will be set throgh below code: (uint64_t)((uintptr_t)ptr + context->tlssize + POS_TLS+i*16)) = i; i have saw the tcbeader_t in gliibc/sysdeps/x86_64/nptl/tls.h, but i can find the data format behind the tcbheader_t . can you give some url link about the data format about this?

third: vsyscall will be copy to tcbheader in function setupTLSData, i want know when it will be used by who?

ptitSeb commented 2 years ago

i was puzzle by code in x64tls.c i have three question. first, tls data access problem. if a native lib has some tls data, and a emulated lib access the tls data use fs register, while native lib use arm style access the tls data, how this worked?

It doesn't work. For now, there is not support for this kind of heterogenous call. If this happens, elfloader will probably show a warning, as the relocation for this will reference a native elf...

second: in setupTlsdata , i saw index will be set throgh below code: _(uint64t)((uintptr_t)ptr + context->tlssize + POS_TLS+i*16)) = i; i have saw the tcbeader_t in gliibc/sysdeps/x86_64/nptl/tls.h, but i can find the data format behind the tcbheader_t . can you give some url link about the data format about this?

I don't have links: I just deduced by debugging programs that I need to populate address & index here, so I just do it.

third: vsyscall will be copy to tcbheader in function setupTLSData, i want know when it will be used by who?

Not sure, I don't remember what needed it.

ifquant commented 2 years ago

@ptitSeb thanks for replay., how could i have so strong debug ablity....