Index: third_party/afl/src/qemu_mode/patches/syscall.diff |
diff --git a/third_party/afl/src/qemu_mode/patches/syscall.diff b/third_party/afl/src/qemu_mode/patches/syscall.diff |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75d39386164eef7501298442c82083849649dc70 |
--- /dev/null |
+++ b/third_party/afl/src/qemu_mode/patches/syscall.diff |
@@ -0,0 +1,25 @@ |
+--- qemu-2.3.0/linux-user/syscall.c.orig 2014-12-09 14:45:43.000000000 +0000 |
++++ qemu-2.3.0/linux-user/syscall.c 2015-03-27 06:33:00.736000000 +0000 |
+@@ -227,7 +227,21 @@ |
+ _syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo) |
+ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len) |
+ #if defined(TARGET_NR_tgkill) && defined(__NR_tgkill) |
+-_syscall3(int,sys_tgkill,int,tgid,int,pid,int,sig) |
++ |
++extern unsigned int afl_forksrv_pid; |
++ |
++static int sys_tgkill(int tgid, int pid, int sig) { |
++ |
++ /* Workaround for -lpthread to make abort() work properly, without |
++ killing the forkserver due to a prematurely cached PID. */ |
++ |
++ if (afl_forksrv_pid && afl_forksrv_pid == pid && sig == SIGABRT) |
++ pid = tgid = getpid(); |
++ |
++ return syscall(__NR_sys_tgkill, pid, tgid, sig); |
++ |
++} |
++ |
+ #endif |
+ #if defined(TARGET_NR_tkill) && defined(__NR_tkill) |
+ _syscall2(int,sys_tkill,int,tid,int,sig) |