7
7
This file is part of Valgrind, a dynamic binary instrumentation
10
Copyright (C) 2000-2006 Julian Seward
10
Copyright (C) 2000-2007 Julian Seward
13
13
This program is free software; you can redistribute it and/or
34
34
//--------------------------------------------------------------------
35
35
// PURPOSE: This module implements user-mode execve, ie. program loading
36
// and exec'ing. It is shared between stage1 and stage2.
37
37
//--------------------------------------------------------------------
40
#include <sys/types.h>
42
/*------------------------------------------------------------*/
43
/*--- General stuff ---*/
44
/*------------------------------------------------------------*/
46
/* This is only here so it can be shared between stage1 and stage2 */
48
/* JRS 9 Aug 05: both of these are apparently unused, except by
49
memcheck/tests/vgtest_ume.c. */
51
//zz void VG_(foreach_map)(int (*fn)(char *start, char *end,
52
//zz const char *perm, off_t offset,
53
//zz int maj, int min, int ino, void* extra),
56
//zz /* Jump to 'dst', but first set the stack pointer to 'stack'. Also,
57
//zz clear all the integer registers before entering 'dst'. It's
58
//zz important that the stack pointer is set to exactly 'stack' and not
59
//zz (eg) stack - apparently_harmless_looking_small_offset. Basically
60
//zz because the code at 'dst' might be wanting to scan the area above
61
//zz 'stack' (viz, the auxv array), and putting spurious words on the
62
//zz stack confuses it.
64
//zz This is only exported so that vgtest_ume.c can use it.
67
//zz __attribute__((noreturn))
68
//zz void VG_(jump_and_switch_stacks) ( Addr stack, Addr dst );
71
39
/*------------------------------------------------------------*/
72
40
/*--- Loading ELF files ---*/
73
41
/*------------------------------------------------------------*/
101
69
// the kernel: ie. it's a file, it's readable and executable, and it's in
102
70
// either ELF or "#!" format. On success, 'out_fd' gets the fd of the file
103
71
// if it's non-NULL. Otherwise the fd is closed.
104
extern SysRes VG_(pre_exec_check)(const HChar* exe_name, Int* out_fd);
72
extern SysRes VG_(pre_exec_check)(const HChar* exe_name, Int* out_fd,
106
75
// Does everything short of actually running 'exe': finds the file,
107
76
// checks execute permissions, sets up interpreter if program is a script,