File bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch of Package gdb
From 7f89abca702d04b67e5018ba89b74867a80ab675 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Sat, 22 Nov 2025 16:19:14 +0100
Subject: [PATCH 16/25] bfd/ELF: Handle prstatus of 156 bytes in
elf32_arm_nabi_grok_prstatus
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
For a corefile generated on openSUSE Leap 15.2 armv7l with linux version
5.3.18, we get:
...
$ gdb -q --core core
...
Core was generated by `/usr/bin/rs_scope -d'.
⚠️ warning: Couldn't find general-purpose registers in core file.
(gdb)
...
The warning is emitted because the pseudo-section .reg is missing, because
elf32_arm_nabi_grok_prstatus expects the PRSTATUS note to have size 148, but
instead we have:
...
$ eu-readelf -n core | grep -i prstatus
CORE 156 PRSTATUS
CORE 156 PRSTATUS
CORE 156 PRSTATUS
CORE 156 PRSTATUS
...
This is a bug for CONFIG_BINFMT_ELF_FDPIC=y configurations, fixed
by v5.9 linux kernel commit 16aead81018c ("take fdpic-related parts of
elf_prstatus out").
The bug causes the FDPIC-specific unsigned long fields pr_exec_fdpic_loadmap
and pr_interp_fdpic_loadmap to be added to struct elf_prstatus in case the
FDPIC ABI is not used.
Work around this bug in elf32_arm_nabi_grok_prstatus, by ignoring the extra
fields, which gets us instead:
...
Core was generated by `/usr/bin/rs_scope -d'.
Program terminated with signal SIGSEGV, Segmentation fault.
[Current thread is 1 (LWP 30047)]
(gdb)
...
Tested gdb, gas, binutils and ld on x86_64-linux and arm-linux with
--enable-targets=all.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33560
---
bfd/elf32-arm.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 77510687150..838ad43abda 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2151,6 +2151,16 @@ elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
default:
return false;
+ case 156: /* Linux/ARM 32-bit, some pre-v5.9 linux kernels. */
+ /* There's a linux kernel bug for CONFIG_BINFMT_ELF_FDPIC=y
+ configurations, fixed by v5.9 linux kernel commit 16aead81018c
+ ("take fdpic-related parts of elf_prstatus out").
+ The bug causes the FDPIC-specific unsigned long fields
+ pr_exec_fdpic_loadmap and pr_interp_fdpic_loadmap to be added to
+ struct elf_prstatus in case the FDPIC ABI is not used.
+ The two fields are added after pr_reg, so just ignore them. */
+
+ /* Fall through. */
case 148: /* Linux/ARM 32-bit. */
/* pr_cursig */
elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
--
2.51.0