This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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]

[binutils-gdb] x86: Use correct .reg-xstate section size


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dde9acd693251ccbe28d2d9c6c8b3cdc8ca884ed

commit dde9acd693251ccbe28d2d9c6c8b3cdc8ca884ed
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Wed Jan 14 17:53:23 2015 +0000

    x86: Use correct .reg-xstate section size
    
    When reading the XSAVE extended state from an i386 or AMD64 core file,
    the respective regset iterator requests a minimum section size of
    zero.  Since the respective regset supply function does not check the
    size either, this may lead to accessing data out of range if the
    section is too short.
    
    In write mode, the iterator always uses the maximum supported size for
    the XSAVE extended state.
    
    This is now changed such that the iterator always requests the
    expected size of this section based on xcr0, both for reading and
    writing.
    
    gdb/ChangeLog:
    
    	* amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
    	For ".reg-xstate", explicitly specify the requested section size
    	via X86_XSTATE_SIZE instead of just 0 on input and
    	X86_XSTATE_MAX_SIZE on output.
    	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
    	Likewise.

Diff:
---
 gdb/ChangeLog          | 9 +++++++++
 gdb/amd64-linux-tdep.c | 2 +-
 gdb/i386-linux-tdep.c  | 3 +--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a2cc9a5..822d0d4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2015-02-04  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
+	* amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
+	For ".reg-xstate", explicitly specify the requested section size
+	via X86_XSTATE_SIZE instead of just 0 on input and
+	X86_XSTATE_MAX_SIZE on output.
+	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
+	Likewise.
+
+2015-02-04  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
 	PR corefiles/17808:
 	* gdbarch.sh (iterate_over_regset_sections_cb): Document this
 	function type, particularly its SIZE parameter.
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 42d884e..5db04c0 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1639,7 +1639,7 @@ amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 
   cb (".reg", 27 * 8, &i386_gregset, NULL, cb_data);
   cb (".reg2", 512, &amd64_fpregset, NULL, cb_data);
-  cb (".reg-xstate",  regcache ? X86_XSTATE_MAX_SIZE : 0,
+  cb (".reg-xstate",  X86_XSTATE_SIZE (tdep->xcr0),
       &amd64_linux_xstateregset, "XSAVE extended state", cb_data);
 }
 
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 8a5209a..4a0ce60 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -690,8 +690,7 @@ i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
   cb (".reg", 68, &i386_gregset, NULL, cb_data);
 
   if (tdep->xcr0 & X86_XSTATE_AVX)
-    /* Use max size for writing, accept any size when reading.  */
-    cb (".reg-xstate", regcache ? X86_XSTATE_MAX_SIZE : 0,
+    cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0),
 	&i386_linux_xstateregset, "XSAVE extended state", cb_data);
   else if (tdep->xcr0 & X86_XSTATE_SSE)
     cb (".reg-xfp", 512, &i386_fpregset, "extended floating-point",


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