[binutils-gdb] GDB: aarch64: Fix inferior function call if GCS is present but disabled
Thiago Bauermann via Gdb-cvs <[email protected]> Wed, 22 Jul 2026 19:43:36 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4410648da673= eb72a456a7a2d925d6201bf2e2a2 commit 4410648da673eb72a456a7a2d925d6201bf2e2a2 Author: Thiago Jung Bauermann <[email protected]> Date: Wed Jul 8 14:48:54 2026 -0300 GDB: aarch64: Fix inferior function call if GCS is present but disabled =20 On AArch64, even if the Guarded Control Stack feature is present on the system the inferior may not have enabled it. =20 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.: =20 (gdb) p foo () Can't write to Guarded Control Stack. =20 The error message is because the GCSPR doesn't point to a valid memory address. =20 Fix by checking whether GCS is enabled in the inferior before trying to push a GCS entry. =20 Regression tested on an aarch64-linux-gnu QEMU VM with GCS present. =20 Approved-By: Luis Machado <[email protected]> Diff: --- gdb/aarch64-tdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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_enabl= ed); + if (gcs_is_enabled) + aarch64_push_gcs_entry (regcache, new_addr); } =20 /* Implement the "push_dummy_call" gdbarch method. */