This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH / RFA] Add core file support functions to elf32-frv.c


The patch below adds core file support for an FR-V processor running
either GNU/Linux or uClinux.  (The core file format is the same for both.)
Okay to apply?

	* elf32-frv.c (elf32_frv_grok_prstatus, elf32_frv_grok_psinfo):
	New functions.
	* elf_backend_grok_prstatus, elf_backend_grok_psinfo): Define.

Index: elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.43
diff -u -p -r1.43 elf32-frv.c
--- elf32-frv.c	15 Aug 2005 15:39:08 -0000	1.43
+++ elf32-frv.c	14 Feb 2006 20:33:02 -0000
@@ -78,6 +78,10 @@ static bfd_boolean frv_elf_merge_private
   PARAMS ((bfd *, bfd *));
 static bfd_boolean frv_elf_print_private_bfd_data
   PARAMS ((bfd *, PTR));
+static bfd_boolean elf32_frv_grok_prstatus
+  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
+static bfd_boolean elf32_frv_grok_psinfo
+  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
 
 static reloc_howto_type elf32_frv_howto_table [] =
 {
@@ -6823,6 +6827,73 @@ frv_elf_print_private_bfd_data (abfd, pt
 }
 
 
+/* Support for core dump NOTE sections.  */
+
+static bfd_boolean
+elf32_frv_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+  int offset;
+  unsigned int raw_size;
+
+  switch (note->descsz)
+    {
+      default:
+	return FALSE;
+
+      case 268:	
+	/* pr_cursig */
+	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+
+	/* pr_pid */
+	elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+	/* pr_reg: Note that raw_size is set to be the size of pr_reg plus
+	   the size of `pr_exec_fdpic_loadmap' and `pr_interp_fdpic_loadmap',
+	   both of which immediately follow `pr_reg'.  This will allow these
+	   fields to be viewed by GDB as registers.  */
+	offset = 72;
+	raw_size = 184 + 4 + 4;  /* This is...
+	                            sizeof (pr_reg)
+	                              + sizeof (pr_exec_fdpic_loadmap)
+				      + sizeof (pr_interp_fdpic_loadmap) */
+
+	break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size,
+					  note->descpos + offset);
+}
+
+static bfd_boolean
+elf32_frv_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+  switch (note->descsz)
+    {
+      default:
+	return FALSE;
+
+      case 124:		/* Linux/FRV elf_prpsinfo */
+	elf_tdata (abfd)->core_program
+	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+	elf_tdata (abfd)->core_command
+	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+    }
+
+  /* Note that for some reason, a spurious space is tacked
+     onto the end of the args in some (at least one anyway)
+     implementations, so strip it off if it exists.  */
+
+  {
+    char *command = elf_tdata (abfd)->core_command;
+    int n = strlen (command);
+
+    if (0 < n && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return TRUE;
+}
 #define ELF_ARCH		bfd_arch_frv
 #define ELF_MACHINE_CODE	EM_CYGNUS_FRV
 #define ELF_MAXPAGESIZE		0x1000
@@ -6857,6 +6928,9 @@ frv_elf_print_private_bfd_data (abfd, pt
 #define elf_backend_finish_dynamic_sections \
 		elf32_frv_finish_dynamic_sections
 
+#define elf_backend_grok_prstatus	elf32_frv_grok_prstatus
+#define elf_backend_grok_psinfo		elf32_frv_grok_psinfo
+
 #include "elf32-target.h"
 
 #undef ELF_MAXPAGESIZE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]