aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2007-10-17 02:26:55 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:51 -0400
commit5f149cf0ac2ba6c23d77e39fe03290535d13f13d (patch)
tree835f835ce8d2018570fba7eea20c9e1f9590f76c
parentab799dede9b6d744a926dcb657ed5b30f401f151 (diff)
powerpc: Use linux/elfcore-compat.h
This makes powerpc64's compat code use the new linux/elfcore-compat.h, reducing some hand-copied duplication. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Andi Kleen <ak@suse.de> Cc: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/powerpc/kernel/binfmt_elf32.c67
-rw-r--r--include/asm-powerpc/elf.h38
2 files changed, 51 insertions, 54 deletions
diff --git a/arch/powerpc/kernel/binfmt_elf32.c b/arch/powerpc/kernel/binfmt_elf32.c
index 5cb58757e1b1..1d45d7782d4e 100644
--- a/arch/powerpc/kernel/binfmt_elf32.c
+++ b/arch/powerpc/kernel/binfmt_elf32.c
@@ -13,49 +13,44 @@
13 * 2 of the License, or (at your option) any later version. 13 * 2 of the License, or (at your option) any later version.
14 */ 14 */
15 15
16#define ELF_ARCH EM_PPC
17#define ELF_CLASS ELFCLASS32
18#define ELF_DATA ELFDATA2MSB;
19
20#include <asm/processor.h> 16#include <asm/processor.h>
21#include <linux/module.h> 17#include <linux/module.h>
22#include <linux/elfcore.h>
23#include <linux/compat.h> 18#include <linux/compat.h>
19#include <linux/elfcore-compat.h>
20
21#undef ELF_ARCH
22#undef ELF_CLASS
23#define ELF_CLASS ELFCLASS32
24#define ELF_ARCH EM_PPC
25
26#undef elfhdr
27#undef elf_phdr
28#undef elf_note
29#undef elf_addr_t
30#define elfhdr elf32_hdr
31#define elf_phdr elf32_phdr
32#define elf_note elf32_note
33#define elf_addr_t Elf32_Off
24 34
25#define elf_prstatus elf_prstatus32 35#define elf_prstatus compat_elf_prstatus
26struct elf_prstatus32 36#define elf_prpsinfo compat_elf_prpsinfo
37
38#define elf_core_copy_regs compat_elf_core_copy_regs
39static inline void compat_elf_core_copy_regs(compat_elf_gregset_t *elf_regs,
40 struct pt_regs *regs)
27{ 41{
28 struct elf_siginfo pr_info; /* Info associated with signal */ 42 PPC_ELF_CORE_COPY_REGS((*elf_regs), regs);
29 short pr_cursig; /* Current signal */ 43}
30 unsigned int pr_sigpend; /* Set of pending signals */
31 unsigned int pr_sighold; /* Set of held signals */
32 pid_t pr_pid;
33 pid_t pr_ppid;
34 pid_t pr_pgrp;
35 pid_t pr_sid;
36 struct compat_timeval pr_utime; /* User time */
37 struct compat_timeval pr_stime; /* System time */
38 struct compat_timeval pr_cutime; /* Cumulative user time */
39 struct compat_timeval pr_cstime; /* Cumulative system time */
40 elf_gregset_t pr_reg; /* General purpose registers. */
41 int pr_fpvalid; /* True if math co-processor being used. */
42};
43 44
44#define elf_prpsinfo elf_prpsinfo32 45#define elf_core_copy_task_regs compat_elf_core_copy_task_regs
45struct elf_prpsinfo32 46static int compat_elf_core_copy_task_regs(struct task_struct *tsk,
47 compat_elf_gregset_t *elf_regs)
46{ 48{
47 char pr_state; /* numeric process state */ 49 struct pt_regs *regs = tsk->thread.regs;
48 char pr_sname; /* char for pr_state */ 50 if (regs)
49 char pr_zomb; /* zombie */ 51 compat_elf_core_copy_regs(elf_regs, regs);
50 char pr_nice; /* nice val */ 52 return 1;
51 unsigned int pr_flag; /* flags */ 53}
52 u32 pr_uid;
53 u32 pr_gid;
54 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
55 /* Lots missing */
56 char pr_fname[16]; /* filename of executable */
57 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
58};
59 54
60#include <linux/time.h> 55#include <linux/time.h>
61 56
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index 5b9e3f41d649..8925c2813667 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -101,6 +101,7 @@ typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
101 101
102typedef unsigned int elf_greg_t32; 102typedef unsigned int elf_greg_t32;
103typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG]; 103typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
104typedef elf_gregset_t32 compat_elf_gregset_t;
104 105
105/* 106/*
106 * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps. 107 * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps.
@@ -175,26 +176,27 @@ typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
175 176
176#define ELF_ET_DYN_BASE (0x20000000) 177#define ELF_ET_DYN_BASE (0x20000000)
177 178
178/* Common routine for both 32-bit and 64-bit processes */ 179/*
180 * Our registers are always unsigned longs, whether we're a 32 bit
181 * process or 64 bit, on either a 64 bit or 32 bit kernel.
182 *
183 * This macro relies on elf_regs[i] having the right type to truncate to,
184 * either u32 or u64. It defines the body of the elf_core_copy_regs
185 * function, either the native one with elf_gregset_t elf_regs or
186 * the 32-bit one with elf_gregset_t32 elf_regs.
187 */
188#define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
189 int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
190 (size_t)ELF_NGREG); \
191 for (i = 0; i < nregs; i++) \
192 elf_regs[i] = ((unsigned long *) regs)[i]; \
193 memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
194
195/* Common routine for both 32-bit and 64-bit native processes */
179static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, 196static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
180 struct pt_regs *regs) 197 struct pt_regs *regs)
181{ 198{
182 int i, nregs; 199 PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
183
184 memset((void *)elf_regs, 0, sizeof(elf_gregset_t));
185
186 /* Our registers are always unsigned longs, whether we're a 32 bit
187 * process or 64 bit, on either a 64 bit or 32 bit kernel.
188 * Don't use ELF_GREG_TYPE here. */
189 nregs = sizeof(struct pt_regs) / sizeof(unsigned long);
190 if (nregs > ELF_NGREG)
191 nregs = ELF_NGREG;
192
193 for (i = 0; i < nregs; i++) {
194 /* This will correctly truncate 64 bit registers to 32 bits
195 * for a 32 bit process on a 64 bit kernel. */
196 elf_regs[i] = (elf_greg_t)((ELF_GREG_TYPE *)regs)[i];
197 }
198} 200}
199#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs); 201#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
200 202