summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/cris/crt0.S
blob: 5b5834028d563a40e34e8e837fc9168c6c4a2111 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;; Startup code compiant to the ELF CRIS ABI.
;;
;; Highly based on code from glibc.

#include <sysdep.h>

	.syntax no_register_prefix

	.text
	.globl	_start
	.type	_start,@function

#if defined L_crt0 || ! defined __UCLIBC_CTOR_DTOR__
	.type	__uClibc_main,@function
#else
	.weak	_init
	.weak	_fini
	.type	__uClibc_start_main,@function
#endif

	;; Setup a dummy reference to main so that if an application is linking
	;; when the main() function is in a static library we can be sure that
	;; the main() actually gets linked in.
	.type main,@function

_start:
	;; Clear the frame pointer, to mark the outermost frame.
	moveq	0, r8

	move.d	[sp],r11
	move.d	sp,[sp]
	move.d	sp,r12
	addq	4,r12
	push	r9

#ifdef __PIC__
	move.d	pc,r0
	sub.d	.:GOTOFF,r0
	move.d	_init:PLTG,r13
	add.d	r0,r13
	move.d	_fini:PLTG,r9
	add.d	r0,r9
	move.d	main:PLTG,r10
	add.d	r0,r10
#else
	move.d	_init,r13
	move.d	_fini,r9
	move.d	main,r10
#endif

	push r9

#if (defined L_crt1 || defined L_gcrt1) && defined __UCLIBC_CTOR_DTOR__
	PLTCALL(__uClibc_start_main)
#else
	PLTCALL(__uClibc_main)
#endif

	;; Crash if 'exit' returns.
	test.d	[6502]
0:
	ba 0b
	nop

/* Define a symbol for the first piece of initialized data.  */
	.data
	.globl __data_start
__data_start:
	.long 0
	.weak data_start
	data_start = __data_start