[PATCH] Add FreeBSD/i386 core file note support

Mark Kettenis kettenis@chello.nl
Sat May 11 07:25:00 GMT 2002


This patch adds support for FreeBSD/i386 core file notes.  The FreeBSD
notes are distinguished based on the name of the note, which has been
FreeBSD ever since support for ELF core dumps was first added to
FreeBSD.

OK to check this in?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* elf32-i386.c (elf_i386_grok_prstatus): Add support for FreeBSD.
	(elf_i386_grok_psinfo): Likewise.

Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf32-i386.c
--- elf32-i386.c 4 Apr 2002 19:53:36 -0000 1.67
+++ elf32-i386.c 11 May 2002 14:16:44 -0000
@@ -328,23 +328,44 @@ elf_i386_grok_prstatus (abfd, note)
   int offset;
   size_t raw_size;
 
-  switch (note->descsz)
+  if (strncmp (note->namedata, "FreeBSD", note->namesz) == 0)
     {
-      default:
+      int pr_version = bfd_get_32 (abfd, note->descdata);
+
+      if (pr_version != 1)
 	return false;
 
-      case 144:		/* Linux/i386 */
-	/* 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 */
-	offset = 72;
-	raw_size = 68;
+      /* pr_cursig */
+      elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20);
+
+      /* pr_pid */
+      elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+      /* pr_reg */
+      offset = 28;
+      raw_size = bfd_get_32 (abfd, note->descdata + 8);
+    }
+  else
+    {
+      switch (note->descsz)
+	{
+	default:
+	  return false;
+
+	case 144:		/* Linux/i386 */
+	  /* 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 */
+	  offset = 72;
+	  raw_size = 68;
 
-	break;
+	  break;
+	}
     }
 
   /* Make a ".reg/999" section.  */
@@ -357,16 +378,31 @@ elf_i386_grok_psinfo (abfd, note)
      bfd *abfd;
      Elf_Internal_Note *note;
 {
-  switch (note->descsz)
+  if (strncmp (note->namedata, "FreeBSD", note->namesz) == 0)
     {
-      default:
+      int pr_version = bfd_get_32 (abfd, note->descdata);
+
+      if (pr_version != 1)
 	return false;
 
-      case 124:		/* Linux/i386 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);
+      elf_tdata (abfd)->core_program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 8, 17);
+      elf_tdata (abfd)->core_command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 25, 81);
+    }
+  else
+    {
+      switch (note->descsz)
+	{
+	default:
+	  return false;
+
+	case 124:		/* Linux/i386 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



More information about the Binutils mailing list