Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "H.J. Lu" <hongjiu.lu@intel.com>
To: binutils@sourceware.org, jan.kratochvil@redhat.com
Cc: GDB <gdb-patches@sourceware.org>
Subject: PATCH: PR corefiles/11467: amd64 gdb generates corrupted 32bit core  file
Date: Sat, 10 Apr 2010 22:19:00 -0000	[thread overview]
Message-ID: <20100410221943.GA9675@intel.com> (raw)

Hi,

I am checking in this patch to support 32bit core note sections on
Linux/x86-64. I will submit a separate gdb patch.


H.J.
---
2010-04-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR corefiles/11467
	* configure.in (CORE_HEADER): New. Set to hosts/x86-64linux.h
	for x86_64-*-linux*.
	* config.in: Regenerated.
	* configure: Likewise.

	* elf.c: Include CORE_HEADER if it is defined.

2010-04-10  H.J. Lu  <hongjiu.lu@intel.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* hosts/x86-64linux.h: New.
diff --git a/bfd/config.in b/bfd/config.in
index 5881b8d..065c905 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -1,5 +1,8 @@
 /* config.in.  Generated from configure.in by autoheader.  */
 
+/* Name of host specific core header file to include in elf.c. */
+#undef CORE_HEADER
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
diff --git a/bfd/configure b/bfd/configure
index f4aba27..928f984 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -13810,6 +13810,7 @@ fi
 # If we are configured native, pick a core file support file.
 COREFILE=
 COREFLAG=
+CORE_HEADER=
 TRAD_HEADER=
 if test "${target}" = "${host}"; then
   case "${host}" in
@@ -14034,6 +14035,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/vaxbsd.h"'
 	;;
+  x86_64-*-linux*)
+	CORE_HEADER='"hosts/x86-64linux.h"'
+	;;
   x86_64-*-netbsd* | x86_64-*-openbsd*)
 	COREFILE=netbsd-core.lo
 	;;
@@ -14701,6 +14705,13 @@ $as_echo "$bfd_cv_have_sys_procfs_type_win32_pstatus_t" >&6; }
 fi
 
 
+if test -n "$CORE_HEADER"; then
+
+cat >>confdefs.h <<_ACEOF
+#define CORE_HEADER $CORE_HEADER
+_ACEOF
+
+fi
 if test -n "$TRAD_HEADER"; then
 
 cat >>confdefs.h <<_ACEOF
diff --git a/bfd/configure.in b/bfd/configure.in
index dfbd0a2..28d5bdd 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -211,6 +211,7 @@ AM_ZLIB
 # If we are configured native, pick a core file support file.
 COREFILE=
 COREFLAG=
+CORE_HEADER=
 TRAD_HEADER=
 if test "${target}" = "${host}"; then
   case "${host}" in
@@ -443,6 +444,9 @@ changequote([,])dnl
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/vaxbsd.h"'
 	;;
+  x86_64-*-linux*)
+	CORE_HEADER='"hosts/x86-64linux.h"'
+	;;
   x86_64-*-netbsd* | x86_64-*-openbsd*)
 	COREFILE=netbsd-core.lo
 	;;
@@ -487,6 +491,10 @@ changequote([,])dnl
 fi
 AC_SUBST(COREFILE)
 AC_SUBST(COREFLAG)
+if test -n "$CORE_HEADER"; then
+  AC_DEFINE_UNQUOTED(CORE_HEADER, $CORE_HEADER,
+    [Name of host specific core header file to include in elf.c.])
+fi
 if test -n "$TRAD_HEADER"; then
   AC_DEFINE_UNQUOTED(TRAD_HEADER, $TRAD_HEADER,
     [Name of host specific header file to include in trad-core.c.])
diff --git a/bfd/elf.c b/bfd/elf.c
index 8f8bd61..bcd238d 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -45,6 +45,10 @@ SECTION
 #include "libiberty.h"
 #include "safe-ctype.h"
 
+#ifdef CORE_HEADER
+#include CORE_HEADER
+#endif
+
 static int elf_sort_sections (const void *, const void *);
 static bfd_boolean assign_file_positions_except_relocs (bfd *, struct bfd_link_info *);
 static bfd_boolean prep_headers (bfd *);
diff --git a/bfd/hosts/x86-64linux.h b/bfd/hosts/x86-64linux.h
new file mode 100644
index 0000000..fdf17f1
--- /dev/null
+++ b/bfd/hosts/x86-64linux.h
@@ -0,0 +1,192 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This is somewhat modelled after the file of the same name on SVR4
+   systems.  It provides a definition of the core file format for ELF
+   used on Linux.  It doesn't have anything to do with the /proc file
+   system, even though Linux has one.
+
+   Anyway, the whole purpose of this file is for GDB and GDB only.
+   Don't read too much into it.  Don't use it for anything other than
+   GDB unless you know what you are doing.  */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+/* We define here only the symbols differing from their 64-bit variant.  */
+#include <sys/procfs.h>
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+typedef unsigned int uint32_t;
+#endif
+
+#define HAVE_PRPSINFO32_T
+#define HAVE_PRSTATUS32_T
+
+/* These are the 32-bit x86 structures.  */
+
+struct user_fpregs32_struct
+{
+  int32_t cwd;
+  int32_t swd;
+  int32_t twd;
+  int32_t fip;
+  int32_t fcs;
+  int32_t foo;
+  int32_t fos;
+  int32_t st_space [20];
+};
+
+struct user_fpxregs32_struct
+{
+  unsigned short int cwd;
+  unsigned short int swd;
+  unsigned short int twd;
+  unsigned short int fop;
+  int32_t fip;
+  int32_t fcs;
+  int32_t foo;
+  int32_t fos;
+  int32_t mxcsr;
+  int32_t reserved;
+  int32_t st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
+  int32_t xmm_space[32];  /* 8*16 bytes for each XMM-reg = 128 bytes */
+  int32_t padding[56];
+};
+
+struct user_regs32_struct
+{
+  int32_t ebx;
+  int32_t ecx;
+  int32_t edx;
+  int32_t esi;
+  int32_t edi;
+  int32_t ebp;
+  int32_t eax;
+  int32_t xds;
+  int32_t xes;
+  int32_t xfs;
+  int32_t xgs;
+  int32_t orig_eax;
+  int32_t eip;
+  int32_t xcs;
+  int32_t eflags;
+  int32_t esp;
+  int32_t xss;
+};
+
+struct user32
+{
+  struct user_regs32_struct	regs;
+  int				u_fpvalid;
+  struct user_fpregs32_struct	i387;
+  uint32_t			u_tsize;
+  uint32_t			u_dsize;
+  uint32_t			u_ssize;
+  uint32_t			start_code;
+  uint32_t			start_stack;
+  int32_t			signal;
+  int				reserved;
+  struct user_regs32_struct*	u_ar0;
+  struct user_fpregs32_struct*	u_fpstate;
+  uint32_t			magic;
+  char				u_comm [32];
+  int				u_debugreg [8];
+};
+
+/* Type for a general-purpose register.  */
+typedef unsigned int elf_greg32_t;
+
+/* And the whole bunch of them.  We could have used `struct
+   user_regs_struct' directly in the typedef, but tradition says that
+   the register set is an array, which does have some peculiar
+   semantics, so leave it that way.  */
+#define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t))
+typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32];
+
+/* Register set for the floating-point registers.  */
+typedef struct user_fpregs32_struct elf_fpregset32_t;
+
+/* Register set for the extended floating-point registers.  Includes
+   the Pentium III SSE registers in addition to the classic
+   floating-point stuff.  */
+typedef struct user_fpxregs32_struct elf_fpxregset32_t;
+
+
+/* Definitions to generate Intel SVR4-like core files.  These mostly
+   have the same names as the SVR4 types with "elf_" tacked on the
+   front to prevent clashes with Linux definitions, and the typedef
+   forms have been avoided.  This is mostly like the SVR4 structure,
+   but more Linuxy, with things that Linux does not support and which
+   GDB doesn't really use excluded.  */
+
+struct prstatus32_timeval
+  {
+    int tv_sec;
+    int tv_usec;
+  };
+
+struct elf_prstatus32
+  {
+    struct elf_siginfo pr_info;		/* Info associated with signal.  */
+    short int pr_cursig;		/* Current signal.  */
+    unsigned int pr_sigpend;		/* Set of pending signals.  */
+    unsigned int pr_sighold;		/* Set of held signals.  */
+    __pid_t pr_pid;
+    __pid_t pr_ppid;
+    __pid_t pr_pgrp;
+    __pid_t pr_sid;
+    struct prstatus32_timeval pr_utime;		/* User time.  */
+    struct prstatus32_timeval pr_stime;		/* System time.  */
+    struct prstatus32_timeval pr_cutime;	/* Cumulative user time.  */
+    struct prstatus32_timeval pr_cstime;	/* Cumulative system time.  */
+    elf_gregset32_t pr_reg;		/* GP registers.  */
+    int pr_fpvalid;			/* True if math copro being used.  */
+  };
+
+
+struct elf_prpsinfo32
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    unsigned int pr_flag;		/* Flags.  */
+    unsigned short int pr_uid;
+    unsigned short int pr_gid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    /* Lots missing */
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
+  };
+
+
+/* The rest of this file provides the types for emulation of the
+   Solaris <proc_service.h> interfaces that should be implemented by
+   users of libthread_db.  */
+
+/* Register sets.  Linux has different names.  */
+typedef elf_gregset_t prgregset32_t;
+typedef elf_fpregset_t prfpregset32_t;
+
+/* Process status and info.  In the end we do provide typedefs for them.  */
+typedef struct elf_prstatus32 prstatus32_t;
+typedef struct elf_prpsinfo32 prpsinfo32_t;


             reply	other threads:[~2010-04-10 22:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-10 22:19 H.J. Lu [this message]
2010-04-10 22:27 ` H.J. Lu
2010-04-11  0:01   ` H.J. Lu
2010-04-11 20:53     ` H.J. Lu
2010-04-12 13:22       ` H.J. Lu
2010-04-12 18:24         ` Mark Kettenis
2010-04-12 18:50           ` H.J. Lu
2010-04-13 18:40             ` Mark Kettenis
2010-04-13 19:19               ` H.J. Lu
2010-04-13 20:03               ` H.J. Lu
2010-04-13 17:18         ` H.J. Lu
2010-04-13 17:27           ` Mark Kettenis
2010-04-13 17:39             ` H.J. Lu
2010-04-13 18:43               ` Mark Kettenis
2010-04-13 17:48           ` H.J. Lu
2010-04-13 20:38             ` H.J. Lu
2010-04-13 20:48               ` Mark Kettenis
2010-04-11 16:50   ` Mark Kettenis
2010-04-11 17:33     ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100410221943.GA9675@intel.com \
    --to=hongjiu.lu@intel.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox