]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Some combined cleaning up and arch-abstraction, involving UME and start-up:
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 13 Oct 2004 17:55:31 +0000 (17:55 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Wed, 13 Oct 2004 17:55:31 +0000 (17:55 +0000)
- removed some assumptions that arch==x86 in Makefile.am files

- removed ume_arch.h;  moved its contents into ume.h.  There was no need for
  these to be separate.

- moved ume_go.c into an x86/ subdir;  gave it the more meaningful name
  jmp_with_stack.c in the process (the corresponding function also got the name
  change)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2757

coregrind/Makefile.am
coregrind/stage1.c
coregrind/ume.c
coregrind/ume.h
coregrind/ume_arch.h [deleted file]
coregrind/vg_main.c
coregrind/x86/Makefile.am
coregrind/x86/jmp_with_stack.c [moved from coregrind/x86/ume_go.c with 92% similarity]

index e61bd1ec2807af4a6617d3d180cf8b49aa5a89dc..685d4a242d03bfbdd484f91d0b1e40c7396b1e37 100644 (file)
@@ -29,10 +29,11 @@ BUILT_SOURCES = vg_toolint.c vg_toolint.h
 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=
@@ -45,7 +46,7 @@ KICKSTART_BASE=0xb0000000
 
 stage2_SOURCES = \
        ume.c \
-       x86/ume_entry.S \
+       ${VG_ARCH}/ume_entry.S \
        \
        vg_scheduler.c \
        vg_default.c \
@@ -141,7 +142,6 @@ noinst_HEADERS = \
        core.h                  \
        core_asm.h              \
        ume.h                   \
-       ume_arch.h              \
        vg_symtab2.h            \
        vg_symtypes.h           \
        vg_toolint.h            \
index 6e8d56dc9c97749f55b02cdef4694d4bd2b3b92e..d056a1a161ac2479a868cb18cf7a21493a1c79da 100644 (file)
@@ -42,9 +42,7 @@
 #include <unistd.h>
 
 #include "core.h"
-
 #include "ume.h"
-#include "ume_arch.h"
 
 static int stack[SIGSTKSZ*4];
 
@@ -293,7 +291,7 @@ static void hoops(void)
       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)
@@ -313,7 +311,7 @@ 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));
 }
 
 /*--------------------------------------------------------------------*/
index a2cbc3e49a900c2fdf58ebc2958aa085ed30fe34..7fe3146d276deda8b6dbfdc59bf3d2192254d525 100644 (file)
@@ -1,6 +1,7 @@
 
 /*--------------------------------------------------------------------*/
-/*--- User-mode execve()                                     ume.c ---*/
+/*--- User-mode execve(), and other stuff shared between stage1    ---*/
+/*--- and stage2.                                            ume.c ---*/
 /*--------------------------------------------------------------------*/
 
 /*
index 1d7cef93b9aac69a5e72b6c6227d5e121bc4069c..76f4ef5514f22ca01c2ebfcc591845df6f214091 100644 (file)
@@ -44,10 +44,6 @@ void foreach_map(int (*fn)(char *start, char *end,
                           int maj, int min, int ino, void* extra),
                  void* extra);
 
-/*------------------------------------------------------------*/
-/*--- Loading ELF files                                    ---*/
-/*------------------------------------------------------------*/
-
 #if    ELFSZ == 64
 #define ESZ(x) Elf64_##x
 #elif  ELFSZ == 32
@@ -59,6 +55,20 @@ void foreach_map(int (*fn)(char *start, char *end,
 /* 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
diff --git a/coregrind/ume_arch.h b/coregrind/ume_arch.h
deleted file mode 100644 (file)
index 52cdabf..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/*
-   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 */
index bf7063db03dec003553ee3eb0438b336384d8586..5fb775b7c36b2287799ba6a6514779257af1bbdb 100644 (file)
@@ -32,7 +32,6 @@
 
 #include "core.h"
 #include "ume.h"
-#include "ume_arch.h"
 
 #include <dirent.h>
 #include <dlfcn.h>
index af552acfb08c28ece94da0d3c50d15dd54684917..ec16264032d944cb761cc68e2c28988d884b1e86 100644 (file)
@@ -10,9 +10,9 @@ noinst_HEADERS = \
 
 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
similarity index 92%
rename from coregrind/x86/ume_go.c
rename to coregrind/x86/jmp_with_stack.c
index 038a27057b54e3f543ca0028046785d186a1378c..1e8a55fd2c7f11af992964278c3a4c4e3f6a236d 100644 (file)
    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 */