comments/formatting of jmp_with_stack for ARM and x86, too.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3149
#include "ume.h"
-/*
- Jump to a particular IP with a particular SP. This is intended
- to simulate the initial CPU state when the kernel starts an program
- after exec; it therefore also clears all the other registers.
- */
-void jmp_with_stack(Addr eip, Addr esp)
+void jmp_with_stack(Addr rip, Addr rsp)
{
- // XXX: temporary only
-extern int printf (__const char *__restrict __format, ...);
-extern void exit (int __status);
- printf("jmp_with_stack: argh\n");
- exit(1);
-#if 0
- asm volatile ("movl %1, %%esp;" /* set esp */
- "pushl %%eax;" /* push esp */
- "xorl %%eax,%%eax;" /* clear registers */
- "xorl %%ebx,%%ebx;"
- "xorl %%ecx,%%ecx;"
- "xorl %%edx,%%edx;"
- "xorl %%esi,%%esi;"
- "xorl %%edi,%%edi;"
- "xorl %%ebp,%%ebp;"
-
- "ret" /* return into entry */
- : : "a" (eip), "r" (esp));
- /* we should never get here */
+ asm volatile (
+ "movq %1, %%rsp;" // set rsp
+ "pushq %%rax;" // push rsp
+ "xorq %%rax,%%rax;" // clear registers
+ "xorq %%rbx,%%rbx;"
+ "xorq %%rcx,%%rcx;"
+ "xorq %%rdx,%%rdx;"
+ "xorq %%rsi,%%rsi;"
+ "xorq %%rdi,%%rdi;"
+ "xorq %%rbp,%%rbp;"
+ "xorq %%r8, %%r8;"
+ "xorq %%r9, %%r9;"
+ "xorq %%r10,%%r10;"
+ "xorq %%r11,%%r11;"
+ "xorq %%r12,%%r12;"
+ "xorq %%r13,%%r13;"
+ "xorq %%r14,%%r14;"
+ "xorq %%r15,%%r15;"
+ "ret" // return into entry
+ : : "a" (rip), "r" (rsp));
+
+ // we should never get here
for(;;)
- asm volatile("ud2");
-#endif
+ asm volatile("ud2");
}
#include "ume.h"
-/*
- Jump to a particular IP with a particular SP. This is intended
- to simulate the initial CPU state when the kernel starts an program
- after exec; it therefore also clears all the other registers.
- */
void jmp_with_stack(Addr eip, Addr esp)
{
// XXX: temporary only
extern void exit (int __status);
printf("jmp_with_stack: argh\n");
exit(1);
-#if 0
- asm volatile ("movl %1, %%esp;" /* set esp */
- "pushl %%eax;" /* push esp */
- "xorl %%eax,%%eax;" /* clear registers */
- "xorl %%ebx,%%ebx;"
- "xorl %%ecx,%%ecx;"
- "xorl %%edx,%%edx;"
- "xorl %%esi,%%esi;"
- "xorl %%edi,%%edi;"
- "xorl %%ebp,%%ebp;"
-
- "ret" /* return into entry */
- : : "a" (eip), "r" (esp));
- /* we should never get here */
- for(;;)
- asm volatile("ud2");
-#endif
+
+ // XXX: see x86/jmp_with_stack.c for how to implement this
}
int maj, int min, int ino, void* extra),
void* extra);
-// Jump to a new 'ip' with the stack 'sp'.
+// Jump to a new 'ip' with the stack 'sp'. This is intended
+// to simulate the initial CPU state when the kernel starts an program
+// after exec; and so should clear all the other registers.
void jmp_with_stack(Addr ip, Addr sp) __attribute__((noreturn));
/*------------------------------------------------------------*/
#include "ume.h"
-/*
- Jump to a particular IP with a particular SP. This is intended
- to simulate the initial CPU state when the kernel starts an program
- after exec; it therefore also clears all the other registers.
- */
void jmp_with_stack(Addr eip, Addr esp)
{
- asm volatile ("movl %1, %%esp;" /* set esp */
- "pushl %%eax;" /* push esp */
- "xorl %%eax,%%eax;" /* clear registers */
- "xorl %%ebx,%%ebx;"
- "xorl %%ecx,%%ecx;"
- "xorl %%edx,%%edx;"
- "xorl %%esi,%%esi;"
- "xorl %%edi,%%edi;"
- "xorl %%ebp,%%ebp;"
-
- "ret" /* return into entry */
- : : "a" (eip), "r" (esp));
- /* we should never get here */
+ asm volatile (
+ "movl %1, %%esp;" // set esp */
+ "pushl %%eax;" // push esp */
+ "xorl %%eax,%%eax;" // clear registers
+ "xorl %%ebx,%%ebx;"
+ "xorl %%ecx,%%ecx;"
+ "xorl %%edx,%%edx;"
+ "xorl %%esi,%%esi;"
+ "xorl %%edi,%%edi;"
+ "xorl %%ebp,%%ebp;"
+ "ret" // return into entry
+ : : "a" (eip), "r" (esp));
+
+ // we should never get here
for(;;)
- asm volatile("ud2");
+ asm volatile("ud2");
}