Hi guys, I found a solution for the problems with the fork and the exec under qemu user-mode. With the fork I enabled the NPTL and now it seems to work fine. For the exec the problem was that it was execute natively, and so the qemu process was killed by the exec, so I simply called the exec for a new instance of qemu, also this seems to work fine. Let me know what do you think:
diff -r -u -p -B a/qemu-0.11.0/linux-user/syscall.c b/qemu-0.11.0/linux-user/syscall.c
--- a/qemu-0.11.0/linux-user/syscall.c 2009-09-23 12:01:32.000000000 -0700 +++ b/qemu-0.11.0/linux-user/syscall.c 2009-10-08 17:42:11.000000000 -0700 @@ -4291,6 +4291,7 @@ abi_long do_syscall(void *cpu_env, int n
unlock_user(p, arg2, 0); break; #endif +//address@hidden case TARGET_NR_execve: { char **argp, **envp; @@ -4300,6 +4301,7 @@ abi_long do_syscall(void *cpu_env, int n
abi_ulong guest_envp; abi_ulong addr; char **q; + int i=0;
argc = 0; guest_argp = arg2; @@ -4320,10 +4322,26 @@ abi_long do_syscall(void *cpu_env, int n
envc++; }
- argp = alloca((argc + 1) * sizeof(void *)); - envp = alloca((envc + 1) * sizeof(void *)); + if(do_strace) + { + i=2;
+ //add one more element to argc that is the path of the qemu-i386 + argp = alloca((argc + 3) * sizeof(void *)); + envp = alloca((envc + 1) * sizeof(void *)); + //put path of qemu-i386 as first element of argp and "-strace" as second
+ *argp=file_path; + *(argp+1)=(char *)"-strace"; + } + else{ + i=1; + //add one more element to argc that is the path of the qemu-i386 + argp = alloca((argc + 2) * sizeof(void *));
+ envp = alloca((envc + 1) * sizeof(void *)); + //put path of qemu-i386 as first element of argp + *argp=file_path; + }
- for (gp = guest_argp, q = argp; gp;
+ for (gp = guest_argp, q = argp+i; gp; gp += sizeof(abi_ulong), q++) { if (get_user_ual(addr, gp)) goto execve_efault; @@ -4347,7 +4365,14 @@ abi_long do_syscall(void *cpu_env, int n
if (!(p = lock_user_string(arg1))) goto execve_efault; - ret = get_errno(execve(p, argp, envp)); + + //put in position i the name of program to execute
+ *(argp+i)=p; + printf("\nA new instance of QEMU-i386 will execute\n"); + printf("the program called by the instruction exec\n\n"); + ret = get_errno(execve(file_path, argp, envp));
+ printf("\nThe execve was not executed well!!!!!\n\n"); + unlock_user(p, arg1, 0);
goto execve_end; @@ -4372,6 +4397,7 @@ abi_long do_syscall(void *cpu_env, int n
} } break; +//address@hidden case TARGET_NR_chdir: if (!(p = lock_user_string(arg1))) goto efault;