]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>
Thu, 1 May 2025 21:12:19 +0000 (18:12 -0300)
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>
Fri, 29 Aug 2025 21:35:58 +0000 (18:35 -0300)
commitff62d39aa4999f44ac79360dee6357fc69d4e322
tree70213c3c357a5e93fa6ce54837100045306aa70e
parent02ecff0c714254cd5a67b55a6d11d62cfd904dbc
GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support

Add the org.gnu.gdb.aarch64.gcs feature with the GCSPR register, and the
org.gnu.gdb.aarch64.gcs.linux feature with "registers" to represent the
Linux kernel ptrace and prctl knobs that enable and lock specific GCS
functionality.

This code supports GCS only in Linux userspace applications, so the
GCSPR that is exposed is the one at EL0.

Also, support for calling inferior functions is enabled by adding an
implementation for the shadow_stack_push gdbarch method.

If for some reason a target description contains the
org.gnu.gdb.aarch64.gcs feature but not the
org.gnu.gdb.aarch64.gcs.linux feature then GCS support is disabled and
GDB continues the debugging session.  Features that need GCS
support (for example, calling inferior functions) will not work and the
inferior will get a segmentation fault signal instead.  There's a
testcase for this scenario but it only checks the native debugging case,
even though in practice this problem would only occur in remote
debugging with a broken stub or gdbserver.  I tested manually with a
gdbserver hacked to send a broken target description and it worked as
described.

Testcases gdb.arch/aarch64-gcs.exp, gdb.arch/aarch64-gcs-core.exp and
gdb.arch/aarch64-gcs-wrong-tdesc.exp are included to cover the added
functionality.

Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
Approved-By: Luis Machado <luis.machado@arm.com>
21 files changed:
gdb/aarch64-linux-nat.c
gdb/aarch64-linux-tdep.c
gdb/aarch64-tdep.c
gdb/aarch64-tdep.h
gdb/arch/aarch64-gcs-linux.h [new file with mode: 0644]
gdb/arch/aarch64.c
gdb/arch/aarch64.h
gdb/features/Makefile
gdb/features/aarch64-gcs-linux.c [new file with mode: 0644]
gdb/features/aarch64-gcs-linux.xml [new file with mode: 0644]
gdb/features/aarch64-gcs.c [new file with mode: 0644]
gdb/features/aarch64-gcs.xml [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs-core.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs-core.exp [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/aarch64-gcs.exp [new file with mode: 0644]
gdb/testsuite/lib/gdb.exp
gdbserver/linux-aarch64-low.cc