vfork 挂掉的一个问题拓展实验二 (子进程使用exit退出时候的栈帧)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void) {
    int var;
    var = 88;
    if ((pid = vfork()) < 0) {
        printf("vfork error");
        exit(-1);
    } else if (pid == 0) { /* 子进程 */
        var++;
        exit(0);
    }
    printf("pid=%d, glob=%d, var=%d\n", getpid(), glob, var);
    return 0;
}

vfork_exit:     file format elf32-i386


Disassembly of section .init:

080482f4 <_init>:
 80482f4:	55                   	push   %ebp
 80482f5:	89 e5                	mov    %esp,%ebp
 80482f7:	53                   	push   %ebx
 80482f8:	83 ec 04             	sub    $0x4,%esp
 80482fb:	e8 00 00 00 00       	call   8048300 <_init+0xc>
 8048300:	5b                   	pop    %ebx
 8048301:	81 c3 f4 1c 00 00    	add    $0x1cf4,%ebx
 8048307:	8b 93 fc ff ff ff    	mov    -0x4(%ebx),%edx
 804830d:	85 d2                	test   %edx,%edx
 804830f:	74 05                	je     8048316 <_init+0x22>
 8048311:	e8 2e 00 00 00       	call   8048344 <__gmon_start__@plt>
 8048316:	e8 15 01 00 00       	call   8048430 <frame_dummy>
 804831b:	e8 20 02 00 00       	call   8048540 <__do_global_ctors_aux>
 8048320:	58                   	pop    %eax
 8048321:	5b                   	pop    %ebx
 8048322:	c9                   	leave  
 8048323:	c3                   	ret    

Disassembly of section .plt:

08048324 <getpid@plt-0x10>:
 8048324:	ff 35 f8 9f 04 08    	pushl  0x8049ff8
 804832a:	ff 25 fc 9f 04 08    	jmp    *0x8049ffc
 8048330:	00 00                	add    %al,(%eax)
	...

08048334 <getpid@plt>:
 8048334:	ff 25 00 a0 04 08    	jmp    *0x804a000
 804833a:	68 00 00 00 00       	push   $0x0
 804833f:	e9 e0 ff ff ff       	jmp    8048324 <_init+0x30>

08048344 <__gmon_start__@plt>:
 8048344:	ff 25 04 a0 04 08    	jmp    *0x804a004
 804834a:	68 08 00 00 00       	push   $0x8
 804834f:	e9 d0 ff ff ff       	jmp    8048324 <_init+0x30>

08048354 <__libc_start_main@plt>:
 8048354:	ff 25 08 a0 04 08    	jmp    *0x804a008
 804835a:	68 10 00 00 00       	push   $0x10
 804835f:	e9 c0 ff ff ff       	jmp    8048324 <_init+0x30>

08048364 <vfork@plt>:
 8048364:	ff 25 0c a0 04 08    	jmp    *0x804a00c
 804836a:	68 18 00 00 00       	push   $0x18
 804836f:	e9 b0 ff ff ff       	jmp    8048324 <_init+0x30>

08048374 <printf@plt>:
 8048374:	ff 25 10 a0 04 08    	jmp    *0x804a010
 804837a:	68 20 00 00 00       	push   $0x20
 804837f:	e9 a0 ff ff ff       	jmp    8048324 <_init+0x30>

08048384 <exit@plt>:
 8048384:	ff 25 14 a0 04 08    	jmp    *0x804a014
 804838a:	68 28 00 00 00       	push   $0x28
 804838f:	e9 90 ff ff ff       	jmp    8048324 <_init+0x30>

Disassembly of section .text:

080483a0 <_start>:
 80483a0:	31 ed                	xor    %ebp,%ebp
 80483a2:	5e                   	pop    %esi
 80483a3:	89 e1                	mov    %esp,%ecx
 80483a5:	83 e4 f0             	and    $0xfffffff0,%esp
 80483a8:	50                   	push   %eax
 80483a9:	54                   	push   %esp
 80483aa:	52                   	push   %edx
 80483ab:	68 d0 84 04 08       	push   $0x80484d0
 80483b0:	68 e0 84 04 08       	push   $0x80484e0
 80483b5:	51                   	push   %ecx
 80483b6:	56                   	push   %esi
 80483b7:	68 54 84 04 08       	push   $0x8048454
 80483bc:	e8 93 ff ff ff       	call   8048354 <__libc_start_main@plt>
 80483c1:	f4                   	hlt    
 80483c2:	90                   	nop
 80483c3:	90                   	nop
 80483c4:	90                   	nop
 80483c5:	90                   	nop
 80483c6:	90                   	nop
 80483c7:	90                   	nop
 80483c8:	90                   	nop
 80483c9:	90                   	nop
 80483ca:	90                   	nop
 80483cb:	90                   	nop
 80483cc:	90                   	nop
 80483cd:	90                   	nop
 80483ce:	90                   	nop
 80483cf:	90                   	nop

080483d0 <__do_global_dtors_aux>:
 80483d0:	55                   	push   %ebp
 80483d1:	89 e5                	mov    %esp,%ebp
 80483d3:	53                   	push   %ebx
 80483d4:	83 ec 04             	sub    $0x4,%esp
 80483d7:	80 3d 20 a0 04 08 00 	cmpb   $0x0,0x804a020
 80483de:	75 3f                	jne    804841f <__do_global_dtors_aux+0x4f>
 80483e0:	a1 24 a0 04 08       	mov    0x804a024,%eax
 80483e5:	bb 20 9f 04 08       	mov    $0x8049f20,%ebx
 80483ea:	81 eb 1c 9f 04 08    	sub    $0x8049f1c,%ebx
 80483f0:	c1 fb 02             	sar    $0x2,%ebx
 80483f3:	83 eb 01             	sub    $0x1,%ebx
 80483f6:	39 d8                	cmp    %ebx,%eax
 80483f8:	73 1e                	jae    8048418 <__do_global_dtors_aux+0x48>
 80483fa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 8048400:	83 c0 01             	add    $0x1,%eax
 8048403:	a3 24 a0 04 08       	mov    %eax,0x804a024
 8048408:	ff 14 85 1c 9f 04 08 	call   *0x8049f1c(,%eax,4)
 804840f:	a1 24 a0 04 08       	mov    0x804a024,%eax
 8048414:	39 d8                	cmp    %ebx,%eax
 8048416:	72 e8                	jb     8048400 <__do_global_dtors_aux+0x30>
 8048418:	c6 05 20 a0 04 08 01 	movb   $0x1,0x804a020
 804841f:	83 c4 04             	add    $0x4,%esp
 8048422:	5b                   	pop    %ebx
 8048423:	5d                   	pop    %ebp
 8048424:	c3                   	ret    
 8048425:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 8048429:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

08048430 <frame_dummy>:
 8048430:	55                   	push   %ebp
 8048431:	89 e5                	mov    %esp,%ebp
 8048433:	83 ec 18             	sub    $0x18,%esp
 8048436:	a1 24 9f 04 08       	mov    0x8049f24,%eax
 804843b:	85 c0                	test   %eax,%eax
 804843d:	74 12                	je     8048451 <frame_dummy+0x21>
 804843f:	b8 00 00 00 00       	mov    $0x0,%eax
 8048444:	85 c0                	test   %eax,%eax
 8048446:	74 09                	je     8048451 <frame_dummy+0x21>
 8048448:	c7 04 24 24 9f 04 08 	movl   $0x8049f24,(%esp)
 804844f:	ff d0                	call   *%eax
 8048451:	c9                   	leave  
 8048452:	c3                   	ret    
 8048453:	90                   	nop

08048454 <main>:
 8048454:	55                   	push   %ebp
 8048455:	89 e5                	mov    %esp,%ebp
 8048457:	83 e4 f0             	and    $0xfffffff0,%esp
 804845a:	83 ec 20             	sub    $0x20,%esp
 804845d:	c7 44 24 1c 58 00 00 	movl   $0x58,0x1c(%esp)
 8048464:	00 
 8048465:	e8 fa fe ff ff       	call   8048364 <vfork@plt>
 804846a:	89 44 24 18          	mov    %eax,0x18(%esp)
 804846e:	83 7c 24 18 00       	cmpl   $0x0,0x18(%esp)
 8048473:	79 19                	jns    804848e <main+0x3a>
 8048475:	b8 90 85 04 08       	mov    $0x8048590,%eax
 804847a:	89 04 24             	mov    %eax,(%esp)
 804847d:	e8 f2 fe ff ff       	call   8048374 <printf@plt>
 8048482:	c7 04 24 ff ff ff ff 	movl   $0xffffffff,(%esp)
 8048489:	e8 f6 fe ff ff       	call   8048384 <exit@plt>
 804848e:	83 7c 24 18 00       	cmpl   $0x0,0x18(%esp)
 8048493:	75 11                	jne    80484a6 <main+0x52> 
 8048495:	83 44 24 1c 01       	addl   $0x1,0x1c(%esp)
 804849a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 80484a1:	e8 de fe ff ff       	call   8048384 <exit@plt>	!跳转到exit函数,不破坏父进程栈帧
 80484a6:	e8 89 fe ff ff       	call   8048334 <getpid@plt>
 80484ab:	ba 9c 85 04 08       	mov    $0x804859c,%edx
 80484b0:	8b 4c 24 1c          	mov    0x1c(%esp),%ecx
 80484b4:	89 4c 24 08          	mov    %ecx,0x8(%esp)
 80484b8:	89 44 24 04          	mov    %eax,0x4(%esp)
 80484bc:	89 14 24             	mov    %edx,(%esp)
 80484bf:	e8 b0 fe ff ff       	call   8048374 <printf@plt>
 80484c4:	b8 00 00 00 00       	mov    $0x0,%eax
 80484c9:	c9                   	leave  
 80484ca:	c3                   	ret    
 80484cb:	90                   	nop
 80484cc:	90                   	nop
 80484cd:	90                   	nop
 80484ce:	90                   	nop
 80484cf:	90                   	nop

080484d0 <__libc_csu_fini>:
 80484d0:	55                   	push   %ebp
 80484d1:	89 e5                	mov    %esp,%ebp
 80484d3:	5d                   	pop    %ebp
 80484d4:	c3                   	ret    
 80484d5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
 80484d9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

080484e0 <__libc_csu_init>:
 80484e0:	55                   	push   %ebp
 80484e1:	89 e5                	mov    %esp,%ebp
 80484e3:	57                   	push   %edi
 80484e4:	56                   	push   %esi
 80484e5:	53                   	push   %ebx
 80484e6:	e8 4f 00 00 00       	call   804853a <__i686.get_pc_thunk.bx>
 80484eb:	81 c3 09 1b 00 00    	add    $0x1b09,%ebx
 80484f1:	83 ec 1c             	sub    $0x1c,%esp
 80484f4:	e8 fb fd ff ff       	call   80482f4 <_init>
 80484f9:	8d bb 20 ff ff ff    	lea    -0xe0(%ebx),%edi
 80484ff:	8d 83 20 ff ff ff    	lea    -0xe0(%ebx),%eax
 8048505:	29 c7                	sub    %eax,%edi
 8048507:	c1 ff 02             	sar    $0x2,%edi
 804850a:	85 ff                	test   %edi,%edi
 804850c:	74 24                	je     8048532 <__libc_csu_init+0x52>
 804850e:	31 f6                	xor    %esi,%esi
 8048510:	8b 45 10             	mov    0x10(%ebp),%eax
 8048513:	89 44 24 08          	mov    %eax,0x8(%esp)
 8048517:	8b 45 0c             	mov    0xc(%ebp),%eax
 804851a:	89 44 24 04          	mov    %eax,0x4(%esp)
 804851e:	8b 45 08             	mov    0x8(%ebp),%eax
 8048521:	89 04 24             	mov    %eax,(%esp)
 8048524:	ff 94 b3 20 ff ff ff 	call   *-0xe0(%ebx,%esi,4)
 804852b:	83 c6 01             	add    $0x1,%esi
 804852e:	39 fe                	cmp    %edi,%esi
 8048530:	72 de                	jb     8048510 <__libc_csu_init+0x30>
 8048532:	83 c4 1c             	add    $0x1c,%esp
 8048535:	5b                   	pop    %ebx
 8048536:	5e                   	pop    %esi
 8048537:	5f                   	pop    %edi
 8048538:	5d                   	pop    %ebp
 8048539:	c3                   	ret    

0804853a <__i686.get_pc_thunk.bx>:
 804853a:	8b 1c 24             	mov    (%esp),%ebx
 804853d:	c3                   	ret    
 804853e:	90                   	nop
 804853f:	90                   	nop

08048540 <__do_global_ctors_aux>:
 8048540:	55                   	push   %ebp
 8048541:	89 e5                	mov    %esp,%ebp
 8048543:	53                   	push   %ebx
 8048544:	83 ec 04             	sub    $0x4,%esp
 8048547:	a1 14 9f 04 08       	mov    0x8049f14,%eax
 804854c:	83 f8 ff             	cmp    $0xffffffff,%eax
 804854f:	74 13                	je     8048564 <__do_global_ctors_aux+0x24>
 8048551:	bb 14 9f 04 08       	mov    $0x8049f14,%ebx
 8048556:	66 90                	xchg   %ax,%ax
 8048558:	83 eb 04             	sub    $0x4,%ebx
 804855b:	ff d0                	call   *%eax
 804855d:	8b 03                	mov    (%ebx),%eax
 804855f:	83 f8 ff             	cmp    $0xffffffff,%eax
 8048562:	75 f4                	jne    8048558 <__do_global_ctors_aux+0x18>
 8048564:	83 c4 04             	add    $0x4,%esp
 8048567:	5b                   	pop    %ebx
 8048568:	5d                   	pop    %ebp
 8048569:	c3                   	ret    
 804856a:	90                   	nop
 804856b:	90                   	nop

Disassembly of section .fini:

0804856c <_fini>:
 804856c:	55                   	push   %ebp
 804856d:	89 e5                	mov    %esp,%ebp
 804856f:	53                   	push   %ebx
 8048570:	83 ec 04             	sub    $0x4,%esp
 8048573:	e8 00 00 00 00       	call   8048578 <_fini+0xc>
 8048578:	5b                   	pop    %ebx
 8048579:	81 c3 7c 1a 00 00    	add    $0x1a7c,%ebx
 804857f:	e8 4c fe ff ff       	call   80483d0 <__do_global_dtors_aux>
 8048584:	59                   	pop    %ecx
 8048585:	5b                   	pop    %ebx
 8048586:	c9                   	leave  
 8048587:	c3                   	ret   


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值