Arch-abstraction: a nice change that removes the need for ume_entry.S. Instead
of using an assembly hack to find the stack pointer at startup, we find it from
argv. It's much simpler, avoids linking games, is platform independent, and
works on PPC.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2782 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 1880925..f3e7f94 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -165,9 +165,7 @@
hello_LDFLAGS = -Wl,-defsym,kickstart_base=0x50000000 \
-Wl,-T,../../coregrind/${VG_ARCH}/stage2.lds
vgtest_ume_SOURCES = vgtest_ume.c
-vgtest_ume_LDFLAGS = -Wl,-e,_ume_entry
vgtest_ume_LDADD = ../../coregrind/ume.o \
- ../../coregrind/ume_entry.o \
../../coregrind/jmp_with_stack.o
# must be built with these flags -- bug only occurred with them
diff --git a/memcheck/tests/vgtest_ume.c b/memcheck/tests/vgtest_ume.c
index 458f6f0..84ca391 100644
--- a/memcheck/tests/vgtest_ume.c
+++ b/memcheck/tests/vgtest_ume.c
@@ -1,6 +1,6 @@
#define ELFSZ 32
-// This file is a unit self-test for ume.c, ume_entry.c, jmp_with_stack.c
+// This file is a unit self-test for ume.c, jmp_with_stack.c
#include <stdlib.h>
#include <stdio.h>
@@ -10,26 +10,28 @@
#define STKSZ (64*1024)
+static void* init_sp;
+
//-------------------------------------------------------------------
// Test foreach_map()
//-------------------------------------------------------------------
-static int x;
+static int x[8];
static int f(char *start, char *end, const char *perm, off_t off,
int maj, int min, int ino, void* dummy) {
// Just do some nonsense action with each of the values so that Memcheck
// checks that they are valid.
- x = ( start == 0 ? 0 : 1 );
- x = ( end == 0 ? 0 : 1 );
- x = ( perm == 0 ? 0 : 1 );
- x = ( off == 0 ? 0 : 1 );
- x = ( maj == 0 ? 0 : 1 );
- x = ( min == 0 ? 0 : 1 );
- x = ( ino == 0 ? 0 : 1 );
- x = ( dummy == 0 ? 0 : 1 );
+ x[0] = ( start == 0 ? 0 : 1 );
+ x[1] = ( end == 0 ? 0 : 1 );
+ x[2] = ( perm == 0 ? 0 : 1 );
+ x[3] = ( off == 0 ? 0 : 1 );
+ x[4] = ( maj == 0 ? 0 : 1 );
+ x[5] = ( min == 0 ? 0 : 1 );
+ x[6] = ( ino == 0 ? 0 : 1 );
+ x[7] = ( dummy == 0 ? 0 : 1 );
- return /*True*/1;
+ return /*True*/1 + x[0] + x[1] + x[2] + x[3] + x[4] + x[5] + x[6] + x[7];
}
static void test__foreach_map(void)
@@ -46,14 +48,14 @@
{
struct ume_auxv *auxv;
- assert(ume_exec_esp != NULL);
+ assert(init_sp != NULL);
fprintf(stderr, "Calling find_auxv()\n");
- auxv = find_auxv((int*)ume_exec_esp);
+ auxv = find_auxv((int*)init_sp);
// Check the auxv value looks sane
- assert((void*)auxv > (void*)ume_exec_esp);
- assert((unsigned int)auxv - (unsigned int)ume_exec_esp < 0x10000);
+ assert((void*)auxv > (void*)init_sp);
+ assert((unsigned int)auxv - (unsigned int)init_sp < 0x10000);
// Scan the auxv, check it looks sane
for (; auxv->a_type != AT_NULL; auxv++) {
@@ -136,8 +138,10 @@
assert(0); // UNREACHABLE
}
-int main(void)
+int main(int argc, char** argv)
{
+ init_sp = argv - 1;
+
test__foreach_map();
test__find_auxv();
test__do_exec();