[lld] [LLD][AArch64] Detach Landing Pad creation from Thunk creation (PR #116402)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 10:18:04 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()) {
----------------
smithp35 wrote:

I've flipped the condition so it can continue. This loses a level of indentation. We need to go through all the thunks so we can't return.

https://github.com/llvm/llvm-project/pull/116402


More information about the llvm-commits mailing list