[lld] [LLD][ELF][AArch64] Add BTI Aware long branch thunks (PR #108989)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 21 18:33:26 PDT 2024
================
@@ -2326,6 +2334,21 @@ bool ThunkCreator::createThunks(uint32_t pass,
ts = getISDThunkSec(os, isec, isd, rel, src);
ts->addThunk(t);
thunks[t->getThunkTargetSym()] = t;
+
+ // When indirect branches are restricted, such as AArch64 BTI
+ // Thunks may need to target a linker generated landing pad
+ // instead of the target.
+ if (t->needsSyntheticLandingPad()) {
+ Thunk *lpt;
+ auto &dr = cast<Defined>(t->destination);
+ std::tie(lpt, isNew) = getSyntheticLandingPad(dr, t->addend);
+ if (isNew) {
+ InputSection *targetsec = dyn_cast<InputSection>(dr.section);
----------------
MaskRay wrote:
It seems that `targetSec` could be nullptr in erroneous non-InputSection cases (MergeInputSection) and would cause a null pointer dereference in `getISThunkSec`.
If we don't write code guarding against such cases, perhaps just use `cast<>`.
https://github.com/llvm/llvm-project/pull/108989
More information about the llvm-commits
mailing list