[PATCH 1/5] x86: Introduce ELF_CORE_EXTRACT_REGS

From: Vitaly Mayatskikh
Date: Wed Jun 02 2010 - 05:47:53 EST


There is macro ELF_CORE_COPY_REGS_COMMON, which packs registers into
elf_gregset_t. ELF_CORE_EXTRACT_REGS does contrary action: unpacks
elf_gregset_t.

Signed-off-by: Vitaly Mayatskikh <v.mayatskih@xxxxxxxxx>
---
arch/x86/include/asm/elf.h | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index f2ad216..5e3decb 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -144,6 +144,27 @@ do { \
savesegment(gs, pr_reg[10]); \
} while (0);

+#define ELF_CORE_EXTRACT_REGS(pr_reg, regs) \
+do { \
+ (regs)->bx = (pr_reg)[0]; \
+ (regs)->cx = (pr_reg)[1]; \
+ (regs)->dx = (pr_reg)[2]; \
+ (regs)->si = (pr_reg)[3]; \
+ (regs)->di = (pr_reg)[4]; \
+ (regs)->bp = (pr_reg)[5]; \
+ (regs)->ax = (pr_reg)[6]; \
+ (regs)->ds = (pr_reg)[7]; \
+ (regs)->es = (pr_reg)[8]; \
+ (regs)->fs = (pr_reg)[9]; \
+ (regs)->gs = (pr_reg)[10]; \
+ (regs)->orig_ax = (pr_reg)[11]; \
+ (regs)->ip = (pr_reg)[12]; \
+ (regs)->cs = (pr_reg)[13]; \
+ (regs)->flags = (pr_reg)[14]; \
+ (regs)->sp = (pr_reg)[15]; \
+ (regs)->ss = (pr_reg)[16]; \
+} while (0);
+
#define ELF_PLATFORM (utsname()->machine)
#define set_personality_64bit() do { } while (0)

@@ -221,6 +242,31 @@ do { \
asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \
} while (0);

+#define ELF_CORE_EXTRACT_REGS(pr_reg, regs) \
+do { \
+ (regs)->r15 = (pr_reg)[0]; \
+ (regs)->r14 = (pr_reg)[1]; \
+ (regs)->r13 = (pr_reg)[2]; \
+ (regs)->r12 = (pr_reg)[3]; \
+ (regs)->bp = (pr_reg)[4]; \
+ (regs)->bx = (pr_reg)[5]; \
+ (regs)->r11 = (pr_reg)[6]; \
+ (regs)->r10 = (pr_reg)[7]; \
+ (regs)->r9 = (pr_reg)[8]; \
+ (regs)->r8 = (pr_reg)[9]; \
+ (regs)->ax = (pr_reg)[10]; \
+ (regs)->cx = (pr_reg)[11]; \
+ (regs)->dx = (pr_reg)[12]; \
+ (regs)->si = (pr_reg)[13]; \
+ (regs)->di = (pr_reg)[14]; \
+ (regs)->orig_ax = (pr_reg)[15]; \
+ (regs)->ip = (pr_reg)[16]; \
+ (regs)->cs = (pr_reg)[17]; \
+ (regs)->flags = (pr_reg)[18]; \
+ (regs)->sp = (pr_reg)[19]; \
+ (regs)->ss = (pr_reg)[20]; \
+} while (0);
+
/* I'm not sure if we can use '-' here */
#define ELF_PLATFORM ("x86_64")
extern void set_personality_64bit(void);
--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/