-
Notifications
You must be signed in to change notification settings - Fork 2
/
_start.s
50 lines (42 loc) · 940 Bytes
/
_start.s
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
/* Entry point for bare metal programs */
.section .text.start
.global _start
.type _start, @function
_start:
/* initialize global pointer */
.option push
.option norelax
1: auipc gp, %pcrel_hi(__global_pointer$)
addi gp, gp, %pcrel_lo(1b)
.option pop
/* initialize stack pointer */
la sp, _sp
/* set vector table address and vectored mode */
la a0, __vector_start
ori a0, a0, 0x1
csrw mtvec, a0
/* clear the bss segment */
la a0, __bss_start
la a2, __bss_end
sub a2, a2, a0
li a1, 0
call memset
/* new-style constructors and destructors */
la a0, __libc_fini_array
call atexit
call __libc_init_array
/* call main */
call main
tail exit
.size _start, .-_start
.global _init
.type _init, @function
.global _fini
.type _fini, @function
_init:
_fini:
/* These don't have to do anything since we use init_array/fini_array. Prevent
missing symbol error */
ret
.size _init, .-_init
.size _fini, .-_fini