From 9da72a62eca3e4226480110e660357ec687ee2dd Mon Sep 17 00:00:00 2001 From: Evgeny Karpov Date: Fri, 7 Jun 2024 16:55:23 +0200 Subject: [PATCH] aarch64: Add debugging information 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 | 9 ++++++++ gcc/config/aarch64/cygming.h | 39 ++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f0672420aed..d90134009a4 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -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 diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h index bd6078023e3..e4ceab82b9e 100644 --- a/gcc/config/aarch64/cygming.h +++ b/gcc/config/aarch64/cygming.h @@ -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 \ { \