[lld] [LLD][AArch64] Detach Landing Pad creation from Thunk creation (PR #116402)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 15 09:17:13 PST 2024
================
@@ -2293,6 +2293,31 @@ bool ThunkCreator::normalizeExistingThunk(Relocation &rel, uint64_t src) {
return false;
}
+// When indirect branches are restricted, such as AArch64 BTI Thunks may need
+// to target a linker generated landing pad instead of the target. This needs
+// to be done once per pass as the need for a BTI thunk is dependent whether
+// a thunk is short or long. We iterate over all the thunks to make sure we
+// catch thunks that have been created but are no longer live. Non-live thunks
+// are not reachable via normalizeExistingThunk() but are still written.
+bool ThunkCreator::addSyntheticLandingPads() {
+ bool addressesChanged = false;
+ for (Thunk *t : allThunks) {
+ if (t->needsSyntheticLandingPad()) {
+ Thunk *lpt;
+ bool isNew;
+ auto &dr = cast<Defined>(t->destination);
+ std::tie(lpt, isNew) = getSyntheticLandingPad(dr, t->addend);
+ if (isNew) {
+ addressesChanged = true;
+ ThunkSection *ts = getISThunkSec(cast<InputSection>(dr.section));
----------------
MaskRay wrote:
The used-once variable can be avoided
https://github.com/llvm/llvm-project/pull/116402
More information about the llvm-commits
mailing list