https://gcc.gnu.org/g:14aef595f01707c54926788346960b909ebea3b7
commit r15-599-g14aef595f01707c54926788346960b909ebea3b7 Author: Sebastian Poeplau <poep...@adacore.com> Date: Wed Mar 6 21:10:04 2024 +0100 ada: Make raise-gcc.c compatible with Clang The Morello variant of Clang doesn't have __builtin_code_address_from_pointer; work around it where necessary. gcc/ada/ * raise-gcc.c: Work around __builtin_code_address_from_pointer if it is unavailable. Diff: --- gcc/ada/raise-gcc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c index 01cf4b6236d1..7179f62529e1 100644 --- a/gcc/ada/raise-gcc.c +++ b/gcc/ada/raise-gcc.c @@ -596,7 +596,15 @@ get_ip_from_context (_Unwind_Context *uw_context) #endif #if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__CHERI__) +#if __has_builtin (__builtin_code_address_from_pointer) ip = __builtin_code_address_from_pointer ((void *)ip); +#elif defined(__aarch64__) + /* Clang doesn't have __builtin_code_address_from_pointer to abstract over + target-specific differences. On AArch64, we need to drop the LSB of the + instruction pointer because it's not part of the address; it indicates the + CPU mode. */ + ip &= ~1UL; +#endif #endif /* Subtract 1 if necessary because GetIPInfo yields a call return address