-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.S
More file actions
157 lines (136 loc) · 3.42 KB
/
Copy pathstart.S
File metadata and controls
157 lines (136 loc) · 3.42 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* Relocate before C and seed the guard before stack-protected calls */
.section .note.GNU-stack,"",%progbits
.text
#if defined(__x86_64__)
.globl _start
.type _start, @function
_start:
xorq %rbp, %rbp
andq $-16, %rsp
leaq __ehdr_start(%rip), %rdi
call InitSelfRelocate
call InitGuardSeed
call InitMain
hlt
.size _start, .-_start
.globl InitSigRestore
.type InitSigRestore, @function
InitSigRestore:
movq $15, %rax /* SYS_rt_sigreturn */
syscall
.size InitSigRestore, .-InitSigRestore
#elif defined(__i386__)
.globl _start
.type _start, @function
_start:
xorl %ebp, %ebp
call 1f
1: popl %eax
addl $(__ehdr_start - 1b), %eax
andl $-16, %esp
subl $12, %esp
pushl %eax
call InitSelfRelocate
addl $16, %esp
andl $-16, %esp
subl $12, %esp
pushl $0
call InitGuardSeed
call InitMain
hlt
.size _start, .-_start
.globl InitSigRestore
.type InitSigRestore, @function
InitSigRestore:
movl $173, %eax /* SYS_rt_sigreturn */
int $0x80
.size InitSigRestore, .-InitSigRestore
#elif defined(__aarch64__)
.globl _start
.type _start, %function
_start:
mov x29, #0
mov x30, #0
adrp x0, __ehdr_start
add x0, x0, :lo12:__ehdr_start
bl InitSelfRelocate
bl InitGuardSeed
bl InitMain
brk #0
.size _start, .-_start
.globl InitSigRestore
.type InitSigRestore, %function
InitSigRestore:
mov x8, #139 /* SYS_rt_sigreturn */
svc #0
.size InitSigRestore, .-InitSigRestore
#elif defined(__riscv) && __riscv_xlen == 64
.globl _start
.type _start, @function
_start:
/* Initialize gp before relaxed access without relaxing this sequence */
.option push
.option norelax
lla gp, __global_pointer$
.option pop
mv s0, zero
mv ra, zero
lla a0, __ehdr_start
call InitSelfRelocate
call InitGuardSeed
call InitMain
ebreak
.size _start, .-_start
#elif defined(__loongarch__) && __loongarch_grlen == 64
.globl _start
.type _start, @function
_start:
move $fp, $zero
move $ra, $zero
la.pcrel $a0, __ehdr_start
bl InitSelfRelocate
bl InitGuardSeed
bl InitMain
break 0
.size _start, .-_start
#elif defined(__arm__)
.globl _start
.type _start, %function
_start:
mov fp, #0
ldr r0, .Lehdr_off
.Lehdr_pc:
add r0, pc, r0
bl InitSelfRelocate
bl InitGuardSeed
bl InitMain
.Lhang:
b .Lhang
.Lehdr_off:
.word __ehdr_start - (.Lehdr_pc + 8)
.size _start, .-_start
.globl InitSigRestore
.type InitSigRestore, %function
InitSigRestore:
mov r7, #173 /* SYS_rt_sigreturn */
svc #0
.size InitSigRestore, .-InitSigRestore
#include "armv6-div.S"
#elif defined(__mips__) && _MIPS_SIM == _ABIO32
.globl _start
.type _start, @function
_start:
move $fp, $zero
move $ra, $zero
/* Reserve the o32 callee argument area for a0-a3 spills */
addiu $sp, $sp, -32
lui $a0, %hi(__ehdr_start)
addiu $a0, $a0, %lo(__ehdr_start)
jal InitSelfRelocate
jal InitGuardSeed
jal InitMain
break
.size _start, .-_start
#else
#error "unsupported architecture"
#endif