[PATCH, MIPS] Extract PID from core dump file
Djordje Todorovic
djordje.todorovic@rt-rk.com
Mon Jun 5 09:14:00 GMT 2017
There is already a thread for this but it is not correct ([PATCH, MIPS]
Extract PID from core file by Michael Eager). As author in this thread
says it was only tested on MIPS32 (N32) . This patch is tested on MIPS32
and MIPS64 executables and both points for setting pid in
bfd/elf32-mips.c and bfd/elf64-mips.c is hit respectively. It is also
checked in Linux kernel and the size of pid is the same as size of int.
It can be found in the source of Linux kernel:
include/uapi/asm-generic/posix_types.h
...
#ifndef __kernel_pid_t
typedef int __kernel_pid_t;
#endif
...
From 79272bae0b10fa35b640d4006045f389e9a85849 Mon Sep 17 00:00:00 2001
From: Djordje Todorovic <djordje.todorovic@rt-rk.com>
Date: Fri, 2 Jun 2017 13:16:00 +0200
Subject: [PATCH] Extract PID from MIPS core dump file
bfd/ChangeLog:
* elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
* elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
---
bfd/ChangeLog | 5 +++++
bfd/elf32-mips.c | 2 ++
bfd/elf64-mips.c | 2 ++
3 files changed, 9 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 27a1e8c..392b131 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-02 Djordje Todorovic <djordje.todorovic@rt-rk.com>
+
+ * elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
+ * elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
+
2017-06-01 John Baldwin <jhb@FreeBSD.org>
* elf.c (elfcore_grok_freebsd_psinfo): Use ELF header class to
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 8c1a68eb..9ec2818 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2353,6 +2353,8 @@ elf32_mips_grok_psinfo (bfd *abfd,
Elf_Internal_Note *note)
return FALSE;
case 128: /* Linux/MIPS elf_prpsinfo */
+ elf_tdata (abfd)->core->pid
+ = bfd_get_32 (abfd, note->descdata + 24);
elf_tdata (abfd)->core->program
= _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
elf_tdata (abfd)->core->command
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index e95db2c..6c7fc6d 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4242,6 +4242,8 @@ elf64_mips_grok_psinfo (bfd *abfd,
Elf_Internal_Note *note)
return FALSE;
case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */
+ elf_tdata (abfd)->core->pid
+ = bfd_get_32 (abfd, note->descdata + 24);
elf_tdata (abfd)->core->program
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
elf_tdata (abfd)->core->command
--
1.9.1
More information about the Binutils
mailing list