@@ -302,12 +302,21 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace,
302302
303303 isSignalFrame = cieInfo.isSignalFrame ;
304304
305- #if defined(__ARM64E__)
306- // If the target is using the arm64e ABI then the return address has
307- // been signed using the stack pointer as a diversifier. The original
308- // return address needs to be authenticated before the it is restored.
309- // autia1716 is used instead of autia as autia1716 assembles to a NOP on
310- // pre-v8.3a architectures.
305+ #if defined(_LIBUNWIND_TARGET_AARCH64) && \
306+ !defined (_LIBUNWIND_TARGET_AARCH64_AUTHENTICATED_UNWINDING)
307+ // There are two ways of return address signing: pac-ret (enabled via
308+ // -mbranch-protection=pac-ret) and ptrauth-returns (enabled as part of
309+ // Apple's arm64e or experimental pauthtest ABI on Linux). The code
310+ // below handles signed RA for pac-ret, while ptrauth-returns uses
311+ // different logic.
312+ // TODO: unify logic for both cases, see
313+ // https://github.com/llvm/llvm-project/issues/160110
314+ //
315+ // If the target is aarch64 then the return address may have been signed
316+ // using the v8.3 pointer authentication extensions. The original
317+ // return address needs to be authenticated before the return address is
318+ // restored. autia1716 is used instead of autia as autia1716 assembles
319+ // to a NOP on pre-v8.3a architectures.
311320 if ((R::getArch () == REGISTERS_ARM64) &&
312321 isReturnAddressSigned (addressSpace, registers, cfa, prolog) &&
313322 returnAddress != 0 ) {
0 commit comments