diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-powerpc/elf.h | 38 |
1 files changed, 20 insertions, 18 deletions
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 | ||
102 | typedef unsigned int elf_greg_t32; | 102 | typedef unsigned int elf_greg_t32; |
103 | typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG]; | 103 | typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG]; |
104 | typedef 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 */ | ||
179 | static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs, | 196 | static 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 | ||