[3/7] Don't hardcode CONTEXT size for a NOTE_INFO_THREAD win32pstatus note

Message ID 20200701213225.14144-4-jon.turney@dronecode.org.uk
State New
Headers show
Series
  • Add gdb support for Cygwin x86_64 core dumps
Related show

Commit Message

Jon Turney July 1, 2020, 9:32 p.m.
Don't hardcode the size of the Win32 API thread CONTEXT type read from a
NOTE_INFO_THREAD win32pstatus note (since it's different on different
architectures).

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Don't hardcode the size of
	the Win32 API thread CONTEXT type read from a NOTE_INFO_THREAD
	win32pstatus note.
---
 bfd/ChangeLog | 6 ++++++
 bfd/elf.c     | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.27.0

Comments

Shahab Vahedi via Gdb-patches July 6, 2020, 8:12 p.m. | #1
On Wed, Jul 1, 2020 at 4:33 PM Jon Turney <jon.turney@dronecode.org.uk> wrote:
>

> Don't hardcode the size of the Win32 API thread CONTEXT type read from a

> NOTE_INFO_THREAD win32pstatus note (since it's different on different

> architectures).

>

> bfd/ChangeLog:

>

> 2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

>

>         * elf.c (elfcore_grok_win32pstatus): Don't hardcode the size of

>         the Win32 API thread CONTEXT type read from a NOTE_INFO_THREAD

>         win32pstatus note.

> ---

>  bfd/ChangeLog | 6 ++++++

>  bfd/elf.c     | 2 +-

>  2 files changed, 7 insertions(+), 1 deletion(-)

>

> diff --git a/bfd/elf.c b/bfd/elf.c

> index a7790a4eec4..a61e2b7dd1d 100644

> --- a/bfd/elf.c

> +++ b/bfd/elf.c

> @@ -10171,7 +10171,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)

>         return FALSE;

>

>        /* sizeof (thread_info.thread_context) */

> -      sect->size = 716;

> +      sect->size = note->descsz - 12;


I guess the "sizeof" comment is now wrong -- where does the "12" come
from though?

>        /* offsetof (thread_info.thread_context) */

>        sect->filepos = note->descpos + 12;

>        sect->alignment_power = 2;

> --

> 2.27.0

>

Patch

diff --git a/bfd/elf.c b/bfd/elf.c
index a7790a4eec4..a61e2b7dd1d 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10171,7 +10171,7 @@  elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
 	return FALSE;
 
       /* sizeof (thread_info.thread_context) */
-      sect->size = 716;
+      sect->size = note->descsz - 12;
       /* offsetof (thread_info.thread_context) */
       sect->filepos = note->descpos + 12;
       sect->alignment_power = 2;