1.text 2.global __clone 3.hidden __clone 4.type __clone, @function 5__clone: 6! incoming: fn stack flags arg ptid tls ctid 7! r4 r5 r6 r7 @r15 @(4,r15) @(8,r15) 8 9 mov #-16, r0 10 and r0, r5 11 12 mov r4, r1 ! r1 = fn 13 mov r7, r2 ! r2 = arg 14 15 mov #120, r3 ! r3 = __NR_clone 16 mov r6, r4 ! r4 = flags 17 !mov r5, r5 ! r5 = stack 18 mov.l @r15, r6 ! r6 = ptid 19 mov.l @(8,r15), r7 ! r7 = ctid 20 mov.l @(4,r15), r0 ! r0 = tls 21 trapa #31 22 23 or r0, r0 24 or r0, r0 25 or r0, r0 26 or r0, r0 27 or r0, r0 28 29 cmp/eq #0, r0 30 bt 1f 31 32 ! we are the parent, return 33 rts 34 nop 35 361: ! we are the child, call fn(arg) 37 mov.l 1f, r0 38 mov r1, r5 39 bsrf r0 40 mov r2, r4 41 422: mov #1, r3 ! __NR_exit 43 mov r0, r4 44 trapa #31 45 46 or r0, r0 47 or r0, r0 48 or r0, r0 49 or r0, r0 50 or r0, r0 51 52.align 2 53.hidden __shcall 541: .long __shcall@PCREL+(.-2b) 55