github.com/afumu/libc@v0.0.6/musl/src/thread/aarch64/clone.s (about)

     1  // __clone(func, stack, flags, arg, ptid, tls, ctid)
     2  //         x0,   x1,    w2,    x3,  x4,   x5,  x6
     3  
     4  // syscall(SYS_clone, flags, stack, ptid, tls, ctid)
     5  //         x8,        x0,    x1,    x2,   x3,  x4
     6  
     7  .global __clone
     8  .hidden __clone
     9  .type   __clone,%function
    10  __clone:
    11  	// align stack and save func,arg
    12  	and x1,x1,#-16
    13  	stp x0,x3,[x1,#-16]!
    14  
    15  	// syscall
    16  	uxtw x0,w2
    17  	mov x2,x4
    18  	mov x3,x5
    19  	mov x4,x6
    20  	mov x8,#220 // SYS_clone
    21  	svc #0
    22  
    23  	cbz x0,1f
    24  	// parent
    25  	ret
    26  	// child
    27  1:	ldp x1,x0,[sp],#16
    28  	blr x1
    29  	mov x8,#93 // SYS_exit
    30  	svc #0