On MIPS platforms, PID information was not correctly propagated from
core dump file to internal GDB structures. This patch fixes that behavior.
The bug was found while trying to read TLS variable from core dump file
on MIPS platforms, but it was not able because GDB needs correct PID
information in order to do that.
This change is tested on MIPS64R2 board with o32, n32 and n64
executables. Test program is forced to crash in order to generate core
file. Core file is loaded into GDB and bfd structure is checked if it
has correct PID value, the same value executable had before crash.
Currently I don't have copyright assignment. Couple a weeks ago my
company initiated process of getting copyright assignment but with no
response so far.
From 06d1e46e23297bcbbd6e75dcce6c0c4cfbca7864 Mon Sep 17 00:00:00 2001
From: Djordje Todorovic <djordje.todorovic@rt-rk.com>
Date: Fri, 16 Jun 2017 14:02:28 +0200
Subject: [PATCH] BFD: Extract PID from MIPS core dump file
On MIPS platforms, PID information was not correctly propagated
from core dump file to internal GDB structures.
This patch fixes that behavior.
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(+)
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 84f2a3f..e45e362 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 dce7ba1..af4e8c3 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3558,6 +3558,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