[PATCH] bfd: loongarch: modify NT_PRSTATUS note to 480 bytes for kernel uapi.And gdb need more protect for coredump.
lijian1@kylinos.cn
lijian1@kylinos.cn
Wed Oct 22 06:22:30 GMT 2025
From: lijian1 <lijian1@kylinos.cn>
Signed-off-by: lijian1 <lijian1@kylinos.cn>
-For loongarch64 from the kernel uapi, the sizeof (struct elf_prstatus) on Linux/LoongArch is 0x1e0(480bytes, include the padding),from kernel 6.6-6.18,keep this value.But the old value for PRSTATUS_SIZE(0x1d8) is 472bytes, this will lead to no .reg section generated.And if there is no reg sections generated, the thread list will not generate normally.So keep the value with kernel in bfd and add protection for gdb.
---
bfd/elfnn-loongarch.c | 2 +-
gdb/thread.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 53cdb783859..8f06fbbf12f 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -6540,7 +6540,7 @@ loongarch_elf_copy_indirect_symbol (struct bfd_link_info *info,
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
-#define PRSTATUS_SIZE 0x1d8
+#define PRSTATUS_SIZE 0x1e0
#define PRSTATUS_OFFSET_PR_CURSIG 0xc
#define PRSTATUS_OFFSET_PR_PID 0x20
#define ELF_GREGSET_T_SIZE 0x168
diff --git a/gdb/thread.c b/gdb/thread.c
index 472f41969cf..92908b0f78e 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -298,6 +298,9 @@ add_thread_silent (process_stratum_target *targ, ptid_t ptid)
gdb_assert (targ != nullptr);
inferior *inf = find_inferior_ptid (targ, ptid);
+
+ /*if there is no reg section, the inf will be null*/
+ gdb_assert(inf != nullptr);
threads_debug_printf ("add thread to inferior %d, ptid %s, target %s",
inf->num, ptid.to_string ().c_str (),
--
2.43.0
More information about the Binutils
mailing list