aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Longo <matthieu.longo@arm.com>2024-09-23 15:03:35 +0100
committerTamar Christina <tamar.christina@arm.com>2024-09-23 15:12:07 +0100
commitba3e597681b640f6f9a676ec4f6cd3ca3878cefc (patch)
tree561658a46303033d053851abbd386c4473420816
parentf531673917e4f80ad51eda0d806f0479c501a907 (diff)
downloadgcc-ba3e597681b640f6f9a676ec4f6cd3ca3878cefc.zip
gcc-ba3e597681b640f6f9a676ec4f6cd3ca3878cefc.tar.gz
gcc-ba3e597681b640f6f9a676ec4f6cd3ca3878cefc.tar.bz2
aarch64: skip copy of RA state register into target context
The RA state register is local to a frame, so it should not be copied to the target frame during the context installation. This patch adds a new backend handler that check whether a register needs to be skipped or not before its installation. libgcc/ChangeLog: * config/aarch64/aarch64-unwind.h (MD_FRAME_LOCAL_REGISTER_P): new handler checking whether a register from the current context needs to be skipped before installation into the target context. (aarch64_frame_local_register): Likewise. * unwind-dw2.c (uw_install_context_1): use MD_FRAME_LOCAL_REGISTER_P.
-rw-r--r--libgcc/config/aarch64/aarch64-unwind.h11
-rw-r--r--libgcc/unwind-dw2.c5
2 files changed, 16 insertions, 0 deletions
diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h
index 94ea589..52bfd54 100644
--- a/libgcc/config/aarch64/aarch64-unwind.h
+++ b/libgcc/config/aarch64/aarch64-unwind.h
@@ -53,6 +53,9 @@ typedef enum {
#define MD_DEMANGLE_RETURN_ADDR(context, fs, addr) \
aarch64_demangle_return_addr (context, fs, addr)
+#define MD_FRAME_LOCAL_REGISTER_P(reg) \
+ aarch64_frame_local_register (reg)
+
static inline aarch64_ra_signing_method_t
aarch64_context_ra_state_get (struct _Unwind_Context *context)
{
@@ -127,6 +130,14 @@ aarch64_arch_extension_frame_init (struct _Unwind_Context *context ATTRIBUTE_UNU
aarch64_fs_ra_state_set (fs, aarch64_ra_no_signing);
}
+/* Before copying the current context to the target context, check whether
+ the register is local to this context and should not be forwarded. */
+static inline bool
+aarch64_frame_local_register(long reg)
+{
+ return (reg == AARCH64_DWARF_REGNUM_RA_STATE);
+}
+
/* Do AArch64 private extraction on ADDR_WORD based on context info CONTEXT and
unwind frame info FS. If ADDR_WORD is signed, we do address authentication
on it using CFA of current frame.
diff --git a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c
index 40d64c0..5f33f80 100644
--- a/libgcc/unwind-dw2.c
+++ b/libgcc/unwind-dw2.c
@@ -1423,6 +1423,11 @@ uw_install_context_1 (struct _Unwind_Context *current,
void *c = (void *) (_Unwind_Internal_Ptr) current->reg[i];
void *t = (void *) (_Unwind_Internal_Ptr)target->reg[i];
+#ifdef MD_FRAME_LOCAL_REGISTER_P
+ if (MD_FRAME_LOCAL_REGISTER_P (i))
+ continue;
+#endif
+
gcc_assert (current->by_value[i] == 0);
if (target->by_value[i] && c)
{