-
Notifications
You must be signed in to change notification settings - Fork 165
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
Relaxable TLSDESC only requires that R_RISCV_TLSDESC_HI20 to be paired with R_RISCV_RELAX #421
Conversation
My lld/ELF implementation checks whether the first instruction (R_RISCV_TLSDESC_HI20) has R_RISCV_RELAX On the LLVM side, I want to push for emitting one R_RISCV_RELAX as well. We don't need to do the same as |
Looks sensible. I think mold works without the RELAX annotations on paired relocs too, but I'll need to double check. |
I think that this issue is red herring because the number of RELAX relocations for TLSDESC is probably fewer than 0.1% of those for |
I made a reply: #401 (comment) I think we can ensure that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those kind of chained relocation, only the first relocation is enough to represent it's relaxable.
R_RISCV_PCREL_HI20
/R_RISCV_PCREL_LO12_[I|S]
may be the candidate, however I realized we really need a ABI version tag before doing those not fully compatible changes.
And another candidate for this idea is the long instruction sequence version of large code model I think :)
…d with R_RISCV_RELAX Requiring 4 R_RISCV_RELAX relocations impose a large size increase to the relocatable file. To mitigate this size increase, we can say that the whole TLSDESC code sequence is relaxable if the first instruction (R_RISCV_TLSDESC_HI20) is paired with R_RISCV_RELAX. A statically linked executable typically has a simple relocation resolver that handles just RELATIVE/IFUNC. For a `-fpic -mtls-dialect=desc` relocatable file, the linker is required to perform TLS optimization to local-exec for a statically linked executable. Therefore, instruction rewriting is essentially inevitable if the relocation resolver is kept simple. Ths general-dynamic TLS model, without a defined optimization scheme, actually has the same issue.
80292c4
to
c96a69e
Compare
Since folks agree that one
I added them just in case folks wanted it... I assume that @ishitatsuyuki will update the gas patch to not emit 4 |
Can this be merged? :) |
LGTM |
Requiring 4 R_RISCV_RELAX relocations impose a large size increase to the relocatable file. To mitigate this size increase, we can say that the whole TLSDESC code sequence is relaxable if the first instruction (R_RISCV_TLSDESC_HI20) is paired with R_RISCV_RELAX.
A statically linked executable typically has a simple relocation resolver that handles just RELATIVE/IFUNC. For a
-fpic -mtls-dialect=desc
relocatable file, the linker is required to perform TLS optimization to local-exec for a statically linked executable. Therefore, instruction rewriting is essentially inevitable if the relocation resolver is kept simple. Ths general-dynamic TLS model, without a defined optimization scheme, actually has the same issue.