From 11ec68e35e31f8e332b472a89557ae69b4162a62 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 10:38:07 +0000 Subject: [PATCH 1/2] Initial plan From 720813439c4fb5fbc86858b714ebaebe7f7c0601 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:06:46 +0000 Subject: [PATCH 2/2] Use hint-safe PAC stripping in NativeAOT Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com> --- src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S | 13 +++++++++---- src/coreclr/nativeaot/Runtime/arm64/MiscStubs.asm | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S b/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S index 21c44d8fb38d15..caa32ce765790a 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S +++ b/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S @@ -7,11 +7,16 @@ // void* PacStripPtr(void *); // This function strips the pointer of PAC info that is passed as an argument. // We prefer to strip a pointer where it's not going to be used to branch execution to. +// It is a no-op on non-PAC enabled machines. .arch_extension pauth - LEAF_ENTRY PacStripPtr, _TEXT - xpaci x0 - ret - LEAF_END PacStripPtr, _TEXT + NESTED_ENTRY PacStripPtr, _TEXT, NoHandler + PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -16 + mov lr, x0 + xpaclri + mov x0, lr + EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 16 + EPILOG_RETURN + NESTED_END PacStripPtr, _TEXT // void* PacSignPtr(void *, void *); // This function signs the input pointer using x1 as salt. It is a no-op on non-PAC enabled machines. diff --git a/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.asm b/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.asm index d31511558da154..a24fd43accdd60 100644 --- a/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.asm +++ b/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.asm @@ -8,10 +8,15 @@ ; void* PacStripPtr(void *); ; This function strips the pointer of PAC info that is passed as an argument. ; We prefer to strip a pointer where it's not going to be used to branch execution to. - LEAF_ENTRY PacStripPtr - DCD 0xDAC143E0 ; xpaci x0 instruction in binary to avoid requiring PAC-enabled assemblers - ret - LEAF_END PacStripPtr +; It is a no-op on non-PAC enabled machines. + NESTED_ENTRY PacStripPtr + PROLOG_SAVE_REG_PAIR fp, lr, #-16! + mov lr, x0 + DCD 0xD50320FF ; xpaclri instruction in binary to avoid requiring PAC-enabled assemblers + mov x0, lr + EPILOG_RESTORE_REG_PAIR fp, lr, #16! + EPILOG_RETURN + NESTED_END ; void* PacSignPtr(void *, void *); ; This function signs the input pointer using x1 as salt. It is a no-op on non-PAC enabled machines.