From: Sebastian Poeplau Date: Wed, 6 Mar 2024 20:10:04 +0000 (+0100) Subject: ada: Make raise-gcc.c compatible with Clang X-Git-Tag: basepoints/gcc-16~8954 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14aef595f01707c54926788346960b909ebea3b7;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c index 01cf4b6236d..7179f62529e 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