1#if defined(__x86_64__) && defined(__linux__)
2
3#include "sanitizer_common/sanitizer_asm.h"
4
5.comm _ZN14__interception10real_vforkE,8,8
6.globl ASM_WRAPPER_NAME(vfork)
7ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
8ASM_WRAPPER_NAME(vfork):
9        _CET_ENDBR
10        // Store return address in the spill area and tear down the stack frame.
11        push    %rcx
12        call    COMMON_INTERCEPTOR_SPILL_AREA
13        pop     %rcx
14        pop     %rdi
15        mov     %rdi, (%rax)
16
17        call    *_ZN14__interception10real_vforkE(%rip)
18
19        // Restore return address from the spill area.
20        push    %rcx
21        push    %rax
22        call    COMMON_INTERCEPTOR_SPILL_AREA
23        mov     (%rax), %rdx
24        mov     %rdx, 8(%rsp)
25        mov     (%rsp), %rax
26
27        // Call handle_vfork in the parent process (%rax != 0).
28        test    %rax, %rax
29        je      .L_exit
30
31        lea     16(%rsp), %rdi
32        call    COMMON_INTERCEPTOR_HANDLE_VFORK@PLT
33
34.L_exit:
35        pop     %rax
36        ret
37ASM_SIZE(ASM_WRAPPER_NAME(vfork))
38
39ASM_INTERCEPTOR_TRAMPOLINE(vfork)
40ASM_TRAMPOLINE_ALIAS(vfork, vfork)
41
42#endif
43