// - LD_PRELOAD is on Linux, not on Darwin, not sure about AIX
// - DYLD_INSERT_LIBRARIES and DYLD_SHARED_REGION are Darwin-only
for (i = 0; envp[i] != NULL; i++) {
- if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
- ld_preload_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.1", &envp[i][11]);
- if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0)
- ld_library_path_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.2", &envp[i][16]);
- if (VG_(strncmp)(envp[i], "DYLD_INSERT_LIBRARIES=", 22) == 0)
- dyld_insert_libraries_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.3", &envp[i][22]);
+ if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0) {
+ envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.1", envp[i]);
+ ld_preload_str = &envp[i][11];
+ }
+ if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0) {
+ envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.2", envp[i]);
+ ld_library_path_str = &envp[i][16];
+ }
+ if (VG_(strncmp)(envp[i], "DYLD_INSERT_LIBRARIES=", 22) == 0) {
+ envp[i] = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.3", envp[i]);
+ dyld_insert_libraries_str = &envp[i][22];
+ }
}
buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.4",
noinst_HEADERS = fdleak.h
EXTRA_DIST = \
+ allexec32.stdout.exp allexec32.stderr.exp allexec32.vgtest\
+ allexec64.stdout.exp allexec64.stderr.exp allexec64.vgtest\
ansi.stderr.exp ansi.vgtest \
args.stderr.exp args.stdout.exp args.vgtest \
async-sigs.stderr.exp async-sigs.vgtest \
--- /dev/null
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+extern char **environ;
+
+#define S(...) (fprintf(stdout, __VA_ARGS__),fflush(stdout))
+#define FORKEXECWAIT(exec_call) do { \
+ int status;\
+ pid_t child = fork(); \
+ if (child == 0) {exec_call; perror ("exec failed");} \
+ else if (child == -1) perror ("cannot fork\n"); \
+ else if (child != wait (&status)) perror ("error waiting child"); \
+ else S("child exited\n"); \
+ } while (0)
+
+void test_allexec (char *exec)
+{
+ FORKEXECWAIT (execlp(exec, exec, NULL));
+ FORKEXECWAIT (execlp(exec, exec, "constant_arg1", "constant_arg2", NULL));
+ FORKEXECWAIT (execve(exec, NULL, environ));
+}
+
+
+/* If a single argument "exec" is given, will execute itself
+ (in bi-arch, a 32 bit and 64 bit variant) via various exec system calls.
+ Note that this test can only be run after the prerequisite have been
+ prepared by allexec_prepare_prereq, which will a.o. make links
+ for the allexec32 and allexec64 executables. On single arch build,
+ these links points to the same executable to ensure this test works
+ everywhere the same.
+ No arguments or more arguments means just print its args. */
+int main(int argc, char **argv, char **envp)
+{
+ if ( (argc == 2) && (strcmp (argv[1], "exec") == 0)) {
+ S("%s will exec ./allexec32\n", argv[0]);
+ test_allexec ("./allexec32");
+ S("%s will exec ./allexec64\n", argv[0]);
+ test_allexec ("./allexec64");
+ } else {
+ int i;
+ S("program exec-ed:");
+ for (i = 0; i < argc; i++) S(" %s", argv[i]);
+ S("\n");
+ }
+ return 0;
+}
--- /dev/null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+./allexec32 will exec ./allexec32
+program exec-ed: ./allexec32
+child exited
+program exec-ed: ./allexec32 constant_arg1 constant_arg2
+child exited
+program exec-ed: ./allexec32
+child exited
+./allexec32 will exec ./allexec64
+program exec-ed: ./allexec64
+child exited
+program exec-ed: ./allexec64 constant_arg1 constant_arg2
+child exited
+program exec-ed: ./allexec64
+child exited
--- /dev/null
+prog: allexec32
+args: exec
+vgopts: --trace-children=yes
+prereq: ./allexec_prepare_prereq
--- /dev/null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+./allexec64 will exec ./allexec32
+program exec-ed: ./allexec32
+child exited
+program exec-ed: ./allexec32 constant_arg1 constant_arg2
+child exited
+program exec-ed: ./allexec32
+child exited
+./allexec64 will exec ./allexec64
+program exec-ed: ./allexec64
+child exited
+program exec-ed: ./allexec64 constant_arg1 constant_arg2
+child exited
+program exec-ed: ./allexec64
+child exited
--- /dev/null
+prog: allexec64
+args: exec
+vgopts: --trace-children=yes
+prereq: ./allexec_prepare_prereq
--- /dev/null
+#! /bin/sh
+
+# prepare the hard or soft link allexec32 and allexec64
+# On 'single arch' compiled Valgrind, allexec32 and allexec64 will point
+# to the same executable.
+# On 'bi-arch', they will point respectively to the executable compiled
+# for the revelant arch.
+# This allows to test the various exec system calls the same way.
+
+
+pair()
+{
+ if ../../tests/arch_test $1 || ../../tests/arch_test $2
+ then
+ if ../../tests/arch_test $1
+ then
+ ln -f $1/allexec allexec32
+ else
+ ln -f -s allexec64 allexec32
+ fi
+ if ../../tests/arch_test $2
+ then
+ ln -f $2/allexec allexec64
+ else
+ ln -f -s allexec32 allexec64
+ fi
+ fi
+}
+
+
+pair x86 amd64
+pair ppc32 ppc64
+pair s390x_unexisting_in_32bits s390x
+pair arm arm_unexisting_in_64bits
+
+exit 0
xadd.stderr.exp xadd.stdout.exp xadd.vgtest
check_PROGRAMS = \
+ allexec \
amd64locked \
asorep \
bug127521-64 bug132813-amd64 bug132918 \
AM_CXXFLAGS += @FLAG_M64@
AM_CCASFLAGS += @FLAG_M64@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
# generic C ones
amd64locked_CFLAGS = $(AM_CFLAGS) -O
bug132918_LDADD = -lm
--- /dev/null
+../allexec.c
\ No newline at end of file
vfp.stdout.exp vfp.stderr.exp vfp.vgtest
check_PROGRAMS = \
+ allexec \
neon128 \
neon64 \
v6intARM \
AM_CXXFLAGS += @FLAG_M32@
AM_CCASFLAGS += @FLAG_M32@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
# These two are specific to their ARM/Thumb respectively and so we
# hardwire -marm/-mthumb. neon64 and neon128 are compilable on both,
# however, ask for them to be compiled on thumb, as that looks
--- /dev/null
+../allexec.c
\ No newline at end of file
test_isa_2_06_part3.stderr.exp test_isa_2_06_part3.stdout.exp test_isa_2_06_part3.vgtest
check_PROGRAMS = \
+ allexec \
bug129390-ppc32 \
bug139050-ppc32 \
ldstrev lsw jm-insns mftocrf mcrfs round test_fx test_gx \
AM_CXXFLAGS += @FLAG_M32@
AM_CCASFLAGS += @FLAG_M32@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
if HAS_ALTIVEC
ALTIVEC_FLAG = -DHAS_ALTIVEC
else
--- /dev/null
+../allexec.c
\ No newline at end of file
test_isa_2_06_part3.stderr.exp test_isa_2_06_part3.stdout.exp test_isa_2_06_part3.vgtest
check_PROGRAMS = \
+ allexec \
jm-insns lsw round std_reg_imm twi_tdi tw_td power6_bcmp power6_mf_gpr test_isa_2_06_part1 \
test_isa_2_06_part2 test_isa_2_06_part3
AM_CXXFLAGS += @FLAG_M64@
AM_CCASFLAGS += @FLAG_M64@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
if HAS_ALTIVEC
ALTIVEC_FLAG = -DHAS_ALTIVEC
else
--- /dev/null
+../allexec.c
\ No newline at end of file
op_exception fgx stck stckf stcke stfle cksm mvcl clcl
check_PROGRAMS = $(INSN_TESTS) \
+ allexec \
ex_sig \
ex_clone \
op00
AM_CXXFLAGS += @FLAG_M64@
AM_CCASFLAGS += @FLAG_M64@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
ex_clone_LDFLAGS = -lpthread
tcxb_CFLAGS = $(AM_CFLAGS) -std=gnu99
--- /dev/null
+../allexec.c
\ No newline at end of file
check_PROGRAMS = \
aad_aam \
+ allexec \
badseg \
bt_everything \
bt_literal \
AM_CXXFLAGS += @FLAG_M32@ $(FLAG_MMMX) $(FLAG_MSSE)
AM_CCASFLAGS += @FLAG_M32@
+allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
+
if VGCONF_OS_IS_DARWIN
# Some of the tests (bug125959_x86, bug152818_x86, insn_*) need
# -mdynamic-no-pic. I tried setting *_CFLAGS separately for all of them,
--- /dev/null
+../allexec.c
\ No newline at end of file