foreach_map(prmap, /*dummy*/NULL);
}
- jmp_with_stack(info.init_eip, (addr_t)esp);
+ jmp_with_stack(info.init_eip, (Addr)esp);
}
int main(int argc, char** argv)
setrlimit(RLIMIT_AS, &rlim);
/* move onto another stack so we can play with the main one */
- jmp_with_stack((addr_t)main2, (addr_t)stack + sizeof(stack));
+ jmp_with_stack((Addr)main2, (Addr)stack + sizeof(stack));
}
/*--------------------------------------------------------------------*/
info->exe_base = minaddr + ebase;
info->exe_end = maxaddr + ebase;
- info->init_eip = (addr_t)entry;
+ info->init_eip = (Addr)entry;
free(e);
#error ELFSZ needs to ==32 or ==64
#endif
-/* Integer type the same size as a pointer */
-typedef ESZ(Addr) addr_t;
-
// Jump to a new 'ip' with the stack 'sp'.
-void jmp_with_stack(addr_t ip, addr_t sp) __attribute__((noreturn));
+void jmp_with_stack(Addr ip, Addr sp) __attribute__((noreturn));
/*------------------------------------------------------------*/
/*--- Loading ELF files ---*/
// inputs/outputs of do_exec().
struct exeinfo
{
- addr_t map_base; // IN: if non-zero, base address of mappings
+ Addr map_base; // IN: if non-zero, base address of mappings
char** argv; // IN: the original argv
- addr_t exe_base; // INOUT: lowest (allowed) address of exe
- addr_t exe_end; // INOUT: highest (allowed) address
+ Addr exe_base; // INOUT: lowest (allowed) address of exe
+ Addr exe_end; // INOUT: highest (allowed) address
- addr_t phdr; // OUT: address phdr was mapped at
- int phnum; // OUT: number of phdrs
- addr_t interp_base; // OUT: where interpreter (ld.so) was mapped
- addr_t entry; // OUT: entrypoint in main executable
- addr_t init_eip; // OUT: initial eip
- addr_t brkbase; // OUT: base address of brk segment
+ Addr phdr; // OUT: address phdr was mapped at
+ int phnum; // OUT: number of phdrs
+ Addr interp_base; // OUT: where interpreter (ld.so) was mapped
+ Addr entry; // OUT: entrypoint in main executable
+ Addr init_eip; // OUT: initial eip
+ Addr brkbase; // OUT: base address of brk segment
// These are the extra args added by #! scripts
char* interp_name; // OUT: the interpreter name
static void layout_remaining_space(Addr argc_addr, float ratio)
{
- Int ires;
- void* vres;
- addr_t client_size, shadow_size;
+ Int ires;
+ void* vres;
+ Addr client_size, shadow_size;
// VG_(valgrind_base) should have been set by scan_auxv, but if not,
// this is a workable approximation
VG_(client_end) = VG_(client_base) + client_size;
/* where !FIXED mmap goes */
VG_(client_mapbase) = VG_(client_base) +
- PGROUNDDN((addr_t)(client_size * CLIENT_HEAP_PROPORTION));
+ PGROUNDDN((Addr)(client_size * CLIENT_HEAP_PROPORTION));
VG_(shadow_base) = VG_(client_end) + REDZONE_SIZE;
VG_(shadow_end) = VG_(valgrind_base);
char **cpp;
char *strtab; /* string table */
char *stringbase;
- addr_t *ptr;
+ Addr *ptr;
struct ume_auxv *auxv;
const struct ume_auxv *orig_auxv;
const struct ume_auxv *cauxv;
int argc; /* total argc */
int envc; /* total number of env vars */
unsigned stacksize; /* total client stack size */
- addr_t cl_esp; /* client stack base (initial esp) */
+ Addr cl_esp; /* client stack base (initial esp) */
/* use our own auxv as a prototype */
orig_auxv = find_auxv(init_sp);
/* ==================== copy client stack ==================== */
- ptr = (addr_t *)cl_esp;
+ ptr = (Addr*)cl_esp;
/* --- argc --- */
*ptr++ = argc; /* client argc */
/* --- argv --- */
if (info->interp_name) {
- *ptr++ = (addr_t)copy_str(&strtab, info->interp_name);
+ *ptr++ = (Addr)copy_str(&strtab, info->interp_name);
free(info->interp_name);
}
if (info->interp_args) {
- *ptr++ = (addr_t)copy_str(&strtab, info->interp_args);
+ *ptr++ = (Addr)copy_str(&strtab, info->interp_args);
free(info->interp_args);
}
for (cpp = orig_argv; *cpp; ptr++, cpp++) {
- *ptr = (addr_t)copy_str(&strtab, *cpp);
+ *ptr = (Addr)copy_str(&strtab, *cpp);
}
*ptr++ = 0;
/* --- envp --- */
VG_(client_envp) = (Char **)ptr;
for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++)
- *ptr = (addr_t)copy_str(&strtab, *cpp);
+ *ptr = (Addr)copy_str(&strtab, *cpp);
*ptr++ = 0;
/* --- auxv --- */
to simulate the initial CPU state when the kernel starts an program
after exec; it therefore also clears all the other registers.
*/
-void jmp_with_stack(addr_t eip, addr_t esp)
+void jmp_with_stack(Addr eip, Addr esp)
{
asm volatile ("movl %1, %%esp;" /* set esp */
"pushl %%eax;" /* push esp */
// fprintf(stderr, "ume_go: %p %p\n", (void*)info.init_eip, (void*)esp);
- jmp_with_stack(info.init_eip, (addr_t)esp);
+ jmp_with_stack(info.init_eip, (Addr)esp);
assert(0); // UNREACHABLE
}