]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
Merge r357339 from the clang1000-import branch:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / compiler-rt / lib / sanitizer_common / sanitizer_common_interceptors_vfork_i386.inc.S
1 #if defined(__i386__) && defined(__linux__)
2
3 #include "sanitizer_common/sanitizer_asm.h"
4
5 .comm _ZN14__interception10real_vforkE,4,4
6 .globl ASM_WRAPPER_NAME(vfork)
7 ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
8 ASM_WRAPPER_NAME(vfork):
9         // Store return address in the spill area and tear down the stack frame.
10         sub     $12, %esp
11         call    COMMON_INTERCEPTOR_SPILL_AREA
12         mov     12(%esp), %ecx
13         mov     %ecx, (%eax)
14         add     $16, %esp
15
16         call    .L0$pb
17 .L0$pb:
18         pop     %eax
19 .Ltmp0:
20         add     $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
21         call    *_ZN14__interception10real_vforkE@GOTOFF(%eax)
22
23         // Restore the stack frame.
24         // 12(%esp) return address
25         // 8(%esp) spill %ebx
26         // 4(%esp) spill REAL(vfork) return value
27         // (%esp) call frame (arg0) for __*_handle_vfork
28         sub     $16, %esp
29         mov     %ebx, 8(%esp)
30         mov     %eax, 4(%esp)
31
32         // Form GOT address in %ebx.
33         call    .L1$pb
34 .L1$pb:
35         pop     %ebx
36 .Ltmp1:
37         add     $_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.L1$pb), %ebx
38
39         // Restore original return address.
40         call    COMMON_INTERCEPTOR_SPILL_AREA
41         mov     (%eax), %ecx
42         mov     %ecx, 12(%esp)
43         mov     4(%esp), %eax
44
45         // Call handle_vfork in the parent process (%rax != 0).
46         test    %eax, %eax
47         je      .L_exit
48
49         lea     16(%esp), %ecx
50         mov     %ecx, (%esp)
51         call    COMMON_INTERCEPTOR_HANDLE_VFORK@PLT
52
53 .L_exit:
54         mov     4(%esp), %eax
55         mov     8(%esp), %ebx
56         add     $12, %esp
57         ret
58 ASM_SIZE(vfork)
59
60 .weak vfork
61 .set vfork, ASM_WRAPPER_NAME(vfork)
62
63 #endif