summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/x86_64/start.S
blob: 328bbcfe3572ed37edf456b64cd391ee57fbc542 (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
#include "dietfeatures.h"

.text
.global _start
_start:
	popq	%rdi			/* %rdi = argc */
	movq	%rsp,%rsi		/* %rsi = argv */
	pushq	%rdi
	
	leaq	8(%rsi,%rdi,8),%rdx	/* %rdx = envp = (8*rdi)+%rsi+8 */

	movq	%rdx, environ

#ifdef PROFILING
	pushq	$_etext
	pushq	$.text
	call	monitor
	addq	$0x16, %rsp
#endif

#ifdef WANT_DYNAMIC
	call	_dyn_start
#else
	call	main
#endif

#ifdef PROFILING
	pushq	%rax
	call	_stop_monitor
	popq	%rdi
#else
	movq	%rax, %rdi	/* return value */
#endif
	call	exit
	hlt
.Lstart:
	.size	 _start,.Lstart-_start