]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Make raise-gcc.c compatible with Clang
authorSebastian Poeplau <poeplau@adacore.com>
Wed, 6 Mar 2024 20:10:04 +0000 (21:10 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 17 May 2024 08:21:01 +0000 (10:21 +0200)
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.

gcc/ada/raise-gcc.c

index 01cf4b6236d105f7605ece72acf651db0b48b16d..7179f62529e1b87bd75306a1c7b89970518df0b0 100644 (file)
@@ -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