summaryrefslogtreecommitdiff
path: root/lib/std/syscall+linux-x64.s
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-08-28 19:33:46 -0700
committerOri Bernstein <ori@eigenstate.org>2015-08-28 19:34:45 -0700
commit7e3d48053773f02748160f3ac7fe60cdb1bb2971 (patch)
treeb4f44b6f0d70b9fb78cde620439e0119fd5d418f /lib/std/syscall+linux-x64.s
parent7deb877757f34da0a6f8fce8b2d5b5ae07178429 (diff)
downloadmc-7e3d48053773f02748160f3ac7fe60cdb1bb2971.tar.gz
Add fnclone wrapper.
Since the stack goes away, we need to ensure that the function on the stack doesn't.
Diffstat (limited to 'lib/std/syscall+linux-x64.s')
-rw-r--r--lib/std/syscall+linux-x64.s27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/std/syscall+linux-x64.s b/lib/std/syscall+linux-x64.s
index f7c020d..53291cb 100644
--- a/lib/std/syscall+linux-x64.s
+++ b/lib/std/syscall+linux-x64.s
@@ -20,3 +20,30 @@ sys$syscall:
ret
+/* clone(flags, stack, ptid, tls, ctid, regs) */
+.globl sys$fnclone
+sys$fnclone:
+ pushq %r15
+ /* %rsp is modified by clone(), so it's saved here */
+ movq 16(%rsp),%r15
+ /*
+ %rdi: flags, %rsi: stack, %rdx: ptid,
+ %rcx: tls, %r8: ctid, %r9: regs
+ */
+ movq $56,%rax /* syscall num */
+ movq %rcx,%r10 /* tls */
+ syscall
+
+ /* fn() */
+ testl %eax,%eax
+ jnz parent
+ call *%r15
+
+ /* exit(0) */
+ movq $60, %rax /* exit */
+ movq $0, %rdi /* arg: 0 */
+ syscall
+
+parent:
+ popq %r15
+ ret