-
-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RV64: Implement TLS relaxation #461
Comments
Hi Rui, I would like to implement this but it may take some time as I am not familiar with the ELF TLS model. |
Sure. I'll assign this bug to you to avoid duplicate effort. Feel free to ask any questions. |
Firstly, I'm trying to open all the In tls-gd.sh, in the end, we are trying to statically link the three PIC object files together. In this very case, the output becomes 0 2 0 0 0 0 instead of the expected 1 2 3 4 5 6, I haven't found the reason yet. ksco@ac878cb#diff-8d8a35fafde296bbdfcf817940e5559dc0fb2a1bc4aaea5822870253cdbaac74R68 |
TLS is super tricky. I don't know what's wrong, let me take a look. |
For RISC-V, DTPOFF is computed 0x800 off from the start of each TLS block to maximize the accessible range for memory access instructions with signed 12-bit immediate. DTPMOD is usually computed by the dynamic loader, but when we do for static binaries, we need to subtract 0x800 to offset the offset. #461
I fixed the issue in the above commit. |
That's amazing! |
I think this is done since we already handled the Thread-pointer Relaxation, right? |
By TLS relaxation, I meant conversion of General Dynamic → Local Exec and Local Dynamic → Local Exec, and not the RISC-V-specific %tp optimization. But I found that the RISC-V psABI lacks a mechanism to allow GD → LD (riscv-non-isa/riscv-elf-psabi-doc#308), so maybe this is infeasible. It's a spec bug, though. |
Oh, seems they're gonna add this mechanism after spec 1.0 is released, so I think I'll just wait till that happens. |
TLSDESC for RISC-V has now been ratified, and we've implement it to mold. I think we can close this issue now. |
mold currently doesn't relax any TLS relocations at all. We should implement GD → LE and LD → LE relaxations just like we did to x86-64.
The text was updated successfully, but these errors were encountered: