* [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-17 6:00 [PATCH v3 0/4] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
@ 2026-02-17 6:00 ` Thiago Jung Bauermann
2026-02-21 12:14 ` Luis
2026-02-17 6:01 ` [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h Thiago Jung Bauermann
` (2 subsequent siblings)
3 siblings, 1 reply; 15+ messages in thread
From: Thiago Jung Bauermann @ 2026-02-17 6:00 UTC (permalink / raw)
To: gdb-patches; +Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi
The code supporting Pointer Authentication duplicates the definition of
AARCH64_HWCAP_PACA and of AARCH64_LINUX_SIZEOF_PAUTH between GDB and
gdbserver, so add new header to host those definitions.
Also, rename AARCH64_HWCAP_PACA to HWCAP_PACA and only define it if it
isn't already defined by the system headers, as is done for other HWCAP
constants.
Suggested-by: Luis <luis.machado.foss@gmail.com>
---
gdb/Makefile.in | 1 +
gdb/aarch64-linux-nat.c | 3 ++-
gdb/aarch64-linux-tdep.c | 3 ++-
gdb/aarch64-linux-tdep.h | 6 ------
gdb/arch/aarch64-pauth-linux.h | 31 +++++++++++++++++++++++++++++++
gdb/arch/aarch64.h | 3 ---
gdbserver/linux-aarch64-low.cc | 8 +++-----
7 files changed, 39 insertions(+), 16 deletions(-)
create mode 100644 gdb/arch/aarch64-pauth-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 2aa95be968ac..8f8a95beccc3 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1306,6 +1306,7 @@ HFILES_NO_SRCDIR = \
arch/aarch64-insn.h \
arch/aarch64-mte.h \
arch/aarch64-mte-linux.h \
+ arch/aarch64-pauth-linux.h \
arch/aarch64-scalable-linux.h \
arch/amd64.h \
arch/amd64-linux-tdesc.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 028de981588b..d310d3e814b2 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -53,6 +53,7 @@
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
+#include "arch/aarch64-pauth-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
#include "arch/aarch64-scalable-linux.h"
@@ -1012,7 +1013,7 @@ aarch64_linux_nat_target::read_description ()
or the streaming vector length, depending on whether streaming mode is
active or not. */
features.vq = aarch64_sve_get_vq (tid);
- features.pauth = hwcap & AARCH64_HWCAP_PACA;
+ features.pauth = hwcap & HWCAP_PACA;
features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index b85c25ecae1d..b5af281d8a40 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -54,6 +54,7 @@
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
+#include "arch/aarch64-pauth-linux.h"
#include "arch/aarch64-scalable-linux.h"
#include "arch-utils.h"
@@ -1760,7 +1761,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
have the correct target description with the correct SVE vector
length. */
features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
- features.pauth = hwcap & AARCH64_HWCAP_PACA;
+ features.pauth = hwcap & HWCAP_PACA;
features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
features.fpmr = hwcap2 & HWCAP2_FPMR;
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index e926687ff6eb..b99fe91f36bd 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -33,16 +33,10 @@
alignment. */
#define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
-/* The pauth regset consists of 2 X sized registers. */
-#define AARCH64_LINUX_SIZEOF_PAUTH (2 * X_REGISTER_SIZE)
-
/* The MTE regset consists of a 64-bit register. */
#define AARCH64_LINUX_SIZEOF_MTE_REGSET (8)
extern const struct regset aarch64_linux_gregset;
extern const struct regset aarch64_linux_fpregset;
-/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
-#define AARCH64_HWCAP_PACA (1 << 30)
-
#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/arch/aarch64-pauth-linux.h b/gdb/arch/aarch64-pauth-linux.h
new file mode 100644
index 000000000000..e973c79c8767
--- /dev/null
+++ b/gdb/arch/aarch64-pauth-linux.h
@@ -0,0 +1,31 @@
+/* Common Linux target-dependent definitions for AArch64 PAuth.
+
+ Copyright (C) 2019-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_ARCH_AARCH64_PAUTH_LINUX_H
+#define GDB_ARCH_AARCH64_PAUTH_LINUX_H
+
+/* Feature check for Pointer Authentication Code Extension. */
+#ifndef HWCAP_PACA
+#define HWCAP_PACA (1 << 30)
+#endif
+
+/* The pauth regset consists of 2 64-bit registers. */
+#define AARCH64_LINUX_SIZEOF_PAUTH 16
+
+#endif /* GDB_ARCH_AARCH64_PAUTH_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 0e9715a4268a..7856d95a93b1 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -178,9 +178,6 @@ enum aarch64_regnum
#define AARCH64_PAUTH_DMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 2)
#define AARCH64_PAUTH_CMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 3)
-/* This size is only meant for Linux, not bare metal. QEMU exposes 4 masks. */
-#define AARCH64_PAUTH_REGS_SIZE (16)
-
#define AARCH64_X_REGS_NUM 31
#define AARCH64_V_REGS_NUM 32
#define AARCH64_SVE_Z_REGS_NUM AARCH64_V_REGS_NUM
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index b19e605f55d6..69aaabc1a8f9 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -45,6 +45,7 @@
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
#include "nat/aarch64-mte-linux-ptrace.h"
+#include "arch/aarch64-pauth-linux.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "tdesc.h"
@@ -952,7 +953,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
break;
case NT_ARM_PAC_MASK:
if (features.pauth)
- regset->size = AARCH64_PAUTH_REGS_SIZE;
+ regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
break;
case NT_ARM_TAGGED_ADDR_CTRL:
if (features.mte)
@@ -984,9 +985,6 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
}
}
-/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
-#define AARCH64_HWCAP_PACA (1 << 30)
-
/* Implementation of linux target ops method "low_arch_setup". */
void
@@ -1005,7 +1003,7 @@ aarch64_target::low_arch_setup ()
features.vq = aarch64_sve_get_vq (tid);
/* A-profile PAC is 64-bit only. */
- features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA;
+ features.pauth = linux_get_hwcap (pid, 8) & HWCAP_PACA;
/* A-profile MTE is 64-bit only. */
features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-17 6:00 ` [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h Thiago Jung Bauermann
@ 2026-02-21 12:14 ` Luis
2026-02-21 15:57 ` Simon Marchi
0 siblings, 1 reply; 15+ messages in thread
From: Luis @ 2026-02-21 12:14 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Tom Tromey, Simon Marchi
On 17/02/2026 06:00, Thiago Jung Bauermann wrote:
> The code supporting Pointer Authentication duplicates the definition of
> AARCH64_HWCAP_PACA and of AARCH64_LINUX_SIZEOF_PAUTH between GDB and
> gdbserver, so add new header to host those definitions.
>
> Also, rename AARCH64_HWCAP_PACA to HWCAP_PACA and only define it if it
> isn't already defined by the system headers, as is done for other HWCAP
> constants.
>
> Suggested-by: Luis <luis.machado.foss@gmail.com>
> ---
> gdb/Makefile.in | 1 +
> gdb/aarch64-linux-nat.c | 3 ++-
> gdb/aarch64-linux-tdep.c | 3 ++-
> gdb/aarch64-linux-tdep.h | 6 ------
> gdb/arch/aarch64-pauth-linux.h | 31 +++++++++++++++++++++++++++++++
> gdb/arch/aarch64.h | 3 ---
> gdbserver/linux-aarch64-low.cc | 8 +++-----
> 7 files changed, 39 insertions(+), 16 deletions(-)
> create mode 100644 gdb/arch/aarch64-pauth-linux.h
>
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index 2aa95be968ac..8f8a95beccc3 100644
> --- a/gdb/Makefile.in
> +++ b/gdb/Makefile.in
> @@ -1306,6 +1306,7 @@ HFILES_NO_SRCDIR = \
> arch/aarch64-insn.h \
> arch/aarch64-mte.h \
> arch/aarch64-mte-linux.h \
> + arch/aarch64-pauth-linux.h \
> arch/aarch64-scalable-linux.h \
> arch/amd64.h \
> arch/amd64-linux-tdesc.h \
> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index 028de981588b..d310d3e814b2 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -53,6 +53,7 @@
>
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte-linux.h"
> +#include "arch/aarch64-pauth-linux.h"
>
> #include "nat/aarch64-mte-linux-ptrace.h"
> #include "arch/aarch64-scalable-linux.h"
> @@ -1012,7 +1013,7 @@ aarch64_linux_nat_target::read_description ()
> or the streaming vector length, depending on whether streaming mode is
> active or not. */
> features.vq = aarch64_sve_get_vq (tid);
> - features.pauth = hwcap & AARCH64_HWCAP_PACA;
> + features.pauth = hwcap & HWCAP_PACA;
> features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
> features.mte = hwcap2 & HWCAP2_MTE;
> features.tls = aarch64_tls_register_count (tid);
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index b85c25ecae1d..b5af281d8a40 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -54,6 +54,7 @@
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte.h"
> #include "arch/aarch64-mte-linux.h"
> +#include "arch/aarch64-pauth-linux.h"
> #include "arch/aarch64-scalable-linux.h"
>
> #include "arch-utils.h"
> @@ -1760,7 +1761,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
> have the correct target description with the correct SVE vector
> length. */
> features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
> - features.pauth = hwcap & AARCH64_HWCAP_PACA;
> + features.pauth = hwcap & HWCAP_PACA;
> features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
> features.mte = hwcap2 & HWCAP2_MTE;
> features.fpmr = hwcap2 & HWCAP2_FPMR;
> diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
> index e926687ff6eb..b99fe91f36bd 100644
> --- a/gdb/aarch64-linux-tdep.h
> +++ b/gdb/aarch64-linux-tdep.h
> @@ -33,16 +33,10 @@
> alignment. */
> #define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
>
> -/* The pauth regset consists of 2 X sized registers. */
> -#define AARCH64_LINUX_SIZEOF_PAUTH (2 * X_REGISTER_SIZE)
> -
> /* The MTE regset consists of a 64-bit register. */
> #define AARCH64_LINUX_SIZEOF_MTE_REGSET (8)
>
> extern const struct regset aarch64_linux_gregset;
> extern const struct regset aarch64_linux_fpregset;
>
> -/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
> -#define AARCH64_HWCAP_PACA (1 << 30)
> -
> #endif /* GDB_AARCH64_LINUX_TDEP_H */
> diff --git a/gdb/arch/aarch64-pauth-linux.h b/gdb/arch/aarch64-pauth-linux.h
> new file mode 100644
> index 000000000000..e973c79c8767
> --- /dev/null
> +++ b/gdb/arch/aarch64-pauth-linux.h
> @@ -0,0 +1,31 @@
> +/* Common Linux target-dependent definitions for AArch64 PAuth.
> +
> + Copyright (C) 2019-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_ARCH_AARCH64_PAUTH_LINUX_H
> +#define GDB_ARCH_AARCH64_PAUTH_LINUX_H
> +
> +/* Feature check for Pointer Authentication Code Extension. */
> +#ifndef HWCAP_PACA
> +#define HWCAP_PACA (1 << 30)
> +#endif
> +
> +/* The pauth regset consists of 2 64-bit registers. */
> +#define AARCH64_LINUX_SIZEOF_PAUTH 16
> +
> +#endif /* GDB_ARCH_AARCH64_PAUTH_LINUX_H */
> diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
> index 0e9715a4268a..7856d95a93b1 100644
> --- a/gdb/arch/aarch64.h
> +++ b/gdb/arch/aarch64.h
> @@ -178,9 +178,6 @@ enum aarch64_regnum
> #define AARCH64_PAUTH_DMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 2)
> #define AARCH64_PAUTH_CMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 3)
>
> -/* This size is only meant for Linux, not bare metal. QEMU exposes 4 masks. */
> -#define AARCH64_PAUTH_REGS_SIZE (16)
> -
> #define AARCH64_X_REGS_NUM 31
> #define AARCH64_V_REGS_NUM 32
> #define AARCH64_SVE_Z_REGS_NUM AARCH64_V_REGS_NUM
> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
> index b19e605f55d6..69aaabc1a8f9 100644
> --- a/gdbserver/linux-aarch64-low.cc
> +++ b/gdbserver/linux-aarch64-low.cc
> @@ -45,6 +45,7 @@
> #include "linux-aarch32-tdesc.h"
> #include "linux-aarch64-tdesc.h"
> #include "nat/aarch64-mte-linux-ptrace.h"
> +#include "arch/aarch64-pauth-linux.h"
> #include "nat/aarch64-scalable-linux-ptrace.h"
> #include "tdesc.h"
>
> @@ -952,7 +953,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
> break;
> case NT_ARM_PAC_MASK:
> if (features.pauth)
> - regset->size = AARCH64_PAUTH_REGS_SIZE;
> + regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
> break;
> case NT_ARM_TAGGED_ADDR_CTRL:
> if (features.mte)
> @@ -984,9 +985,6 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
> }
> }
>
> -/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
> -#define AARCH64_HWCAP_PACA (1 << 30)
> -
> /* Implementation of linux target ops method "low_arch_setup". */
>
> void
> @@ -1005,7 +1003,7 @@ aarch64_target::low_arch_setup ()
>
> features.vq = aarch64_sve_get_vq (tid);
> /* A-profile PAC is 64-bit only. */
> - features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA;
> + features.pauth = linux_get_hwcap (pid, 8) & HWCAP_PACA;
> /* A-profile MTE is 64-bit only. */
> features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
> features.tls = aarch64_tls_register_count (tid);
Thanks for the cleanup. This one is OK.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-21 12:14 ` Luis
@ 2026-02-21 15:57 ` Simon Marchi
2026-02-22 10:06 ` Luis
0 siblings, 1 reply; 15+ messages in thread
From: Simon Marchi @ 2026-02-21 15:57 UTC (permalink / raw)
To: Luis, Thiago Jung Bauermann, gdb-patches; +Cc: Chris Packham, Tom Tromey
>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>> index b85c25ecae1d..b5af281d8a40 100644
>> --- a/gdb/aarch64-linux-tdep.c
>> +++ b/gdb/aarch64-linux-tdep.c
>> @@ -54,6 +54,7 @@
>> #include "arch/aarch64-gcs-linux.h"
>> #include "arch/aarch64-mte.h"
>> #include "arch/aarch64-mte-linux.h"
>> +#include "arch/aarch64-pauth-linux.h"
>> #include "arch/aarch64-scalable-linux.h"
>> #include "arch-utils.h"
>> @@ -1760,7 +1761,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
>> have the correct target description with the correct SVE vector
>> length. */
>> features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
>> - features.pauth = hwcap & AARCH64_HWCAP_PACA;
>> + features.pauth = hwcap & HWCAP_PACA;
See comment below about HWCAP_PACA.
>> diff --git a/gdb/arch/aarch64-pauth-linux.h b/gdb/arch/aarch64-pauth-linux.h
>> new file mode 100644
>> index 000000000000..e973c79c8767
>> --- /dev/null
>> +++ b/gdb/arch/aarch64-pauth-linux.h
>> @@ -0,0 +1,31 @@
>> +/* Common Linux target-dependent definitions for AArch64 PAuth.
>> +
>> + Copyright (C) 2019-2026 Free Software Foundation, Inc.
>> +
>> + This file is part of GDB.
>> +
>> + This program is free software; you can redistribute it and/or modify
>> + it under the terms of the GNU General Public License as published by
>> + the Free Software Foundation; either version 3 of the License, or
>> + (at your option) any later version.
>> +
>> + This program is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + GNU General Public License for more details.
>> +
>> + You should have received a copy of the GNU General Public License
>> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
>> +
>> +#ifndef GDB_ARCH_AARCH64_PAUTH_LINUX_H
>> +#define GDB_ARCH_AARCH64_PAUTH_LINUX_H
>> +
>> +/* Feature check for Pointer Authentication Code Extension. */
>> +#ifndef HWCAP_PACA
>> +#define HWCAP_PACA (1 << 30)
>> +#endif
As per the previous discussions, I'm not sure this definition of
HWCAP_PACA should be here. For instance, what if another architecture
defines a HWCAP_PACA with a different meaning/value? It should only be
seen by native code, so it should be somehwere in nat/.
For the same reason, I think that aarch64-linux-tdep.c should use a
constant named AARCH64_HWCAP_PACA, not HWCAP_PACA. I thought this was
the conclusion of the previous discussions, there might have been a
misunderstanding.
The native files aarch64-linux-nat.c and linux-aarch64-low.cc can use
HWCAP_PACA though, because they see the definition from the system
headers (or worst case, a definition from nat/, to support compiling
against older kernels).
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-21 15:57 ` Simon Marchi
@ 2026-02-22 10:06 ` Luis
2026-02-22 14:22 ` Simon Marchi
0 siblings, 1 reply; 15+ messages in thread
From: Luis @ 2026-02-22 10:06 UTC (permalink / raw)
To: Simon Marchi, Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Tom Tromey
On 21/02/2026 15:57, Simon Marchi wrote:
>>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>>> index b85c25ecae1d..b5af281d8a40 100644
>>> --- a/gdb/aarch64-linux-tdep.c
>>> +++ b/gdb/aarch64-linux-tdep.c
>>> @@ -54,6 +54,7 @@
>>> #include "arch/aarch64-gcs-linux.h"
>>> #include "arch/aarch64-mte.h"
>>> #include "arch/aarch64-mte-linux.h"
>>> +#include "arch/aarch64-pauth-linux.h"
>>> #include "arch/aarch64-scalable-linux.h"
>>> #include "arch-utils.h"
>>> @@ -1760,7 +1761,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
>>> have the correct target description with the correct SVE vector
>>> length. */
>>> features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
>>> - features.pauth = hwcap & AARCH64_HWCAP_PACA;
>>> + features.pauth = hwcap & HWCAP_PACA;
>
> See comment below about HWCAP_PACA.
>
>>> diff --git a/gdb/arch/aarch64-pauth-linux.h b/gdb/arch/aarch64-pauth-linux.h
>>> new file mode 100644
>>> index 000000000000..e973c79c8767
>>> --- /dev/null
>>> +++ b/gdb/arch/aarch64-pauth-linux.h
>>> @@ -0,0 +1,31 @@
>>> +/* Common Linux target-dependent definitions for AArch64 PAuth.
>>> +
>>> + Copyright (C) 2019-2026 Free Software Foundation, Inc.
>>> +
>>> + This file is part of GDB.
>>> +
>>> + This program is free software; you can redistribute it and/or modify
>>> + it under the terms of the GNU General Public License as published by
>>> + the Free Software Foundation; either version 3 of the License, or
>>> + (at your option) any later version.
>>> +
>>> + This program is distributed in the hope that it will be useful,
>>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>>> + GNU General Public License for more details.
>>> +
>>> + You should have received a copy of the GNU General Public License
>>> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
>>> +
>>> +#ifndef GDB_ARCH_AARCH64_PAUTH_LINUX_H
>>> +#define GDB_ARCH_AARCH64_PAUTH_LINUX_H
>>> +
>>> +/* Feature check for Pointer Authentication Code Extension. */
>>> +#ifndef HWCAP_PACA
>>> +#define HWCAP_PACA (1 << 30)
>>> +#endif
>
> As per the previous discussions, I'm not sure this definition of
> HWCAP_PACA should be here. For instance, what if another architecture
> defines a HWCAP_PACA with a different meaning/value? It should only be
> seen by native code, so it should be somehwere in nat/.
>
> For the same reason, I think that aarch64-linux-tdep.c should use a
> constant named AARCH64_HWCAP_PACA, not HWCAP_PACA. I thought this was
> the conclusion of the previous discussions, there might have been a
> misunderstanding.
I don´t recall the discussions touching renaming/moving of these
constants. But I see your point. I just don´t think we should block this
series from going in on that particular snag. We should try a
refactoring as a follow on.
On the naming, I don´t mind adding an AARCH64 prefix, but I find it
unlikely we will run into a naming collision given BSD uses equivalent
constants. Again, not disputing the matter of what is technically
correct or not.
>
> The native files aarch64-linux-nat.c and linux-aarch64-low.cc can use
> HWCAP_PACA though, because they see the definition from the system
> headers (or worst case, a definition from nat/, to support compiling
> against older kernels).
> > Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-22 10:06 ` Luis
@ 2026-02-22 14:22 ` Simon Marchi
2026-02-22 15:15 ` Luis
0 siblings, 1 reply; 15+ messages in thread
From: Simon Marchi @ 2026-02-22 14:22 UTC (permalink / raw)
To: Luis, Thiago Jung Bauermann, gdb-patches; +Cc: Chris Packham, Tom Tromey
On 2026-02-22 05:06, Luis wrote:
> I don´t recall the discussions touching renaming/moving of these
> constants. But I see your point. I just don´t think we should block
> this series from going in on that particular snag. We should try a
> refactoring as a follow on.
>
This is what I was referring to, from Thiago:
Ok. While fixing this, I noticed that gdb/arch/aarch64-gcs-linux.h also
contains:
/* Feature check for Guarded Control Stack. */
#ifndef HWCAP_GCS
#define HWCAP_GCS (1ULL << 32)
#endif
which can be said to be an implicit dependency on an arch-specific
include file (since it relies on such file defining or not HWCAP_GCS).
Also, on non-AArch64 systems it relies on them not having by coincidence
an unrelated hardware capability bit also named HWCAP_GCS...
I fixed this in v2 by renaming the macro to AARCH64_HWCAP_GCS and
defining it unconditionally (following the existing example of
AARCH64_HWCAP_PACA).
From: https://inbox.sourceware.org/gdb-patches/87qzqkx8l1.fsf@linaro.org/T/#mbe0d3d5a2802f4f88abe907874ed44c063666639
I think that was a good idea, and it seems like we went backwards from
there?
> On the naming, I don´t mind adding an AARCH64 prefix, but I find it
> unlikely we will run into a naming collision given BSD uses equivalent
> constants. Again, not disputing the matter of what is technically
> correct or not.
This is already a refactoring / cleanup series, it's not harder to do it
right from the start.
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-22 14:22 ` Simon Marchi
@ 2026-02-22 15:15 ` Luis
2026-02-22 15:25 ` Simon Marchi
0 siblings, 1 reply; 15+ messages in thread
From: Luis @ 2026-02-22 15:15 UTC (permalink / raw)
To: Simon Marchi
Cc: Thiago Jung Bauermann, gdb-patches, Chris Packham, Tom Tromey
[-- Attachment #1: Type: text/plain, Size: 1840 bytes --]
That's ok by me. Would you like to clarify what Thiago needs to do so we
don't send mixed signals then?
Thanks
On Sun, Feb 22, 2026, 14:22 Simon Marchi <simark@simark.ca> wrote:
>
>
> On 2026-02-22 05:06, Luis wrote:
> > I don´t recall the discussions touching renaming/moving of these
> > constants. But I see your point. I just don´t think we should block
> > this series from going in on that particular snag. We should try a
> > refactoring as a follow on.
> >
>
> This is what I was referring to, from Thiago:
>
> Ok. While fixing this, I noticed that gdb/arch/aarch64-gcs-linux.h also
> contains:
>
> /* Feature check for Guarded Control Stack. */
> #ifndef HWCAP_GCS
> #define HWCAP_GCS (1ULL << 32)
> #endif
>
> which can be said to be an implicit dependency on an arch-specific
> include file (since it relies on such file defining or not HWCAP_GCS).
>
> Also, on non-AArch64 systems it relies on them not having by
> coincidence
> an unrelated hardware capability bit also named HWCAP_GCS...
>
> I fixed this in v2 by renaming the macro to AARCH64_HWCAP_GCS and
> defining it unconditionally (following the existing example of
> AARCH64_HWCAP_PACA).
>
> From:
> https://inbox.sourceware.org/gdb-patches/87qzqkx8l1.fsf@linaro.org/T/#mbe0d3d5a2802f4f88abe907874ed44c063666639
>
> I think that was a good idea, and it seems like we went backwards from
> there?
>
> > On the naming, I don´t mind adding an AARCH64 prefix, but I find it
> > unlikely we will run into a naming collision given BSD uses equivalent
> > constants. Again, not disputing the matter of what is technically
> > correct or not.
>
> This is already a refactoring / cleanup series, it's not harder to do it
> right from the start.
>
> Simon
>
[-- Attachment #2: Type: text/html, Size: 2496 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-22 15:15 ` Luis
@ 2026-02-22 15:25 ` Simon Marchi
2026-03-03 5:00 ` Thiago Jung Bauermann
0 siblings, 1 reply; 15+ messages in thread
From: Simon Marchi @ 2026-02-22 15:25 UTC (permalink / raw)
To: Luis; +Cc: Thiago Jung Bauermann, gdb-patches, Chris Packham, Tom Tromey
On 2026-02-22 10:15, Luis wrote:
> That's ok by me. Would you like to clarify what Thiago needs to do so we don't send mixed signals then?
I think we can summarize it like this:
- Definitions in arch/ should be namespaced / prefixed with AARCH64_
(e.g. AARCH64_HWCAP_FOO)
- Definitions in nat/, which are there to allow building natively
against an older, should use the original name (e.g HWCAP_FOO)
- -tdep files should use the AARCH64_-prefixed versions (e.g.
AARCH64_HWCAP_FOO)
- -nat (in gdb) and -low (in gdbserver) should use the original name
(e.g. HWCAP_FOO)
Simon
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
2026-02-22 15:25 ` Simon Marchi
@ 2026-03-03 5:00 ` Thiago Jung Bauermann
0 siblings, 0 replies; 15+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:00 UTC (permalink / raw)
To: Simon Marchi; +Cc: Luis, gdb-patches, Chris Packham, Tom Tromey
Simon Marchi <simark@simark.ca> writes:
> On 2026-02-22 10:15, Luis wrote:
>> That's ok by me. Would you like to clarify what Thiago needs to do so we don't send mixed signals then?
>
> I think we can summarize it like this:
>
> - Definitions in arch/ should be namespaced / prefixed with AARCH64_
> (e.g. AARCH64_HWCAP_FOO)
> - Definitions in nat/, which are there to allow building natively
> against an older, should use the original name (e.g HWCAP_FOO)
> - -tdep files should use the AARCH64_-prefixed versions (e.g.
> AARCH64_HWCAP_FOO)
> - -nat (in gdb) and -low (in gdbserver) should use the original name
> (e.g. HWCAP_FOO)
Thank you for the clarification. I've done all of the above in v4.
Regarding the first point, I found some definitions in arch/ besides the
HWCAP ones which should have the AARCH64_ prefix, so I did that too:
- SEGV_MTEAERR → AARCH64_SEGV_MTEAERR
- SEGV_MTESERR → AARCH64_SEGV_MTESERR
- SEGV_CPERR → AARCH64_SEGV_CPERR
- PR_SHADOW_STACK_ENABLE → AARCH64_PR_SHADOW_STACK_ENABLE
- PR_SHADOW_STACK_WRITE → AARCH64_PR_SHADOW_STACK_WRITE
- PR_SHADOW_STACK_PUSH → AARCH64_PR_SHADOW_STACK_PUSH
Actually, the last four of them weren't even in a gdb/arch/ header, but
in gdb/linux-tdep.h. I moved them into gdb/arch/.
From your other email in this thread:
> On 2026-02-22 05:06, Luis wrote:
>> I don´t recall the discussions touching renaming/moving of these
>> constants. But I see your point. I just don´t think we should block
>> this series from going in on that particular snag. We should try a
>> refactoring as a follow on.
>>
>
> This is what I was referring to, from Thiago:
>
> Ok. While fixing this, I noticed that gdb/arch/aarch64-gcs-linux.h also
> contains:
>
> /* Feature check for Guarded Control Stack. */
> #ifndef HWCAP_GCS
> #define HWCAP_GCS (1ULL << 32)
> #endif
>
> which can be said to be an implicit dependency on an arch-specific
> include file (since it relies on such file defining or not HWCAP_GCS).
>
> Also, on non-AArch64 systems it relies on them not having by coincidence
> an unrelated hardware capability bit also named HWCAP_GCS...
>
> I fixed this in v2 by renaming the macro to AARCH64_HWCAP_GCS and
> defining it unconditionally (following the existing example of
> AARCH64_HWCAP_PACA).
>
> From: https://inbox.sourceware.org/gdb-patches/87qzqkx8l1.fsf@linaro.org/T/#mbe0d3d5a2802f4f88abe907874ed44c063666639
>
> I think that was a good idea, and it seems like we went backwards from
> there?
I misunderstood this comment you made when you reviewed v2¹:
>> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
>> index 028de981588b..b2dd192a7b56 100644
>> --- a/gdb/aarch64-linux-nat.c
>> +++ b/gdb/aarch64-linux-nat.c
>> @@ -51,7 +51,7 @@
>> #include "gdb_proc_service.h"
>> #include "arch-utils.h"
>>
>> -#include "arch/aarch64-gcs-linux.h"
>> +#include "arch/aarch64-linux.h"
>> #include "arch/aarch64-mte-linux.h"
>>
>> #include "nat/aarch64-mte-linux-ptrace.h"
>> @@ -1013,7 +1013,7 @@ aarch64_linux_nat_target::read_description ()
>> active or not. */
>> features.vq = aarch64_sve_get_vq (tid);
>> features.pauth = hwcap & AARCH64_HWCAP_PACA;
>> - features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
>
> This one could stay HWCAP_GCS, but I don't have a preference.
>
> If we want to ensure / prove they are the same, we could add asserts
> like this in the nat/ header:
>
> static_assert (AARCH64_HWCAP_GCS == HWCAP_GCS);
>
> That assert would only be checked when compiling natively for an aarch64
> system (where HWCAP_GCS is available), but it's better than nothing.
to mean that you didn't have a preference on whether to use
AARCH64_-prefixed definitions. I didn't notice that the comment was made
in a hunk from a -nat.c file. Sorry for the confusion.
--
Thiago
¹ https://inbox.sourceware.org/gdb-patches/5cebfbfa-a192-4359-97d9-83455d40fdc6@simark.ca/
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h
2026-02-17 6:00 [PATCH v3 0/4] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
2026-02-17 6:00 ` [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h Thiago Jung Bauermann
@ 2026-02-17 6:01 ` Thiago Jung Bauermann
2026-02-21 12:15 ` Luis
2026-02-17 6:01 ` [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs Thiago Jung Bauermann
2026-02-17 6:01 ` [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
3 siblings, 1 reply; 15+ messages in thread
From: Thiago Jung Bauermann @ 2026-02-17 6:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi
GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
not the best place for it since it's a Linux-specific definition.
Add a new Linux- and feature-specific header to contain it.
Suggested-by: Luis <luis.machado.foss@gmail.com>
---
gdb/Makefile.in | 1 +
gdb/aarch64-linux-nat.c | 1 +
gdb/aarch64-linux-tdep.c | 1 +
gdb/arch/aarch64-fpmr-linux.h | 28 ++++++++++++++++++++++++++++
gdb/arch/aarch64.h | 5 -----
gdbserver/linux-aarch64-low.cc | 1 +
6 files changed, 32 insertions(+), 5 deletions(-)
create mode 100644 gdb/arch/aarch64-fpmr-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 8f8a95beccc3..f0f10e3946bf 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1301,6 +1301,7 @@ HFILES_NO_SRCDIR = \
amdgpu-tdep.h \
annotate.h \
arch/aarch32.h \
+ arch/aarch64-fpmr-linux.h \
arch/aarch64-gcs-linux.h \
arch/aarch64.h \
arch/aarch64-insn.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index d310d3e814b2..9f85d96b59ef 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -51,6 +51,7 @@
#include "gdb_proc_service.h"
#include "arch-utils.h"
+#include "arch/aarch64-fpmr-linux.h"
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-pauth-linux.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index b5af281d8a40..c17ccbc66220 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -51,6 +51,7 @@
#include "record-full.h"
#include "linux-record.h"
+#include "arch/aarch64-fpmr-linux.h"
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
diff --git a/gdb/arch/aarch64-fpmr-linux.h b/gdb/arch/aarch64-fpmr-linux.h
new file mode 100644
index 000000000000..d3040fa263e4
--- /dev/null
+++ b/gdb/arch/aarch64-fpmr-linux.h
@@ -0,0 +1,28 @@
+/* Common Linux target-dependent definitions for AArch64 FPMR.
+
+ Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_ARCH_AARCH64_FPMR_LINUX_H
+#define GDB_ARCH_AARCH64_FPMR_LINUX_H
+
+/* Feature check for Floating Point Mode Register. */
+#ifndef HWCAP2_FPMR
+#define HWCAP2_FPMR (1ULL << 48)
+#endif /* HWCAP2_FPMR */
+
+#endif /* GDB_ARCH_AARCH64_FPMR_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 7856d95a93b1..c9a89ac40986 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -243,9 +243,4 @@ enum aarch64_regnum
/* Size of the SME2 ZT0 register in bytes. */
#define AARCH64_SME2_ZT0_SIZE 64
-/* Feature check for Floating Point Mode Register. */
-#ifndef HWCAP2_FPMR
-#define HWCAP2_FPMR (1ULL << 48)
-#endif /* HWCAP2_FPMR */
-
#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 69aaabc1a8f9..6b61f6d5a815 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -39,6 +39,7 @@
#include "gdb_proc_service.h"
#include "arch/aarch64.h"
+#include "arch/aarch64-fpmr-linux.h"
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-scalable-linux.h"
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h
2026-02-17 6:01 ` [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h Thiago Jung Bauermann
@ 2026-02-21 12:15 ` Luis
0 siblings, 0 replies; 15+ messages in thread
From: Luis @ 2026-02-21 12:15 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Tom Tromey, Simon Marchi
On 17/02/2026 06:01, Thiago Jung Bauermann wrote:
> GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
> not the best place for it since it's a Linux-specific definition.
>
> Add a new Linux- and feature-specific header to contain it.
>
> Suggested-by: Luis <luis.machado.foss@gmail.com>
> ---
> gdb/Makefile.in | 1 +
> gdb/aarch64-linux-nat.c | 1 +
> gdb/aarch64-linux-tdep.c | 1 +
> gdb/arch/aarch64-fpmr-linux.h | 28 ++++++++++++++++++++++++++++
> gdb/arch/aarch64.h | 5 -----
> gdbserver/linux-aarch64-low.cc | 1 +
> 6 files changed, 32 insertions(+), 5 deletions(-)
> create mode 100644 gdb/arch/aarch64-fpmr-linux.h
>
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index 8f8a95beccc3..f0f10e3946bf 100644
> --- a/gdb/Makefile.in
> +++ b/gdb/Makefile.in
> @@ -1301,6 +1301,7 @@ HFILES_NO_SRCDIR = \
> amdgpu-tdep.h \
> annotate.h \
> arch/aarch32.h \
> + arch/aarch64-fpmr-linux.h \
> arch/aarch64-gcs-linux.h \
> arch/aarch64.h \
> arch/aarch64-insn.h \
> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index d310d3e814b2..9f85d96b59ef 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -51,6 +51,7 @@
> #include "gdb_proc_service.h"
> #include "arch-utils.h"
>
> +#include "arch/aarch64-fpmr-linux.h"
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte-linux.h"
> #include "arch/aarch64-pauth-linux.h"
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index b5af281d8a40..c17ccbc66220 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -51,6 +51,7 @@
> #include "record-full.h"
> #include "linux-record.h"
>
> +#include "arch/aarch64-fpmr-linux.h"
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte.h"
> #include "arch/aarch64-mte-linux.h"
> diff --git a/gdb/arch/aarch64-fpmr-linux.h b/gdb/arch/aarch64-fpmr-linux.h
> new file mode 100644
> index 000000000000..d3040fa263e4
> --- /dev/null
> +++ b/gdb/arch/aarch64-fpmr-linux.h
> @@ -0,0 +1,28 @@
> +/* Common Linux target-dependent definitions for AArch64 FPMR.
> +
> + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_ARCH_AARCH64_FPMR_LINUX_H
> +#define GDB_ARCH_AARCH64_FPMR_LINUX_H
> +
> +/* Feature check for Floating Point Mode Register. */
> +#ifndef HWCAP2_FPMR
> +#define HWCAP2_FPMR (1ULL << 48)
> +#endif /* HWCAP2_FPMR */
> +
> +#endif /* GDB_ARCH_AARCH64_FPMR_LINUX_H */
> diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
> index 7856d95a93b1..c9a89ac40986 100644
> --- a/gdb/arch/aarch64.h
> +++ b/gdb/arch/aarch64.h
> @@ -243,9 +243,4 @@ enum aarch64_regnum
> /* Size of the SME2 ZT0 register in bytes. */
> #define AARCH64_SME2_ZT0_SIZE 64
>
> -/* Feature check for Floating Point Mode Register. */
> -#ifndef HWCAP2_FPMR
> -#define HWCAP2_FPMR (1ULL << 48)
> -#endif /* HWCAP2_FPMR */
> -
> #endif /* GDB_ARCH_AARCH64_H */
> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
> index 69aaabc1a8f9..6b61f6d5a815 100644
> --- a/gdbserver/linux-aarch64-low.cc
> +++ b/gdbserver/linux-aarch64-low.cc
> @@ -39,6 +39,7 @@
>
> #include "gdb_proc_service.h"
> #include "arch/aarch64.h"
> +#include "arch/aarch64-fpmr-linux.h"
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte-linux.h"
> #include "arch/aarch64-scalable-linux.h"
Also OK. Thanks.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs
2026-02-17 6:00 [PATCH v3 0/4] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
2026-02-17 6:00 ` [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h Thiago Jung Bauermann
2026-02-17 6:01 ` [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h Thiago Jung Bauermann
@ 2026-02-17 6:01 ` Thiago Jung Bauermann
2026-02-21 12:20 ` Luis
2026-02-17 6:01 ` [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
3 siblings, 1 reply; 15+ messages in thread
From: Thiago Jung Bauermann @ 2026-02-17 6:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi
Only native code should use struct user_gcs, so its definition should be
in a native-specific file and not in a file under gdb/arch/.
To fix this problem, create gdb/nat/aarch64-gcs-linux-ptrace.h and move
the struct user_gcs definition to it, as suggested by Luis.
To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
and use it in aarch64-linux-tdep.c, as is done for other regsets and
following a suggestion from Simon Marchi.
Suggested-by: Luis <luis.machado.foss@gmail.com>
Suggested-by: Simon Marchi <simark@simark.ca>
---
Changes since v2:
- Don't rename gdb/arch/aarch64-gcs-linux.h to gdb/arch/aarch64-linux.h,
as suggested by Luis.
- Create gdb/nat/aarch64-gcs-linux-ptrace.h to contain definition of
struct user_gcs, as suggested by Luis.
- Don't rename HWCAP_GCS to AARCH64_HWCAP_GCS, as suggested by Luis.
- Move definition of AARCH64_LINUX_SIZEOF_GCS_REGSET from
gdb/aarch64-linux-tdep.h to gdb/arch/aarch64-gcs-linux.h, as suggested
by Luis.
- Move changes to HWCAP_PACA to separate patch.
gdb/Makefile.in | 1 +
gdb/aarch64-linux-nat.c | 1 +
gdb/aarch64-linux-tdep.c | 5 ++--
gdb/arch/aarch64-gcs-linux.h | 17 ++-----------
gdb/nat/aarch64-gcs-linux-ptrace.h | 40 ++++++++++++++++++++++++++++++
gdbserver/linux-aarch64-low.cc | 1 +
6 files changed, 48 insertions(+), 17 deletions(-)
create mode 100644 gdb/nat/aarch64-gcs-linux-ptrace.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index f0f10e3946bf..0ac45bd9d326 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1550,6 +1550,7 @@ HFILES_NO_SRCDIR = \
nat/aarch64-hw-point.h \
nat/aarch64-linux.h \
nat/aarch64-linux-hw-point.h \
+ nat/aarch64-gcs-linux-ptrace.h \
nat/aarch64-mte-linux-ptrace.h \
nat/aarch64-scalable-linux-ptrace.h \
nat/aarch64-scalable-linux-sigcontext.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 9f85d96b59ef..a49b82ca43c8 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -34,6 +34,7 @@
#include "arch/arm.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
+#include "nat/aarch64-gcs-linux-ptrace.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "elf/external.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index c17ccbc66220..f0935cbd67e8 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1736,8 +1736,9 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
gcs_regmap, regcache_supply_regset, regcache_collect_regset
};
- cb (".reg-aarch-gcs", sizeof (user_gcs), sizeof (user_gcs),
- &aarch64_linux_gcs_regset, "GCS registers", cb_data);
+ cb (".reg-aarch-gcs", AARCH64_LINUX_SIZEOF_GCS_REGSET,
+ AARCH64_LINUX_SIZEOF_GCS_REGSET, &aarch64_linux_gcs_regset,
+ "GCS registers", cb_data);
}
}
diff --git a/gdb/arch/aarch64-gcs-linux.h b/gdb/arch/aarch64-gcs-linux.h
index b31fc32daa03..015a49b25976 100644
--- a/gdb/arch/aarch64-gcs-linux.h
+++ b/gdb/arch/aarch64-gcs-linux.h
@@ -20,25 +20,12 @@
#ifndef GDB_ARCH_AARCH64_GCS_LINUX_H
#define GDB_ARCH_AARCH64_GCS_LINUX_H
-#include <stdint.h>
-
/* Feature check for Guarded Control Stack. */
#ifndef HWCAP_GCS
#define HWCAP_GCS (1ULL << 32)
#endif
-/* Make sure we only define these if the kernel header doesn't. */
-#ifndef GCS_MAGIC
-
-/* GCS state (NT_ARM_GCS). */
-
-struct user_gcs
-{
- uint64_t features_enabled;
- uint64_t features_locked;
- uint64_t gcspr_el0;
-};
-
-#endif /* GCS_MAGIC */
+/* The GCS regset consists of 3 64-bit registers. */
+#define AARCH64_LINUX_SIZEOF_GCS_REGSET (3 * 8)
#endif /* GDB_ARCH_AARCH64_GCS_LINUX_H */
diff --git a/gdb/nat/aarch64-gcs-linux-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h
new file mode 100644
index 000000000000..f45a1059cd0a
--- /dev/null
+++ b/gdb/nat/aarch64-gcs-linux-ptrace.h
@@ -0,0 +1,40 @@
+/* Common native Linux definitions for AArch64 Guarded Control Stack.
+
+ Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H
+#define GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H
+
+#include <stdint.h>
+#include <asm/ptrace.h>
+
+/* Make sure we only define these if the kernel header doesn't. */
+#ifndef GCS_MAGIC
+
+/* GCS state (NT_ARM_GCS). */
+
+struct user_gcs
+{
+ uint64_t features_enabled;
+ uint64_t features_locked;
+ uint64_t gcspr_el0;
+};
+
+#endif /* GCS_MAGIC */
+
+#endif /* GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 6b61f6d5a815..55e55b2df0ab 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -45,6 +45,7 @@
#include "arch/aarch64-scalable-linux.h"
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
+#include "nat/aarch64-gcs-linux-ptrace.h"
#include "nat/aarch64-mte-linux-ptrace.h"
#include "arch/aarch64-pauth-linux.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs
2026-02-17 6:01 ` [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs Thiago Jung Bauermann
@ 2026-02-21 12:20 ` Luis
0 siblings, 0 replies; 15+ messages in thread
From: Luis @ 2026-02-21 12:20 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Tom Tromey, Simon Marchi
On 17/02/2026 06:01, Thiago Jung Bauermann wrote:
> Only native code should use struct user_gcs, so its definition should be
> in a native-specific file and not in a file under gdb/arch/.
>
> To fix this problem, create gdb/nat/aarch64-gcs-linux-ptrace.h and move
> the struct user_gcs definition to it, as suggested by Luis.
>
> To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
> macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
> and use it in aarch64-linux-tdep.c, as is done for other regsets and
> following a suggestion from Simon Marchi.
>
> Suggested-by: Luis <luis.machado.foss@gmail.com>
> Suggested-by: Simon Marchi <simark@simark.ca>
> ---
> Changes since v2:
> - Don't rename gdb/arch/aarch64-gcs-linux.h to gdb/arch/aarch64-linux.h,
> as suggested by Luis.
> - Create gdb/nat/aarch64-gcs-linux-ptrace.h to contain definition of
> struct user_gcs, as suggested by Luis.
> - Don't rename HWCAP_GCS to AARCH64_HWCAP_GCS, as suggested by Luis.
> - Move definition of AARCH64_LINUX_SIZEOF_GCS_REGSET from
> gdb/aarch64-linux-tdep.h to gdb/arch/aarch64-gcs-linux.h, as suggested
> by Luis.
> - Move changes to HWCAP_PACA to separate patch.
>
> gdb/Makefile.in | 1 +
> gdb/aarch64-linux-nat.c | 1 +
> gdb/aarch64-linux-tdep.c | 5 ++--
> gdb/arch/aarch64-gcs-linux.h | 17 ++-----------
> gdb/nat/aarch64-gcs-linux-ptrace.h | 40 ++++++++++++++++++++++++++++++
> gdbserver/linux-aarch64-low.cc | 1 +
> 6 files changed, 48 insertions(+), 17 deletions(-)
> create mode 100644 gdb/nat/aarch64-gcs-linux-ptrace.h
>
> diff --git a/gdb/Makefile.in b/gdb/Makefile.in
> index f0f10e3946bf..0ac45bd9d326 100644
> --- a/gdb/Makefile.in
> +++ b/gdb/Makefile.in
> @@ -1550,6 +1550,7 @@ HFILES_NO_SRCDIR = \
> nat/aarch64-hw-point.h \
> nat/aarch64-linux.h \
> nat/aarch64-linux-hw-point.h \
> + nat/aarch64-gcs-linux-ptrace.h \
> nat/aarch64-mte-linux-ptrace.h \
> nat/aarch64-scalable-linux-ptrace.h \
> nat/aarch64-scalable-linux-sigcontext.h \
> diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
> index 9f85d96b59ef..a49b82ca43c8 100644
> --- a/gdb/aarch64-linux-nat.c
> +++ b/gdb/aarch64-linux-nat.c
> @@ -34,6 +34,7 @@
> #include "arch/arm.h"
> #include "nat/aarch64-linux.h"
> #include "nat/aarch64-linux-hw-point.h"
> +#include "nat/aarch64-gcs-linux-ptrace.h"
> #include "nat/aarch64-scalable-linux-ptrace.h"
>
> #include "elf/external.h"
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index c17ccbc66220..f0935cbd67e8 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -1736,8 +1736,9 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
> gcs_regmap, regcache_supply_regset, regcache_collect_regset
> };
>
> - cb (".reg-aarch-gcs", sizeof (user_gcs), sizeof (user_gcs),
> - &aarch64_linux_gcs_regset, "GCS registers", cb_data);
> + cb (".reg-aarch-gcs", AARCH64_LINUX_SIZEOF_GCS_REGSET,
> + AARCH64_LINUX_SIZEOF_GCS_REGSET, &aarch64_linux_gcs_regset,
> + "GCS registers", cb_data);
> }
> }
>
> diff --git a/gdb/arch/aarch64-gcs-linux.h b/gdb/arch/aarch64-gcs-linux.h
> index b31fc32daa03..015a49b25976 100644
> --- a/gdb/arch/aarch64-gcs-linux.h
> +++ b/gdb/arch/aarch64-gcs-linux.h
> @@ -20,25 +20,12 @@
> #ifndef GDB_ARCH_AARCH64_GCS_LINUX_H
> #define GDB_ARCH_AARCH64_GCS_LINUX_H
>
> -#include <stdint.h>
> -
> /* Feature check for Guarded Control Stack. */
> #ifndef HWCAP_GCS
> #define HWCAP_GCS (1ULL << 32)
> #endif
>
> -/* Make sure we only define these if the kernel header doesn't. */
> -#ifndef GCS_MAGIC
> -
> -/* GCS state (NT_ARM_GCS). */
> -
> -struct user_gcs
> -{
> - uint64_t features_enabled;
> - uint64_t features_locked;
> - uint64_t gcspr_el0;
> -};
> -
> -#endif /* GCS_MAGIC */
> +/* The GCS regset consists of 3 64-bit registers. */
> +#define AARCH64_LINUX_SIZEOF_GCS_REGSET (3 * 8)
>
> #endif /* GDB_ARCH_AARCH64_GCS_LINUX_H */
> diff --git a/gdb/nat/aarch64-gcs-linux-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h
> new file mode 100644
> index 000000000000..f45a1059cd0a
> --- /dev/null
> +++ b/gdb/nat/aarch64-gcs-linux-ptrace.h
> @@ -0,0 +1,40 @@
> +/* Common native Linux definitions for AArch64 Guarded Control Stack.
> +
> + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H
> +#define GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H
> +
> +#include <stdint.h>
> +#include <asm/ptrace.h>
> +
> +/* Make sure we only define these if the kernel header doesn't. */
> +#ifndef GCS_MAGIC
> +
> +/* GCS state (NT_ARM_GCS). */
> +
> +struct user_gcs
> +{
> + uint64_t features_enabled;
> + uint64_t features_locked;
> + uint64_t gcspr_el0;
> +};
> +
> +#endif /* GCS_MAGIC */
> +
> +#endif /* GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H */
> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
> index 6b61f6d5a815..55e55b2df0ab 100644
> --- a/gdbserver/linux-aarch64-low.cc
> +++ b/gdbserver/linux-aarch64-low.cc
> @@ -45,6 +45,7 @@
> #include "arch/aarch64-scalable-linux.h"
> #include "linux-aarch32-tdesc.h"
> #include "linux-aarch64-tdesc.h"
> +#include "nat/aarch64-gcs-linux-ptrace.h"
> #include "nat/aarch64-mte-linux-ptrace.h"
> #include "arch/aarch64-pauth-linux.h"
> #include "nat/aarch64-scalable-linux-ptrace.h"
Thanks. Also OK.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems
2026-02-17 6:00 [PATCH v3 0/4] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
` (2 preceding siblings ...)
2026-02-17 6:01 ` [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs Thiago Jung Bauermann
@ 2026-02-17 6:01 ` Thiago Jung Bauermann
2026-02-21 12:23 ` Luis
3 siblings, 1 reply; 15+ messages in thread
From: Thiago Jung Bauermann @ 2026-02-17 6:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi
When building against musl (e.g. on Alpine Linux), the following error
happens:
CXX linux-aarch64-low.o
In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:48:
/home/bauermann/src/binutils-gdb/gdbserver/../gdb/nat/aarch64-gcs-linux-ptrace.h:31:8: error: redefinition of 'struct user_gcs'
31 | struct user_gcs
| ^~~~~~~~
In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:35:
/usr/include/asm/ptrace.h:329:8: note: previous definition of 'struct user_gcs'
329 | struct user_gcs {
| ^~~~~~~~
make[2]: *** [Makefile:565: linux-aarch64-low.o] Error 1
aarch64-linux-tdep.c fails to build in the same way. This happens
because aarch64-linux.h uses GCS_MAGIC to see whether the system
headers have GCS-related definitions. The problem is that GCS_MAGIC is
defined in <asm/sigcontext.h> while struct gcs_user is defined in
<asm/ptrace.h>. It's fine on glibc systems because in the set of system
headers that linux-aarch64-low.cc and aarch64-linux-tdep.c include,
<asm/sigcontext.h> ends up being included implicitly as well. This
doesn't happen when using musl's headers though.
There isn't a macro in <asm/ptrace.h> whose presence is correlated with
the presence of the struct user_gcs definition, so a configure check is
needed to detect it and conditionally define the struct.
Note that there's another build issue with musl, described in
PR gdb/33747 affecting compilation of gdb/ser-unix.c. In order to be
able to test this patch, I applied the patch in comment 11 there.
Tested with a native build on an Alpine Linux aarch64 system, and also
verified that all gdb.arch/aarch64-gcs*.exp tests pass on it.
Co-authored-by: Chris Packham <judge.packham@gmail.com>
---
Changes since v2:
- It's the same patch except that the header changed is
gdb/nat/aarch64-gcs-linux-ptrace.h rather than gdb/nat/aarch64-linux.h,
which doesn't exist in this version of the patch series.
gdb/nat/aarch64-gcs-linux-ptrace.h | 5 ++---
gdbsupport/config.in | 3 +++
gdbsupport/configure | 36 ++++++++++++++++++++++++++++++
gdbsupport/configure.ac | 19 ++++++++++++++++
4 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/gdb/nat/aarch64-gcs-linux-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h
index f45a1059cd0a..f3dda08a1d27 100644
--- a/gdb/nat/aarch64-gcs-linux-ptrace.h
+++ b/gdb/nat/aarch64-gcs-linux-ptrace.h
@@ -23,8 +23,7 @@
#include <stdint.h>
#include <asm/ptrace.h>
-/* Make sure we only define these if the kernel header doesn't. */
-#ifndef GCS_MAGIC
+#ifndef HAVE_STRUCT_USER_GCS
/* GCS state (NT_ARM_GCS). */
@@ -35,6 +34,6 @@ struct user_gcs
uint64_t gcspr_el0;
};
-#endif /* GCS_MAGIC */
+#endif /* HAVE_STRUCT_USER_GCS */
#endif /* GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H */
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index 0beacf22c057..2957ee0f0301 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -271,6 +271,9 @@
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
+/* Define to 1 if your system has struct user_gcs. */
+#undef HAVE_STRUCT_USER_GCS
+
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 05ad00f48c4f..584a80ef8255 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -14307,6 +14307,42 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Check for `struct user_gcs`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct user_gcs" >&5
+$as_echo_n "checking for struct user_gcs... " >&6; }
+if ${gdb_cv_struct_user_gcs+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/ptrace.h>
+ #include <asm/ptrace.h>
+int
+main ()
+{
+struct user_gcs u;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ gdb_cv_struct_user_gcs=yes
+else
+ gdb_cv_struct_user_gcs=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_user_gcs" >&5
+$as_echo "$gdb_cv_struct_user_gcs" >&6; }
+if test "$gdb_cv_struct_user_gcs" = yes; then
+
+$as_echo "#define HAVE_STRUCT_USER_GCS 1" >>confdefs.h
+
+fi
+
# Set the 'development' global.
. $srcdir/../bfd/development.sh
diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac
index 5491b8f3f10a..6c06832f0913 100644
--- a/gdbsupport/configure.ac
+++ b/gdbsupport/configure.ac
@@ -68,6 +68,25 @@ GDB_AC_PTRACE
AM_GDB_COMPILER_TYPE
AM_GDB_WARNINGS
+# Check for `struct user_gcs`
+AC_CACHE_CHECK(
+ [for struct user_gcs],
+ [gdb_cv_struct_user_gcs],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <sys/ptrace.h>
+ #include <asm/ptrace.h>],
+ [struct user_gcs u;]
+ )],
+ [gdb_cv_struct_user_gcs=yes],
+ [gdb_cv_struct_user_gcs=no]
+ )]
+)
+if test "$gdb_cv_struct_user_gcs" = yes; then
+ AC_DEFINE(HAVE_STRUCT_USER_GCS, 1,
+ [Define to 1 if your system has struct user_gcs.])
+fi
+
# Set the 'development' global.
. $srcdir/../bfd/development.sh
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems
2026-02-17 6:01 ` [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
@ 2026-02-21 12:23 ` Luis
0 siblings, 0 replies; 15+ messages in thread
From: Luis @ 2026-02-21 12:23 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Tom Tromey, Simon Marchi
On 17/02/2026 06:01, Thiago Jung Bauermann wrote:
> When building against musl (e.g. on Alpine Linux), the following error
> happens:
>
> CXX linux-aarch64-low.o
> In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:48:
> /home/bauermann/src/binutils-gdb/gdbserver/../gdb/nat/aarch64-gcs-linux-ptrace.h:31:8: error: redefinition of 'struct user_gcs'
> 31 | struct user_gcs
> | ^~~~~~~~
> In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:35:
> /usr/include/asm/ptrace.h:329:8: note: previous definition of 'struct user_gcs'
> 329 | struct user_gcs {
> | ^~~~~~~~
> make[2]: *** [Makefile:565: linux-aarch64-low.o] Error 1
>
> aarch64-linux-tdep.c fails to build in the same way. This happens
> because aarch64-linux.h uses GCS_MAGIC to see whether the system
> headers have GCS-related definitions. The problem is that GCS_MAGIC is
> defined in <asm/sigcontext.h> while struct gcs_user is defined in
> <asm/ptrace.h>. It's fine on glibc systems because in the set of system
> headers that linux-aarch64-low.cc and aarch64-linux-tdep.c include,
> <asm/sigcontext.h> ends up being included implicitly as well. This
> doesn't happen when using musl's headers though.
>
> There isn't a macro in <asm/ptrace.h> whose presence is correlated with
> the presence of the struct user_gcs definition, so a configure check is
> needed to detect it and conditionally define the struct.
>
> Note that there's another build issue with musl, described in
> PR gdb/33747 affecting compilation of gdb/ser-unix.c. In order to be
> able to test this patch, I applied the patch in comment 11 there.
>
> Tested with a native build on an Alpine Linux aarch64 system, and also
> verified that all gdb.arch/aarch64-gcs*.exp tests pass on it.
>
> Co-authored-by: Chris Packham <judge.packham@gmail.com>
> ---
> Changes since v2:
> - It's the same patch except that the header changed is
> gdb/nat/aarch64-gcs-linux-ptrace.h rather than gdb/nat/aarch64-linux.h,
> which doesn't exist in this version of the patch series.
>
> gdb/nat/aarch64-gcs-linux-ptrace.h | 5 ++---
> gdbsupport/config.in | 3 +++
> gdbsupport/configure | 36 ++++++++++++++++++++++++++++++
> gdbsupport/configure.ac | 19 ++++++++++++++++
> 4 files changed, 60 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/nat/aarch64-gcs-linux-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h
> index f45a1059cd0a..f3dda08a1d27 100644
> --- a/gdb/nat/aarch64-gcs-linux-ptrace.h
> +++ b/gdb/nat/aarch64-gcs-linux-ptrace.h
> @@ -23,8 +23,7 @@
> #include <stdint.h>
> #include <asm/ptrace.h>
>
> -/* Make sure we only define these if the kernel header doesn't. */
> -#ifndef GCS_MAGIC
> +#ifndef HAVE_STRUCT_USER_GCS
>
> /* GCS state (NT_ARM_GCS). */
>
> @@ -35,6 +34,6 @@ struct user_gcs
> uint64_t gcspr_el0;
> };
>
> -#endif /* GCS_MAGIC */
> +#endif /* HAVE_STRUCT_USER_GCS */
>
> #endif /* GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H */
> diff --git a/gdbsupport/config.in b/gdbsupport/config.in
> index 0beacf22c057..2957ee0f0301 100644
> --- a/gdbsupport/config.in
> +++ b/gdbsupport/config.in
> @@ -271,6 +271,9 @@
> /* Define to 1 if `st_blocks' is a member of `struct stat'. */
> #undef HAVE_STRUCT_STAT_ST_BLOCKS
>
> +/* Define to 1 if your system has struct user_gcs. */
> +#undef HAVE_STRUCT_USER_GCS
> +
> /* Define to 1 if you have the <sys/param.h> header file. */
> #undef HAVE_SYS_PARAM_H
>
> diff --git a/gdbsupport/configure b/gdbsupport/configure
> index 05ad00f48c4f..584a80ef8255 100755
> --- a/gdbsupport/configure
> +++ b/gdbsupport/configure
> @@ -14307,6 +14307,42 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
>
>
>
> +# Check for `struct user_gcs`
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct user_gcs" >&5
> +$as_echo_n "checking for struct user_gcs... " >&6; }
> +if ${gdb_cv_struct_user_gcs+:} false; then :
> + $as_echo_n "(cached) " >&6
> +else
> + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h. */
> +#include <sys/ptrace.h>
> + #include <asm/ptrace.h>
> +int
> +main ()
> +{
> +struct user_gcs u;
> +
> + ;
> + return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_compile "$LINENO"; then :
> + gdb_cv_struct_user_gcs=yes
> +else
> + gdb_cv_struct_user_gcs=no
> +
> +fi
> +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_user_gcs" >&5
> +$as_echo "$gdb_cv_struct_user_gcs" >&6; }
> +if test "$gdb_cv_struct_user_gcs" = yes; then
> +
> +$as_echo "#define HAVE_STRUCT_USER_GCS 1" >>confdefs.h
> +
> +fi
> +
> # Set the 'development' global.
> . $srcdir/../bfd/development.sh
>
> diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac
> index 5491b8f3f10a..6c06832f0913 100644
> --- a/gdbsupport/configure.ac
> +++ b/gdbsupport/configure.ac
> @@ -68,6 +68,25 @@ GDB_AC_PTRACE
> AM_GDB_COMPILER_TYPE
> AM_GDB_WARNINGS
>
> +# Check for `struct user_gcs`
> +AC_CACHE_CHECK(
> + [for struct user_gcs],
> + [gdb_cv_struct_user_gcs],
> + [AC_COMPILE_IFELSE(
> + [AC_LANG_PROGRAM(
> + [#include <sys/ptrace.h>
> + #include <asm/ptrace.h>],
> + [struct user_gcs u;]
> + )],
> + [gdb_cv_struct_user_gcs=yes],
> + [gdb_cv_struct_user_gcs=no]
> + )]
> +)
> +if test "$gdb_cv_struct_user_gcs" = yes; then
> + AC_DEFINE(HAVE_STRUCT_USER_GCS, 1,
> + [Define to 1 if your system has struct user_gcs.])
> +fi
> +
> # Set the 'development' global.
> . $srcdir/../bfd/development.sh
>
Thanks. Still looks OK to me. I'd like a second approval from Tom or Simon.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread