1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 .section .text
23 .global _start
24 _start:
25
26
27
28
29 mov x20, sp
30 ldr x10, [x20]
31 add x20, x20, #16
32 mov x28, #-1
33 .next_action:
34 ldr x11, [x20]
35 and x12, x11, #-17
36 cbz x12, .open_file
37 cmp x12, #3
38 beq .rest_of_exec
39 cmp x12, #4
40 beq .do_mmap_anon
41 .do_mmap:
42 ldr x0, [x20, 8]
43 ldr x1, [x20, 32]
44 ldr x2, [x20, 24]
45 ldr x3, [x20, 40]
46 tst x11, #16
47 mov x4, x29
48 beq .do_mmap_1
49 mov x4, x28
50 .do_mmap_1:
51 mov x8, #222
52 ldr x5, [x20, 16]
53 svc #0
54 ldr x9, [x20, 8]
55 cmp x0, x9
56 bne .perror
57 ldr x3, [x20, 48]
58 add x1, x1, x0
59 sub x3, x1, x3
60 mov x0, #0
61 .fill64:
62 sub x2, x1, x3
63 cmp x2, #63
64 ble .fillb
65 stp x0, x0, [x3]
66 stp x0, x0, [x3, 16]
67 stp x0, x0, [x3, 32]
68 stp x0, x0, [x3, 48]
69 add x3, x3, #64
70 b .fill64
71 .fillb:
72 cmp x1, x3
73 beq .continue
74 strb w0, [x3], #1
75 b .fillb
76 .continue:
77 add x20, x20, #56
78 b .next_action
79 .do_mmap_anon:
80 ldr x0, [x20, 8]
81 ldr x1, [x20, 32]
82 ldr x2, [x20, 24]
83 ldr x3, [x20, 40]
84 mov x4, #-1
85 b .do_mmap_1
86 .open_file:
87 mov x8, #56
88 mov x0, #-100
89 add x1, x20, #8
90 mov x2, #0
91 mov x3, #0
92 svc #0
93 cmp x0, #-1
94 ble .perror
95 mov x19, x1
96 .nextc:
97 ldrb w2, [x1], #1
98 cmp w2, #47
99 bne .nextc1
100 mov x19, x1
101 .nextc1:
102 cbnz w2, .nextc
103 add x1, x1, #7
104 and x20, x1, #-8
105 tst x11, #16
106 bne .secondary
107 mov x29, x0
108 mov x8, #167
109 mov x0, #15
110 mov x1, x19
111 mov x2, #0
112 mov x3, #0
113 mov x4, #0
114 mov x5, #0
115 svc #0
116 b .next_action
117 .secondary:
118 mov x28, x0
119 b .next_action
120 .perror:
121 mov x8, #93
122 mvn x0, x0
123 add x0, x0, 1
124 svc #0
125 .rest_of_exec:
126 mov x7, x20
127 mov x20, x10
128 ldr x9, [x20]
129 add x9, x9, #2
130 lsl x9, x9, #3
131 add x20, x20, x9
132 .skipenv:
133 ldr x9, [x20], #8
134 cbnz x9, .skipenv
135 .one_auxv:
136 ldr x9, [x20], #16
137 cbz x9, .cleanup
138 cmp x9, #3
139 beq .replace_phdr
140 cmp x9, #4
141 beq .replace_phent
142 cmp x9, #5
143 beq .replace_phnum
144 cmp x9, #9
145 beq .replace_entry
146 cmp x9, #7
147 beq .replace_base
148 b .one_auxv
149 .replace_phdr:
150 ldr x9, [x7, 40]
151 str x9, [x20, -8]
152 b .one_auxv
153 .replace_phent:
154 ldr x9, [x7, 24]
155 str x9, [x20, -8]
156 b .one_auxv
157 .replace_phnum:
158 ldr x9, [x7, 32]
159 str x9, [x20, -8]
160 b .one_auxv
161 .replace_entry:
162 ldr x9, [x7, 16]
163 str x9, [x20, -8]
164 b .one_auxv
165 .replace_base:
166 ldr x9, [x7, 48]
167 str x9, [x20, -8]
168 b .one_auxv
169 .cleanup:
170 cmp x28, #-1
171 bne .cleanup1
172 mov x8, #57
173 mov x0, x28
174 svc #0
175 .cleanup1:
176 mov x8, #57
177 mov x0, x29
178 svc #0
179 .enter:
180 mov sp, x10
181 mov x0, #0
182 ldr x1, [x7, 8]
183 br x1
184
185 timespec:
186 .quad 10
187 .quad 10