DynamoRIO / DynamoRIO/dynamorio
AARCHXX: Potential priv TLS layout issue
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
During the porting of RISCV64, I found an issue with the private TLS layout on the AARCHXX side. But I'm not sure about this, so here is an issue for further discussion.
Namely, in [loader_linux.c#L343](https://github.com/DynamoRIO/dynamorio/blob/master/core/unix/loader_linux.c#L343) and [loader_linux.c#L400](https://github.com/DynamoRIO/dynamorio/blob/master/core/unix/loader_linux.c#L400), dr_tp calculation seems incorrect.
Similar to RISC-V, ARM/Aarch64 uses the Variant I TLS layout, while x86 uses Variant II.


> https://www.uclibc.org/docs/tls.pdf
So for AARCHXX, at line 343, `dr_tp` should be calculated as: `dr_tp = dr_tp + TLS_PRE_TCB_SIZE;`, at line 400, should be: `dr_tp = dr_tp - TLS_PRE_TCB_SIZE;`.
For RISC-V, refer to https://github.com/DynamoRIO/dynamorio/pull/6147, at line 343, `dr_tp` should be calculated as: `dr_tp = dr_tp + TLS_PRE_TCB_SIZE + sizeof(tcb_head_t);`, at line 400, should be: `dr_tp = dr_tp - TLS_PRE_TCB_SIZE - sizeof(tcb_head_t);`. The RISC-V part will be submitted as a new PR once this issue is confirmed.
Contributor guide
Assessment
This issue has not been assessed yet.