]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Account for aarch64 in init.c section for Android
authorOlivier Hainque <hainque@adacore.com>
Fri, 16 Aug 2024 15:10:59 +0000 (17:10 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 8 Oct 2024 08:37:11 +0000 (10:37 +0200)
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.

gcc/ada/init.c

index 93e73f53c64cf4f45137829107c6704149fa75c3..ad51e2e054da16bf723f65dbeb9d7981868b15e8 100644 (file)
@@ -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.  */