Skip to content

Commit

Permalink
feat: support PAC stripping on older assemblers. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus authored Jan 27, 2025
1 parent d129c02 commit 4cc763c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions util/linux/pac_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ VMAddress StripPACBits(VMAddress address) {
#elif defined(ARCH_CPU_ARM64)
// Strip any pointer authentication bits that are assigned to the address.
register uintptr_t x30 __asm("x30") = address;
#ifdef SENTRY_MODIFIED
asm("xpaclri" : "+r"(x30));
#else
// `xpaclri` is to be decoded as `NOP` if `FEAT_PAuth` is not implemented:
// https://developer.arm.com/documentation/ddi0602/2024-12/Base-Instructions/XPACD--XPACI--XPACLRI--Strip-Pointer-Authentication-Code-#XPACLRI_HI_hints
// which means we don't need any runtime checks on pre-ARMv8.3 or
// environments where it is disabled.
// Use `hint #7` as encoded here https://developer.arm.com/documentation/ddi0602/2024-12/Base-Instructions/HINT--Hint-instruction-
// to support older toolchains with assemblers that don't know `xpaclri`:
asm("hint #7" /* = xpaclri */ : "+r"(x30));
#endif
address = x30;
#endif
return address;
Expand Down

0 comments on commit 4cc763c

Please sign in to comment.