namespace pollution.
Also broadened a couple of _dl_* suppressions so that vgtest_ume
passes on my machine.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3993
/* Look for our AUXV table */
static int scan_auxv(void* init_sp)
{
- struct ume_auxv *auxv = find_auxv((UWord*)init_sp);
+ struct ume_auxv *auxv = VG_(find_auxv)((UWord*)init_sp);
int padfile = -1, found = 0;
for (; auxv->a_type != AT_NULL; auxv++)
#if defined(VGP_ppc32_linux)
case AT_SYSINFO_EHDR:
VG_(vdso_base) = auxv->u.a_val;
- foreach_map(find_vdso, NULL);
+ VG_(foreach_map)(find_vdso, NULL);
break;
#endif
}
Addr cl_esp; /* client stack base (initial esp) */
/* use our own auxv as a prototype */
- orig_auxv = find_auxv(init_sp);
+ orig_auxv = VG_(find_auxv)(init_sp);
/* ==================== compute sizes ==================== */
} else {
Int ret;
VG_(clexecfd) = VG_(open)(exec, VKI_O_RDONLY, VKI_S_IRUSR);
- ret = do_exec(exec, info);
+ ret = VG_(do_exec)(exec, info);
if (ret != 0) {
fprintf(stderr, "valgrind: do_exec(%s) failed: %s\n",
exec, strerror(ret));
extra.killpad_padstat = &padstat;
extra.killpad_start = start;
extra.killpad_end = end;
- foreach_map(killpad, &extra);
+ VG_(foreach_map)(killpad, &extra);
}
static void as_closepadfile(int padfile)
// 'extra' allows the caller to pass in extra args to 'fn', like free
// variables to a closure.
-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)
+void VG_(foreach_map)(int (*fn)(char *start, char *end,
+ const char *perm, off_t offset,
+ int maj, int min, int ino, void* extra),
+ void* extra)
{
static char buf[10240];
char *bufptr = buf;
/*------------------------------------------------------------*/
// __attribute__((noreturn))
-// void jump_and_switch_stacks ( Addr stack, Addr dst );
+// void VG_(jump_and_switch_stacks) ( Addr stack, Addr dst );
#if defined(VGA_x86)
// 4(%esp) == stack
// 8(%esp) == dst
asm(
-".global jump_and_switch_stacks\n"
-"jump_and_switch_stacks:\n"
+".global vgPlain_jump_and_switch_stacks\n"
+"vgPlain_jump_and_switch_stacks:\n"
" movl %esp, %esi\n" // remember old stack pointer
" movl 4(%esi), %esp\n" // set stack
" pushl 8(%esi)\n" // dst to stack
// %rdi == stack
// %rsi == dst
asm(
-".global jump_and_switch_stacks\n"
-"jump_and_switch_stacks:\n"
+".global vgPlain_jump_and_switch_stacks\n"
+"vgPlain_jump_and_switch_stacks:\n"
" movq %rdi, %rsp\n" // set stack
" pushq %rsi\n" // dst to stack
" movq $0, %rax\n" // zero all GP regs
// %r3 == stack
// %r4 == dst
asm(
-".global jump_and_switch_stacks\n"
-"jump_and_switch_stacks:\n"
+".global vgPlain_jump_and_switch_stacks\n"
+"vgPlain_jump_and_switch_stacks:\n"
" mtctr %r4\n\t" // dst to %ctr
" mr %r1,%r3\n\t" // stack to %sp
" li 0,0\n\t" // zero all GP regs
/*--- Finding auxv on the stack ---*/
/*------------------------------------------------------------*/
-struct ume_auxv *find_auxv(UWord* sp)
+struct ume_auxv *VG_(find_auxv)(UWord* sp)
{
sp++; // skip argc (Nb: is word-sized, not int-sized!)
// See ume.h for an indication of which entries of 'info' are inputs, which
// are outputs, and which are both.
-int do_exec(const char *exe, struct exeinfo *info)
+int VG_(do_exec)(const char *exe, struct exeinfo *info)
{
info->interp_name = NULL;
info->interp_args = NULL;
/* This is only here so it can be shared between stage1 and stage2 */
extern
-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);
+void VG_(foreach_map)(int (*fn)(char *start, char *end,
+ const char *perm, off_t offset,
+ int maj, int min, int ino, void* extra),
+ void* extra);
/* Jump to 'dst', but first set the stack pointer to 'stack'. Also,
clear all the integer registers before entering 'dst'. It's
*/
extern
__attribute__((noreturn))
-void jump_and_switch_stacks ( Addr stack, Addr dst );
+void VG_(jump_and_switch_stacks) ( Addr stack, Addr dst );
/*------------------------------------------------------------*/
// checks execute permissions, sets up interpreter if program is a script,
// reads headers, maps file into memory, and returns important info about
// the program.
-extern int do_exec(const char *exe, struct exeinfo *info);
+extern int VG_(do_exec)(const char *exe, struct exeinfo *info);
/*------------------------------------------------------------*/
/*--- Finding and dealing with auxv ---*/
} u;
};
-extern struct ume_auxv *find_auxv(UWord* orig_esp);
+extern struct ume_auxv *VG_(find_auxv)(UWord* orig_esp);
/* Our private auxv entries */
#define AT_UME_PADFD 0xff01 /* padding file fd */
assert(&delta >= stack && &delta < &stack[sizeof(stack)/sizeof(*stack)]);
/* find the beginning of the AUXV table */
- auxv = find_auxv(v_init_esp);
+ auxv = VG_(find_auxv)(v_init_esp);
/* Work out how we should move things to make space for the new
auxv entry. It seems that ld.so wants a 16-byte aligned stack on
extra.fillgap_end = end;
extra.fillgap_padfile = padfile;
- foreach_map(fillgap, &extra);
+ VG_(foreach_map)(fillgap, &extra);
if (extra.fillgap_start < extra.fillgap_end) {
void* res = mmap(extra.fillgap_start,
snprintf(buf, sizeof(buf), "%s/%s", valgrind_lib, stage2);
- err = do_exec(buf, &info);
+ err = VG_(do_exec)(buf, &info);
if (err != 0) {
fprintf(stderr, "valgrind: failed to load %s: %s\n",
if (0) {
printf("---------- launch stage 2 ----------\n");
printf("eip=%p esp=%p\n", (void *)info.init_eip, esp);
- foreach_map(prmap, /*dummy*/NULL);
+ VG_(foreach_map)(prmap, /*dummy*/NULL);
}
VG_(debugLog)(1, "stage1", "main2(): starting stage2\n");
- jump_and_switch_stacks(
+ VG_(jump_and_switch_stacks)(
(Addr) esp, /* stack */
(Addr) info.init_eip /* where to */
);
/* move onto another stack so we can play with the main one */
VG_(debugLog)(1, "stage1", "main(): running main2() on new stack\n");
- jump_and_switch_stacks(
+ VG_(jump_and_switch_stacks)(
(Addr) stack + sizeof(stack), /* stack */
(Addr) main2 /* where to */
);
vgtest_ume_CFLAGS = -DVGA_$(VG_ARCH) -DVGO_$(VG_OS)
vgtest_ume_SOURCES = vgtest_ume.c
-vgtest_ume_LDADD = ../../coregrind/ume.o
+vgtest_ume_LDADD = ../../coregrind/m_ume.o
#include <assert.h>
#include <elf.h>
#include "../../include/pub_tool_basics.h"
-#include "../../coregrind/ume.h"
+#include "../../coregrind/pub_core_ume.h"
#define STKSZ (64*1024)
static void* init_sp;
//-------------------------------------------------------------------
-// Test foreach_map()
+// Test VG_(foreach_map)()
//-------------------------------------------------------------------
static int x[8];
static void test__foreach_map(void)
{
- fprintf(stderr, "Calling foreach_map()\n");
- foreach_map(f, /*dummy*/NULL);
+ fprintf(stderr, "Calling VG_(foreach_map)()\n");
+ VG_(foreach_map)(f, /*dummy*/NULL);
}
//-------------------------------------------------------------------
-// Test find_auxv()
+// Test VG_(find_auxv)()
//-------------------------------------------------------------------
static void test__find_auxv(void)
assert(init_sp != NULL);
- fprintf(stderr, "Calling find_auxv()\n");
- auxv = find_auxv((UWord*)init_sp);
+ fprintf(stderr, "Calling VG_(find_auxv)()\n");
+ auxv = VG_(find_auxv)((UWord*)init_sp);
// Check the auxv value looks sane
assert((void*)auxv > (void*)init_sp);
}
//-------------------------------------------------------------------
-// Test do_exec()
+// Test VG_(do_exec)()
//-------------------------------------------------------------------
static void push_auxv(unsigned char **espp, int type, void *val)
info.exe_end = 0x50ffffff;
info.map_base = 0x51000000;
- fprintf(stderr, "Calling do_exec(\"hello\")\n");
- err = do_exec("hello", &info);
+ fprintf(stderr, "Calling VG_(do_exec)(\"hello\")\n");
+ err = VG_(do_exec)("hello", &info);
assert(0 == err);
// printf("info.exe_base=%p exe_end=%p\n",
// fprintf(stderr, "ume_go: %p %p\n", (void*)info.init_eip, (void*)esp);
- jump_and_switch_stacks((Addr)esp, info.init_eip);
+ VG_(jump_and_switch_stacks)((Addr)esp, info.init_eip);
assert(0); // UNREACHABLE
}
-Calling foreach_map()
-Calling find_auxv()
-Calling do_exec("hello")
+Calling VG_(foreach_map)()
+Calling VG_(find_auxv)()
+Calling VG_(do_exec)("hello")
Hello, world!