CLEANFILES = vg_toolint.c vg_toolint.h vg_replace_malloc.c vg_intercept.c
valgrind_SOURCES = \
- stage1.c \
ume.c \
- x86/ume_entry.S \
- x86/ume_go.c
+ ${VG_ARCH}/ume_entry.S \
+ \
+ stage1.c \
+ ${VG_ARCH}/jmp_with_stack.c
valgrind_DEPENDENCIES =
valgrind_LDFLAGS=-static -g -Wl,-e,_ume_entry
valgrind_LDADD=
stage2_SOURCES = \
ume.c \
- x86/ume_entry.S \
+ ${VG_ARCH}/ume_entry.S \
\
vg_scheduler.c \
vg_default.c \
core.h \
core_asm.h \
ume.h \
- ume_arch.h \
vg_symtab2.h \
vg_symtypes.h \
vg_toolint.h \
#include <unistd.h>
#include "core.h"
-
#include "ume.h"
-#include "ume_arch.h"
static int stack[SIGSTKSZ*4];
foreach_map(prmap, /*dummy*/NULL);
}
- ume_go(info.init_eip, (addr_t)esp);
+ jmp_with_stack(info.init_eip, (addr_t)esp);
}
int main(void)
setrlimit(RLIMIT_AS, &rlim);
/* move onto another stack so we can play with the main one */
- ume_go((addr_t)hoops, (addr_t)stack + sizeof(stack));
+ jmp_with_stack((addr_t)hoops, (addr_t)stack + sizeof(stack));
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
-/*--- User-mode execve() ume.c ---*/
+/*--- User-mode execve(), and other stuff shared between stage1 ---*/
+/*--- and stage2. ume.c ---*/
/*--------------------------------------------------------------------*/
/*
int maj, int min, int ino, void* extra),
void* extra);
-/*------------------------------------------------------------*/
-/*--- Loading ELF files ---*/
-/*------------------------------------------------------------*/
-
#if ELFSZ == 64
#define ESZ(x) Elf64_##x
#elif ELFSZ == 32
/* Integer type the same size as a pointer */
typedef ESZ(Addr) addr_t;
+extern void *ume_exec_esp; /* esp on entry at exec time */
+
+// Jump to a new 'ip' with the stack 'sp'.
+void jmp_with_stack(addr_t ip, addr_t sp) __attribute__((noreturn));
+
+void foreach_map(int (*fn)(char *start, char *end,
+ const char *perm, off_t offset,
+ int maj, int min, int ino, void* extra),
+ void* extra);
+
+/*------------------------------------------------------------*/
+/*--- Loading ELF files ---*/
+/*------------------------------------------------------------*/
+
// Info needed to load and run a program. IN/INOUT/OUT refers to the
// inputs/outputs of do_exec().
struct exeinfo
+++ /dev/null
-
-/*
- This file is part of Valgrind, an extensible x86 protected-mode
- emulator for monitoring program execution on x86-Unixes.
-
- Copyright (C) 2000-2004 Julian Seward
- jseward@acm.org
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#ifndef UME_ARCH
-#define UME_ARCH
-
-#include "ume.h"
-
-void ume_go(addr_t eip, addr_t esp) __attribute__((noreturn));
-
-extern void *ume_exec_esp; /* esp on entry at exec time */
-
-#endif /* UME_ARCH */
#include "core.h"
#include "ume.h"
-#include "ume_arch.h"
#include <dirent.h>
#include <dlfcn.h>
noinst_LIBRARIES = libarch.a
-EXTRA_DIST = \
- ume_entry.S \
- ume_go.c
+EXTRA_DIST = \
+ jmp_with_stack.c \
+ ume_entry.S
BUILT_SOURCES = stage2.lds
CLEANFILES = stage2.lds
The GNU General Public License is contained in the file COPYING.
*/
-#include "ume_arch.h"
+#include "ume.h"
/*
- Jump to a particular EIP with a particular ESP. This is intended
+ 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 ume_go(addr_t eip, addr_t esp)
+void jmp_with_stack(addr_t eip, addr_t esp)
{
asm volatile ("movl %1, %%esp;" /* set esp */
"pushl %%eax;" /* push esp */