From: Thiago Jung Bauermann Date: Wed, 8 Jul 2026 17:48:54 +0000 (-0300) Subject: GDB: aarch64: Fix inferior function call if GCS is present but disabled X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4410648da673eb72a456a7a2d925d6201bf2e2a2;p=thirdparty%2Fbinutils-gdb.git GDB: aarch64: Fix inferior function call if GCS is present but disabled On AArch64, even if the Guarded Control Stack feature is present on the system the inferior may not have enabled it. There's a bug in GDB's GCS support in that if the system supports GCS, GDB will always push a GCS entry when doing an inferior function call even if the inferior doesn't have it enabled. This causes inferior function calls to fail. E.g.: (gdb) p foo () Can't write to Guarded Control Stack. The error message is because the GCSPR doesn't point to a valid memory address. Fix by checking whether GCS is enabled in the inferior before trying to push a GCS entry. Regression tested on an aarch64-linux-gnu QEMU VM with GCS present. Approved-By: Luis Machado --- diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index a84da1fd59e..950ad4f6aae 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1934,7 +1934,11 @@ static void aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr, regcache *regcache) { - aarch64_push_gcs_entry (regcache, new_addr); + bool gcs_is_enabled; + + (void) gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled); + if (gcs_is_enabled) + aarch64_push_gcs_entry (regcache, new_addr); } /* Implement the "push_dummy_call" gdbarch method. */