[2/3] BFD: Extract PID from MIPS core dump file

Message ID 1508248194-26950-2-git-send-email-djordje.todorovic@rt-rk.com
State Superseded
Headers

Commit Message

Djordje Todorovic Oct. 17, 2017, 1:49 p.m. UTC
  On MIPS o32, n32 and n64 platforms, PID information was not
correctly propagated from core dump file to internal GDB
structures.  This patch fixes that behavior.

GDB needs correct PID in order to fetch value of TLS variable
from core file.

bfd/ChangeLog:

     * elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
     * elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
     * elfn32-mips.c (elf32_mips_grok_psinfo): Likewise.
---
 bfd/elf32-mips.c  | 2 ++
 bfd/elf64-mips.c  | 2 ++
 bfd/elfn32-mips.c | 2 ++
 3 files changed, 6 insertions(+)
  

Comments

Maciej W. Rozycki Oct. 18, 2017, 1:34 p.m. UTC | #1
On Tue, 17 Oct 2017, Djordje Todorovic wrote:

> On MIPS o32, n32 and n64 platforms, PID information was not
> correctly propagated from core dump file to internal GDB
> structures.  This patch fixes that behavior.
> 
> GDB needs correct PID in order to fetch value of TLS variable
> from core file.

 This is OK.  Thanks.

  Maciej
  

Patch

diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 2ee15e9..86c5e43 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 + 16);
 	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 f3997bd..0227a0f 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4228,6 +4228,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
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index d9d2020..cb7e26c 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3560,6 +3560,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 + 16);
 	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
 	elf_tdata (abfd)->core->command