summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/i386/start.S
blob: 167bb779ca2ed9cec4d13205f52906279075e066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "start.h"

#ifdef __i386__
.text
.globl _start
_start:
#if 0
	popl	%ecx
	movl	%esp, %esi
	leal	4(%esp,%ecx,4),%eax
#else
	movl (%esp),%ecx	/* %ecx = argc */
	leal 4(%esp),%esi	/* %esi = argv */

	leal 4(%esi,%ecx,4),%eax	/* eax = 4*ecx+4 = envp */
#endif
	pushl %eax
	pushl %esi
	pushl %ecx
	movl %eax,environ

#ifdef WANT_DYNAMIC
/* in %edx we have the dynamic _fini ( register this if non null ) */
	test	%edx, %edx
	je	.Linit
	push	%edx
	call	atexit
	pop	%edx
.Linit:
	call	_init
	push	$_fini
	call	atexit
	pop	%edx
#endif

	call main
	pushl %eax
	call exit
.Lfefe:
	.size	 _start,.Lfefe-_start
#endif