Skip to content

Commit bf26f91

Browse files
committed
Make __is_function_overridden pauth-aware on ELF platforms
1 parent d7dd2c4 commit bf26f91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libcxx/src/include/overridable_function.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
116116
uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
117117
uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);
118118

119+
# if __has_feature(ptrauth_calls)
120+
// We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
121+
// we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
122+
// to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
123+
// stripped the function pointer.
124+
__ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
125+
# endif
126+
119127
return __ptr < __start || __ptr > __end;
120128
}
121129
_LIBCPP_END_NAMESPACE_STD

0 commit comments

Comments
 (0)