]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Corrupted unwind info in aarch64-vx7r2 llvm kernel tests
authorDouglas B Rupp <rupp@adacore.com>
Fri, 3 Oct 2025 16:54:47 +0000 (09:54 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 13 Nov 2025 15:36:10 +0000 (16:36 +0100)
Adjust the register restoration on aarch64 to not use register 96
on llvm. Avoids the "reg too big" warning on aarch64 when sigtramp
is called.  For llvm and aarch64, the correct choice seems to be 32.

Remove parens on REGNO_PC_OFFSET when compiling,
it causes a silent failure due to alphanumeric register names.

Define a macro for __attribute ((optimize (2))) which is
empty if not availble. (Despite being documented, it generates an
"unknown attribute" warning with clang.)

Define ATTRIBUTE_PRINTF_2 if not defined.

gcc/ada/ChangeLog:

* sigtramp-vxworks-target.h (REGNO_PC_OFFSET): Use 32 vice
96 with llvm/clang. (REGNO_G_REG_OFFSET): Remove parens on
operand. (REGNO_GR): Likewise.
* sigtramp-vxworks.c (__gnat_sigtramp): Define a macro for
__attribute__ optimize, which is empty of not available.
* raise-gcc.c (db): Define ATTRIBUTE_PRINTF_2 if not defined.

gcc/ada/raise-gcc.c
gcc/ada/sigtramp-vxworks-target.h
gcc/ada/sigtramp-vxworks.c

index 34aa707ef5543044bada2e9f1fe40bf384f43b46..0a70cce7d38c762822dd1f02768063554ada98be 100644 (file)
@@ -274,6 +274,12 @@ db_indent (int requests)
     fprintf (stderr, "%*s", current_indentation_level * DB_INDENT_UNIT, " ");
 }
 
+/* If ATTRIBUTE_PRINTF_2 is not available, assume a printf format
+   attribute a-la gcc such as:  */
+#ifndef ATTRIBUTE_PRINTF_2
+#define ATTRIBUTE_PRINTF_2 __attribute((format(printf, 2, 3)))
+#endif
+
 static void ATTRIBUTE_PRINTF_2
 db (int db_code, const char * msg_format, ...)
 {
index 90c9c3cedfb3ff6331350587cf803385f709a5e4..00fb103b7a1b2d6e54e142d6da61e6fb82e71239 100644 (file)
 #undef TCR
 #define TCR(S) TAB(CR(S))
 
-/* REGNO constants, dwarf column numbers for registers of interest.  */
+/* REGNO constants, dwarf column numbers for registers of interest.
+
+   In the REGNO definitions that follow, when there is a register
+   number argument N, the use of parens around N in the result
+   is to be avoided.  These eventually expand as a register column
+   number in a .cfi_offset directive within an "asm" statement,
+   through stringification.  Parens in the macro expansion would
+   end up in the result and yield code such as
+
+     asm(".cfi_offset (0), <offset-expr>")
+
+   The parens impair readability here, and could even cause
+   processing errors from llvm compilers that interpret the
+   directives.  */
 
 #if defined (__PPC__)
 
 #define REGNO_CTR 66
 #define REGNO_CR  70
 #define REGNO_XER 76
-#define REGNO_GR(N) (N)
+#define REGNO_GR(N) N
 
 #define REGNO_PC  67  /* ARG_POINTER_REGNUM  */
 
 
 #elif defined (ARMEL)
 
-#define REGNO_G_REG_OFFSET(N) (N)
+#define REGNO_G_REG_OFFSET(N) N
 
 #define FUNCTION "%function"
 
 #ifdef __aarch64__
-#define REGNO_PC_OFFSET  96  /* DWARF_ALT_FRAME_RETURN_COLUMN */
+
+/* For the return column, GCC has DWARF_ALT_FRAME_RETURN_COLUMN (96)
+   while libunwind, used with llvm toolchains, implements the PC (!= LR)
+   ABI column 32.  */
+#ifdef __llvm__
+#define REGNO_PC_OFFSET 32
+#else
+#define REGNO_PC_OFFSET 96 /* DWARF_ALT_FRAME_RETURN_COLUMN */
+#endif
 #else
 #define REGNO_PC_OFFSET  15  /* PC_REGNUM */
 #endif
index 83bd2c6923f4e3099ffc9ff9d5a09e8ac1bd701d..2dff40d81b422beaa4eced874c4539712c195a19 100644 (file)
@@ -114,9 +114,17 @@ void __gnat_set_is_vxsim(int val) {
 }
 #endif
 
+/* When one is known for the compiler processing this runtime file,
+   a function attribute requesting optimization for the said function.
+   Assume __has_attribute is available for such queries, valid for at
+   least gcc and clang.  */
+#if __has_attribute(optimize)
+#define OPTIMIZE_O2  __attribute__((optimize(2)));
+#else
+#define OPTIMIZE_O2
+#endif
 void __gnat_sigtramp (int signo, void *si, void *sc,
-                     __sigtramphandler_t * handler)
-     __attribute__((optimize(2)));
+                     __sigtramphandler_t * handler) OPTIMIZE_O2;
 
 void __gnat_sigtramp (int signo, void *si, void *sc,
                      __sigtramphandler_t * handler)