Restructured the as_*() functions so they are simpler and there is no implicit
global state -- the state is threaded explicitly through via function arguments
and return values. ume.c now has no global variables, which is nice.
Also removed a redundant as_pad() call in stage2's main() which meant
layout_client_space() could be merged with layout_remaining_space().
Also removed a couple of no-longer-used variables and #defines.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2537 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/stage1.c b/coregrind/stage1.c
index 4d50c49..ce408d7 100644
--- a/coregrind/stage1.c
+++ b/coregrind/stage1.c
@@ -61,7 +61,8 @@
communicate some extra information to stage2 (namely, the fd of the
padding file, so it can identiry and remove the padding later).
*/
-static void *fix_auxv(void *v_init_esp, const struct exeinfo *info)
+static void *fix_auxv(void *v_init_esp, const struct exeinfo *info,
+ int padfile)
{
struct ume_auxv *auxv;
int *newesp;
@@ -90,7 +91,7 @@
/* stage2 needs this so it can clean up the padding we leave in
place when we start it */
auxv[0].a_type = AT_UME_PADFD;
- auxv[0].u.a_val = as_getpadfd();
+ auxv[0].u.a_val = padfile;
/* This will be needed by valgrind itself so that it can
subsequently execve() children. This needs to be done here
@@ -155,7 +156,8 @@
return v_init_esp;
}
-static int prmap(void *start, void *end, const char *perm, off_t off, int maj, int min, int ino) {
+static int prmap(char *start, char *end, const char *perm, off_t off, int maj,
+ int min, int ino, void* dummy) {
printf("mapping %10p-%10p %s %02x:%02x %d\n",
start, end, perm, maj, min, ino);
return 1;
@@ -163,7 +165,7 @@
static void hoops(void)
{
- int err;
+ int err, padfile;
struct exeinfo info;
extern char _end;
int *esp;
@@ -193,14 +195,15 @@
/* Make sure stage2's dynamic linker can't tromp on the lower part
of the address space. */
- as_pad(0, (void *)info.map_base);
+ padfile = as_openpadfile();
+ as_pad(0, (void *)info.map_base, padfile);
- esp = fix_auxv(ume_exec_esp, &info);
+ esp = fix_auxv(ume_exec_esp, &info, padfile);
if (0) {
printf("---------- launch stage 2 ----------\n");
printf("eip=%p esp=%p\n", (void *)info.init_eip, esp);
- foreach_map(prmap);
+ foreach_map(prmap, /*dummy*/NULL);
}
ume_go(info.init_eip, (addr_t)esp);