Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/s390-linux-nat.c: use gdb_fpregset_t to fix build with musl
@ 2026-11-10 18:03 Florian Fuchs
  2026-11-11 14:52 ` Ulrich Weigand
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fuchs @ 2026-11-10 18:03 UTC (permalink / raw)
  To: gdb-patches, Andreas Arnez; +Cc: Ulrich Weigand, Florian Fuchs

gdb/gregset.h declares supply_fpregset and fill_fpregset with
gdb_fpregset_t, which nm-linux.h defines as elf_fpregset_t. The s390
native target defines them with fpregset_t instead. On glibc the two
are the same type, so this goes unnoticed. On musl they are distinct
types, so the definitions in s390-linux-nat.c become separate
overloads, and the calls in proc-service.c find no definition:

ld: proc-service.o: in function `ps_lgetfpregs':
proc-service.c:(.text+0x3f0): undefined reference to
   `fill_fpregset(regcache const*, elf_fpregset_t*, int)'
ld: proc-service.o: in function `ps_lsetfpregs':
proc-service.c:(.text+0x426): undefined reference to
   `supply_fpregset(regcache*, elf_fpregset_t const*)'

Use gdb_fpregset_t in the definitions and the local buffers, like other
Linux native targets do, so they match the declarations in gregset.h.

Tested by cross-building and running GDB for s390x with musl and glibc.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34986
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
 gdb/s390-linux-nat.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index cffaadf3c28..f3e93a81c3b 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -239,20 +239,21 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno)
 /* Fill GDB's register array with the floating-point register values
    in *REGP.  */
 void
-supply_fpregset (struct regcache *regcache, const fpregset_t *regp)
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *regp)
 {
   regcache_supply_regset (&s390_fpregset, regcache, -1, regp,
-			  sizeof (fpregset_t));
+			  sizeof (gdb_fpregset_t));
 }
 
 /* Fill register REGNO (if it is a general-purpose register) in
    *REGP with the value in GDB's register array.  If REGNO is -1,
    do this for all registers.  */
 void
-fill_fpregset (const struct regcache *regcache, fpregset_t *regp, int regno)
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *regp,
+	       int regno)
 {
   regcache_collect_regset (&s390_fpregset, regcache, regno, regp,
-			   sizeof (fpregset_t));
+			   sizeof (gdb_fpregset_t));
 }
 
 /* Find the TID for the current inferior thread to use with ptrace.  */
@@ -309,7 +310,7 @@ store_regs (const struct regcache *regcache, int tid, int regnum)
 static void
 fetch_fpregs (struct regcache *regcache, int tid)
 {
-  fpregset_t fpregs;
+  gdb_fpregset_t fpregs;
   ptrace_area parea;
 
   parea.len = sizeof (fpregs);
@@ -318,7 +319,7 @@ fetch_fpregs (struct regcache *regcache, int tid)
   if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea, 0) < 0)
     perror_with_name (_("Couldn't get floating point status"));
 
-  supply_fpregset (regcache, (const fpregset_t *) &fpregs);
+  supply_fpregset (regcache, &fpregs);
 }
 
 /* Store all valid floating-point registers in GDB's register cache
@@ -326,7 +327,7 @@ fetch_fpregs (struct regcache *regcache, int tid)
 static void
 store_fpregs (const struct regcache *regcache, int tid, int regnum)
 {
-  fpregset_t fpregs;
+  gdb_fpregset_t fpregs;
   ptrace_area parea;
 
   parea.len = sizeof (fpregs);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb/s390-linux-nat.c: use gdb_fpregset_t to fix build with musl
  2026-11-10 18:03 [PATCH] gdb/s390-linux-nat.c: use gdb_fpregset_t to fix build with musl Florian Fuchs
@ 2026-11-11 14:52 ` Ulrich Weigand
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Weigand @ 2026-11-11 14:52 UTC (permalink / raw)
  To: Florian Fuchs, gdb-patches, Andreas Arnez; +Cc: Ulrich Weigand

Florian Fuchs <fuchsfl@gmail.com> wrote:

>gdb/gregset.h declares supply_fpregset and fill_fpregset with
>gdb_fpregset_t, which nm-linux.h defines as elf_fpregset_t. The s390
>native target defines them with fpregset_t instead. On glibc the two
>are the same type, so this goes unnoticed. On musl they are distinct
>types, so the definitions in s390-linux-nat.c become separate
>overloads, and the calls in proc-service.c find no definition:
>
>ld: proc-service.o: in function `ps_lgetfpregs':
>proc-service.c:(.text+0x3f0): undefined reference to
>   `fill_fpregset(regcache const*, elf_fpregset_t*, int)'
>ld: proc-service.o: in function `ps_lsetfpregs':
>proc-service.c:(.text+0x426): undefined reference to
>   `supply_fpregset(regcache*, elf_fpregset_t const*)'
>
>Use gdb_fpregset_t in the definitions and the local buffers, like
other
>Linux native targets do, so they match the declarations in gregset.h.

You're right that this is correct thing to do, and your patch looks
good to me.

However, I think we should do the same for supply_gregset and
fill_gregset - they should use gdb_gregset_t instead of
gregset_t.  It seems that these types are currently considered
identical even in their musl definitions, but still it would be
more consistent to make that change as well while we're at it.

Bye,
Ulrich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-11 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 18:03 [PATCH] gdb/s390-linux-nat.c: use gdb_fpregset_t to fix build with musl Florian Fuchs
2026-11-11 14:52 ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox