From: Olivier Hainque <hain...@adacore.com> Unlike the ARM port already there, aarch64 is dwarf CFI based for unwinding and Android-Linux exposes kernel CFI for signal handlers.
gcc/ada/ChangeLog: * init.c (__gnat_error_handler): Map signals straight to Ada exceptions, without a local CFI trampoline. (__gnat_adjust_context_for_raise): Guard arm specific code on __arm__ compilation. Do nothing otherwise, relying on libgcc's signal frame recognition for PC/RA adjustments. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 93e73f53c64..ad51e2e054d 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2782,10 +2782,16 @@ __gnat_install_handler () void __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED, void *ucontext) { +#if defined(__arm__) mcontext_t *mcontext = &((ucontext_t *) ucontext)->uc_mcontext; /* ARM Bump has to be an even number because of odd/even architecture. */ ((mcontext_t *) mcontext)->arm_pc += 2; +#endif + + /* Other ports, based on dwarf2 unwinding, typically leverage + kernel CFI coordinated with libgcc's explicit support for signal + frames. */ } static void @@ -2826,8 +2832,14 @@ __gnat_error_handler (int sig, siginfo_t *si, void *ucontext) { __gnat_adjust_context_for_raise (sig, ucontext); + /* The ARM port relies on a sigtramp. Others such as aarch64, + dwarf info based, rely on kernel CFI. */ +#if defined(__arm__) __gnat_sigtramp (sig, (void *) si, (void *) ucontext, (__sigtramphandler_t *)&__gnat_map_signal); +#else + __gnat_map_signal (sig, si, ucontext); +#endif } /* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */ -- 2.43.0