-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
LLD AArch64 range extension thunk to PLT entry is not generating BTI (when BTI enabled) #62140
Comments
Doesn't this also affect direct branches to local functions whose address cannot be taken? I think the most straightforward fix would be use |
It does affect direct branches to functions without a landing pad. Clang adds BTI even for local functions whose address cannot be taken, but GCC does not (ARM-software/abi-aa#196). We hope to update the ABI on what the requirements for static-linkers and code-generators are shortly. Current plans are to put up a design doc with the options and their consequences. using Another adjacent change that could help is to implement short Thunks for AArch64. This would use a B, and would extend the branch range by another 128 MiB which should handle almost all user-space programs without needing an indirect branch. |
I've submitted a patch to add short range thunk support https://reviews.llvm.org/D148701 for AArch64. This should lower the probability that we get an indirect branch to either the PLT or a function without a BTI from a thunk. Not a fix for this problem, but an improvement that is worth making that should help. |
Thank you. That should cover us for clang compiled objects. |
I left a comment on https://reviews.llvm.org/D148701#4281776 that short range thunks may not work well with the current thunk selection code. D148704 looks close. Thank you! |
@llvm/issue-subscribers-lld-elf |
LLD will produce BTI compliant PLT entries when
-zforce-bti
is used or when all input objects are marked with the BTI property.Currently LLD will only put a BTI at the top of a PLT[N] entry in limited circumstances, the comment from the source file says:
There is also the rare, but can happen with large programs like Chrome built with instrumentation, case of a range extension thunk to the PLT entry. A contrived example:
With linker script:
Using:
Has the following disassembly:
Note the indirect jumpt to the PLT entry, which doesn't have a BTI c landing pad so the program will crash if BTI is enabled.
The simplest way to fix this is to track which symbols with
isInPlt() == true
are the targets of range extension thunks. We can then extend the existing canonical PLT check to include thunks.Other possibilities include BTI aware range extension thunks see AArch64 ABI issue for more details ARM-software/abi-aa#196
The text was updated successfully, but these errors were encountered: