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