aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-06-16 22:08:12 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-06-16 22:08:12 +0000
commit8fd79e71a13726d33285c696f019be5010a332d5 (patch)
tree71515fce7292d32e646f4835509c3f29c6ee66e4 /bfd
parent9d3b06987a9f8e6c40bf90f502f57d1c2b6b10ed (diff)
downloadgdb-8fd79e71a13726d33285c696f019be5010a332d5.zip
gdb-8fd79e71a13726d33285c696f019be5010a332d5.tar.gz
gdb-8fd79e71a13726d33285c696f019be5010a332d5.tar.bz2
Suport x32 gcore.
2011-06-16 H.J. Lu <hongjiu.lu@intel.com> * elf64-x86-64.c: Include <stdarg.h> and CORE_HEADER if CORE_HEADER is defined. (elf_x86_64_write_core_note): New. (elf_backend_write_core_note): Likewise. * hosts/x86-64linux.h (uint64_t): New. (user_regsx32_struct): Likewise. (elf_gregx32_t): Likewise. (ELF_NGREGX32): Likewise. (elf_gregsetx32_t): Likewise. (elf_prstatusx32): Likewise. (prstatusx32_t): Likewise. (user_fpregs32_struct): Removed. (user_fpxregs32_struct): Likewise. (user32): Likewise. (elf_fpregset32_t): Likewise. (elf_fpxregset32_t): Likewise. (prgregset32_t): Likewise. (prfpregset32_t): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog22
-rw-r--r--bfd/elf64-x86-64.c101
-rw-r--r--bfd/hosts/x86-64linux.h110
3 files changed, 174 insertions, 59 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 41b22cc..1ce1ac2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,27 @@
2011-06-16 H.J. Lu <hongjiu.lu@intel.com>
+ * elf64-x86-64.c: Include <stdarg.h> and CORE_HEADER if
+ CORE_HEADER is defined.
+ (elf_x86_64_write_core_note): New.
+ (elf_backend_write_core_note): Likewise.
+
+ * hosts/x86-64linux.h (uint64_t): New.
+ (user_regsx32_struct): Likewise.
+ (elf_gregx32_t): Likewise.
+ (ELF_NGREGX32): Likewise.
+ (elf_gregsetx32_t): Likewise.
+ (elf_prstatusx32): Likewise.
+ (prstatusx32_t): Likewise.
+ (user_fpregs32_struct): Removed.
+ (user_fpxregs32_struct): Likewise.
+ (user32): Likewise.
+ (elf_fpregset32_t): Likewise.
+ (elf_fpxregset32_t): Likewise.
+ (prgregset32_t): Likewise.
+ (prfpregset32_t): Likewise.
+
+2011-06-16 H.J. Lu <hongjiu.lu@intel.com>
+
* elf64-x86-64.c (elf_x86_64_grok_prstatus): Support x32.
(elf_x86_64_grok_psinfo): Likewise.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index de65197..23b5559 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -32,6 +32,11 @@
#include "elf/x86-64.h"
+#ifdef CORE_HEADER
+#include <stdarg.h>
+#include CORE_HEADER
+#endif
+
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
#define MINUS_ONE (~ (bfd_vma) 0)
@@ -385,6 +390,99 @@ elf_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}
+
+#ifdef CORE_HEADER
+static char *
+elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
+ int note_type, ...)
+{
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ const void *p;
+ int size;
+ va_list ap;
+ const char *fname, *psargs;
+ long pid;
+ int cursig;
+ const void *gregs;
+
+ switch (note_type)
+ {
+ default:
+ return NULL;
+
+ case NT_PRPSINFO:
+ va_start (ap, note_type);
+ fname = va_arg (ap, const char *);
+ psargs = va_arg (ap, const char *);
+ va_end (ap);
+
+ if (bed->s->elfclass == ELFCLASS32)
+ {
+ prpsinfo32_t data;
+ memset (&data, 0, sizeof (data));
+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
+ p = (const void *) &data;
+ size = sizeof (data);
+ }
+ else
+ {
+ prpsinfo_t data;
+ memset (&data, 0, sizeof (data));
+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
+ p = (const void *) &data;
+ size = sizeof (data);
+ }
+ break;
+
+ case NT_PRSTATUS:
+ va_start (ap, note_type);
+ pid = va_arg (ap, long);
+ cursig = va_arg (ap, int);
+ gregs = va_arg (ap, const void *);
+ va_end (ap);
+
+ if (bed->s->elfclass == ELFCLASS32)
+ {
+ if (bed->elf_machine_code == EM_X86_64)
+ {
+ prstatusx32_t prstat;
+ memset (&prstat, 0, sizeof (prstat));
+ prstat.pr_pid = pid;
+ prstat.pr_cursig = cursig;
+ memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
+ p = (const void *) &prstat;
+ size = sizeof (prstat);
+ }
+ else
+ {
+ prstatus32_t prstat;
+ memset (&prstat, 0, sizeof (prstat));
+ prstat.pr_pid = pid;
+ prstat.pr_cursig = cursig;
+ memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
+ p = (const void *) &prstat;
+ size = sizeof (prstat);
+ }
+ }
+ else
+ {
+ prstatus_t prstat;
+ memset (&prstat, 0, sizeof (prstat));
+ prstat.pr_pid = pid;
+ prstat.pr_cursig = cursig;
+ memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
+ p = (const void *) &prstat;
+ size = sizeof (prstat);
+ }
+ break;
+ }
+
+ return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, p,
+ size);
+}
+#endif
/* Functions for the x86-64 ELF linker. */
@@ -4711,6 +4809,9 @@ static const struct bfd_elf_special_section
#define elf_backend_gc_sweep_hook elf_x86_64_gc_sweep_hook
#define elf_backend_grok_prstatus elf_x86_64_grok_prstatus
#define elf_backend_grok_psinfo elf_x86_64_grok_psinfo
+#ifdef CORE_HEADER
+#define elf_backend_write_core_note elf_x86_64_write_core_note
+#endif
#define elf_backend_reloc_type_class elf_x86_64_reloc_type_class
#define elf_backend_relocate_section elf_x86_64_relocate_section
#define elf_backend_size_dynamic_sections elf_x86_64_size_dynamic_sections
diff --git a/bfd/hosts/x86-64linux.h b/bfd/hosts/x86-64linux.h
index 093af61..4ffc3f2 100644
--- a/bfd/hosts/x86-64linux.h
+++ b/bfd/hosts/x86-64linux.h
@@ -37,6 +37,7 @@
#include <stdint.h>
#else
typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
#endif
#undef HAVE_PRPSINFO32_T
@@ -49,35 +50,6 @@ typedef unsigned int uint32_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;
@@ -99,27 +71,40 @@ struct user_regs32_struct
int32_t xss;
};
-struct user32
+struct user_regsx32_struct
{
- 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];
+ uint64_t r15;
+ uint64_t r14;
+ uint64_t r13;
+ uint64_t r12;
+ uint64_t rbp;
+ uint64_t rbx;
+ uint64_t r11;
+ uint64_t r10;
+ uint64_t r9;
+ uint64_t r8;
+ uint64_t rax;
+ uint64_t rcx;
+ uint64_t rdx;
+ uint64_t rsi;
+ uint64_t rdi;
+ uint64_t orig_rax;
+ uint64_t rip;
+ uint64_t cs;
+ uint64_t eflags;
+ uint64_t rsp;
+ uint64_t ss;
+ uint64_t fs_base;
+ uint64_t gs_base;
+ uint64_t ds;
+ uint64_t es;
+ uint64_t fs;
+ uint64_t gs;
};
/* Type for a general-purpose register. */
-typedef unsigned int elf_greg32_t;
+typedef uint32_t elf_greg32_t;
+typedef uint64_t elf_gregx32_t;
/* And the whole bunch of them. We could have used `struct
user_regs_struct' directly in the typedef, but tradition says that
@@ -127,15 +112,8 @@ typedef unsigned int elf_greg32_t;
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;
-
+#define ELF_NGREGX32 (sizeof (struct user_regsx32_struct) / sizeof(elf_gregx32_t))
+typedef elf_gregx32_t elf_gregsetx32_t[ELF_NGREGX32];
/* Definitions to generate Intel SVR4-like core files. These mostly
have the same names as the SVR4 types with "elf_" tacked on the
@@ -168,6 +146,23 @@ struct elf_prstatus32
int pr_fpvalid; /* True if math copro being used. */
};
+struct elf_prstatusx32
+ {
+ 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_gregsetx32_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
struct elf_prpsinfo32
{
@@ -189,10 +184,7 @@ struct elf_prpsinfo32
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_prstatusx32 prstatusx32_t;
typedef struct elf_prpsinfo32 prpsinfo32_t;