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, s390] Support NT_S390_HIGH_GPRS core file notes


Hello,

System z hardware allows use of the full 64-bit general purpose
register set (and corresponding instructions) even to 32-bit
applications running under a 64-bit kernel.  Recent Linux kernels
have added support for this mode of operation.  In particular,
this affects the core file format: when such an application
crashes, we need not just the usual 32-bit register set, but
the full 64-bit register contents in order to enable debugging.

To preserve compatibility, the kernel does not change the format
of the NT_PRSTATUS notes it generates; these continue to hold
the 32-bit register set, i.e. the lower halves of the actual
64-bit general registers.  In addition, the kernel now generates
a new note section holding the *upper* halves of those registers.

This patch adds binutils support for this note section.

Tested on s390x-linux; also tested as part of a GDB tree in
conjunction with an (upcoming) GDB patch to add support for
debugging such applications.

OK for mainline?

Bye,
Ulrich


ChangeLog:

include/elf/
	* common.h (NT_S390_HIGH_GPRS): Define.

bfd/
	* elf.c (elfcore_grok_s390_high_gprs): New function.
	(elfcore_grok_note): Handle NT_S390_HIGH_GPRS notes.
	(elfcore_write_s390_high_gprs): New function.
	(elfcore_write_register_note): Call it.

binutils/
	* readelf.c (get_note_type): Handle NT_S390_HIGH_GPRS notes.


Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.495
diff -u -p -r1.495 elf.c
--- bfd/elf.c	11 Dec 2009 13:42:02 -0000	1.495
+++ bfd/elf.c	18 Dec 2009 15:23:49 -0000
@@ -7638,6 +7638,12 @@ elfcore_grok_ppc_vsx (bfd *abfd, Elf_Int
   return elfcore_make_note_pseudosection (abfd, ".reg-ppc-vsx", note);
 }
 
+static bfd_boolean
+elfcore_grok_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-s390-high-gprs", note);
+}
+
 #if defined (HAVE_PRPSINFO_T)
 typedef prpsinfo_t   elfcore_psinfo_t;
 #if defined (HAVE_PRPSINFO32_T)		/* Sparc64 cross Sparc32 */
@@ -7999,6 +8005,13 @@ elfcore_grok_note (bfd *abfd, Elf_Intern
       else
         return TRUE;
 
+    case NT_S390_HIGH_GPRS:
+      if (note->namesz == 6
+          && strcmp (note->namedata, "LINUX") == 0)
+        return elfcore_grok_s390_high_gprs (abfd, note);
+      else
+        return TRUE;
+
     case NT_PRPSINFO:
     case NT_PSINFO:
       if (bed->elf_backend_grok_psinfo)
@@ -8641,6 +8654,19 @@ elfcore_write_ppc_vsx (bfd *abfd,
                              note_name, NT_PPC_VSX, ppc_vsx, size);
 }
 
+static char *
+elfcore_write_s390_high_gprs (bfd *abfd,
+			      char *buf,
+			      int *bufsiz,
+			      const void *s390_high_gprs,
+			      int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+                             note_name, NT_S390_HIGH_GPRS,
+			     s390_high_gprs, size);
+}
+
 char *
 elfcore_write_register_note (bfd *abfd,
 			     char *buf,
@@ -8657,6 +8683,8 @@ elfcore_write_register_note (bfd *abfd,
     return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-ppc-vsx") == 0)
     return elfcore_write_ppc_vsx (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-s390-high-gprs") == 0)
+    return elfcore_write_s390_high_gprs (abfd, buf, bufsiz, data, size);
   return NULL;
 }
 
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.475
diff -u -p -r1.475 readelf.c
--- binutils/readelf.c	11 Dec 2009 13:42:06 -0000	1.475
+++ binutils/readelf.c	18 Dec 2009 15:23:51 -0000
@@ -10385,6 +10385,8 @@ get_note_type (unsigned e_type)
 	return _("NT_PPC_VMX (ppc Altivec registers)");
       case NT_PPC_VSX:
 	return _("NT_PPC_VSX (ppc VSX registers)");
+      case NT_S390_HIGH_GPRS:
+	return _("NT_S390_HIGH_GPRS (s390 upper register halves)");
       case NT_PSTATUS:
 	return _("NT_PSTATUS (pstatus structure)");
       case NT_FPREGS:
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.117
diff -u -p -r1.117 common.h
--- include/elf/common.h	28 Nov 2009 03:18:00 -0000	1.117
+++ include/elf/common.h	18 Dec 2009 15:23:53 -0000
@@ -510,6 +510,8 @@
 					/*   note name must be "LINUX".  */
 #define NT_PPC_VSX	0x102		/* PowerPC VSX registers */
 					/*   note name must be "LINUX".  */
+#define NT_S390_HIGH_GPRS 0x300		/* S/390 upper halves of GPRs  */
+					/*   note name must be "LINUX".  */
 
 /* Note segments for core files on dir-style procfs systems.  */
 
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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