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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
Start-up code for Free Pascal Compiler, not in a shared library,
not linking with C library.
Written by Edmund Grimley Evans in 2015 and released into the public domain.
*/
.text
.align 2
.globl _dynamic_start
.type _dynamic_start, function
_dynamic_start:
lui x5,%hi(__dl_fini)
addi x5,x5,%lo(__dl_fini)
sd x10, (x5)
jal x0, _start
.globl _start
.type _start, function
_start:
1:
auipc gp, %pcrel_hi(__bss_start+0x800)
addi gp, gp, %pcrel_lo(1b)
# clear the bss segment
la t0, __bss_start
la t1, _end
2:
sd zero,0(t0)
addi t0, t0, 8
bltu t0, t1, 2b
/* Get argc, argv, envp */
ld x5,(x2)
addi x6,x2,8
addi x7,x5,1
slli x7,x7,3
add x7,x6,x7
/* Save argc, argv, envp, and initial stack pointer */
lui x8,%hi(operatingsystem_parameter_argc)
addi x8,x8,%lo(operatingsystem_parameter_argc)
sd x5,(x8)
lui x8,%hi(operatingsystem_parameter_argv)
addi x8,x8,%lo(operatingsystem_parameter_argv)
sd x6,(x8)
lui x8,%hi(operatingsystem_parameter_envp)
addi x8,x8,%lo(operatingsystem_parameter_envp)
sd x7,(x8)
lui x5,%hi(__stkptr)
addi x5,x8,%lo(__stkptr)
addi x6, x2, 0
sd x6,(x5)
/* Initialise FP to zero */
addi x8,x0,0
/* Call main */
jal x1, PASCALMAIN
.globl _haltproc
.type _haltproc,function
_haltproc:
lui x10,%hi(__dl_fini)
addi x10,x10,%lo(__dl_fini)
ld x10,(x10)
beq x10,x0,.Lexit
jalr x1,x10
.Lexit:
lui x10,%hi(operatingsystem_result)
addi x10,x10,%lo(operatingsystem_result)
ld x10,(x10)
addi x17, x0, 94
scall
jal x0, _haltproc
/* Define a symbol for the first piece of initialized data. */
.data
.align 3
.globl __data_start
__data_start:
.long 0
.weak data_start
data_start = __data_start
.bss
.align 3
.comm __dl_fini,8
.comm __stkptr,8
.comm operatingsystem_parameter_envp,8
.comm operatingsystem_parameter_argc,8
.comm operatingsystem_parameter_argv,8
.section .note.GNU-stack,"",%progbits
|