]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Add debugging information
authorEvgeny Karpov <evgeny.karpov@microsoft.com>
Fri, 7 Jun 2024 14:55:23 +0000 (16:55 +0200)
committerEvgeny Karpov <eukarpov@gmail.com>
Tue, 19 Nov 2024 13:27:32 +0000 (14:27 +0100)
This patch enables DWARF and allows compilation with debugging
information by using "gcc -g". The unwind info is disabled for
the moment and will be revisited after SEH implementation for
the target.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (TARGET_ASM_UNALIGNED_HI_OP):
Enable DWARF.
(TARGET_ASM_UNALIGNED_SI_OP): Likewise.
(TARGET_ASM_UNALIGNED_DI_OP): Likewise.
* config/aarch64/cygming.h (DWARF2_DEBUGGING_INFO): Likewise.
(PREFERRED_DEBUGGING_TYPE): Likewise.
(DWARF2_UNWIND_INFO): Likewise.
(ASM_OUTPUT_DWARF_OFFSET): Likewise.

gcc/config/aarch64/aarch64.cc
gcc/config/aarch64/cygming.h

index f0672420aed6659c9b13642566d5015f7c2d60a3..d90134009a47a7f6a29ff51ef2f445f24498bcd4 100644 (file)
@@ -31131,6 +31131,15 @@ aarch64_run_selftests (void)
 #undef TARGET_ASM_ALIGNED_SI_OP
 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
 
+#if TARGET_PECOFF
+#undef TARGET_ASM_UNALIGNED_HI_OP
+#define TARGET_ASM_UNALIGNED_HI_OP TARGET_ASM_ALIGNED_HI_OP
+#undef TARGET_ASM_UNALIGNED_SI_OP
+#define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
+#undef TARGET_ASM_UNALIGNED_DI_OP
+#define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
+#endif
+
 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
   hook_bool_const_tree_hwi_hwi_const_tree_true
index bd6078023e368811df007f986f608397e4110846..e4ceab82b9ecfb876d540047812156e16aacac33 100644 (file)
@@ -21,8 +21,13 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_AARCH64_CYGMING_H
 #define GCC_AARCH64_CYGMING_H
 
+#define DWARF2_DEBUGGING_INFO 1
+
 #undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DINFO_TYPE_NONE
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 0
 
 #define FASTCALL_PREFIX '@'
 
@@ -75,6 +80,38 @@ still needed for compilation.  */
 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
   mingw_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
 
+/* Use section relative relocations for debugging offsets.  Unlike
+   other targets that fake this by putting the section VMA at 0, PE
+   won't allow it.  */
+#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \
+  do {                                                         \
+    switch (SIZE)                                              \
+      {                                                                \
+      case 4:                                                  \
+       fputs ("\t.secrel32\t", FILE);                          \
+       assemble_name (FILE, LABEL);                            \
+       if ((OFFSET) != 0)                                      \
+         fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,           \
+                  (HOST_WIDE_INT) (OFFSET));                   \
+       break;                                                  \
+      case 8:                                                  \
+       /* This is a hack.  There is no 64-bit section relative \
+          relocation.  However, the COFF format also does not  \
+          support 64-bit file offsets; 64-bit applications are \
+          limited to 32-bits of code+data in any one module.   \
+          Fake the 64-bit offset by zero-extending it.  */     \
+       fputs ("\t.secrel32\t", FILE);                          \
+       assemble_name (FILE, LABEL);                            \
+       if ((OFFSET) != 0)                                      \
+         fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC,           \
+                  (HOST_WIDE_INT) (OFFSET));                   \
+       fputs ("\n\t.long\t0", FILE);                           \
+       break;                                                  \
+      default:                                                 \
+       gcc_unreachable ();                                     \
+      }                                                                \
+  } while (0)
+
 #define TARGET_OS_CPP_BUILTINS()                                       \
   do                                                                   \
     {                                                                  \