]>
Commit | Line | Data |
---|---|---|
f5ffcb6a JR |
1 | diff -urN -x .git dietlibc-0.33/alpha/Makefile.add dietlibc/alpha/Makefile.add |
2 | --- dietlibc-0.33/alpha/Makefile.add 2012-01-24 18:24:24.000000000 +0000 | |
3 | +++ dietlibc/alpha/Makefile.add 2015-01-01 12:14:43.454938895 +0000 | |
4 | @@ -3,3 +3,5 @@ | |
5 | VPATH:=alpha:syscalls.s:$(VPATH) | |
6 | ||
7 | LIBOBJ+=$(patsubst %,$(OBJDIR)/%,divq.o divl.o remq.o reml.o __time.o __alarm.o __CAS.o) | |
8 | + | |
9 | +$(OBJDIR)/__pause.o: include/signal.h | |
10 | diff -urN -x .git dietlibc-0.33/alpha/start.S dietlibc/alpha/start.S | |
11 | --- dietlibc-0.33/alpha/start.S 2006-05-29 16:30:53.000000000 +0000 | |
12 | +++ dietlibc/alpha/start.S 2015-01-01 12:14:43.454938895 +0000 | |
13 | @@ -24,6 +24,15 @@ | |
14 | ||
15 | stq $18, environ | |
16 | ||
17 | +#ifdef WANT_ELFINFO | |
18 | +# warning "MAKE ME alpha ASSEMBLER!" | |
19 | +1: ldq $19, $18 ; load *envp into $19 | |
20 | + addq $18, 1, $18 ; increment *envp | |
21 | + orr $19, $19, $19 | |
22 | + jne 1b | |
23 | + stq $18, __elfinfo | |
24 | +#endif | |
25 | + | |
26 | #ifdef WANT_DYNAMIC | |
27 | /* in v0 ($0) is the ld.so _fini pointer */ | |
28 | mov $0, $19 /* mov v0(dynload) to a3 */ | |
29 | diff -urN -x .git dietlibc-0.33/alpha/syscalls.h dietlibc/alpha/syscalls.h | |
30 | --- dietlibc-0.33/alpha/syscalls.h 2008-05-06 17:18:34.000000000 +0000 | |
31 | +++ dietlibc/alpha/syscalls.h 2015-01-01 12:14:43.454938895 +0000 | |
32 | @@ -412,7 +412,38 @@ | |
33 | #define __NR_signalfd 476 | |
34 | #define __NR_timerfd 477 | |
35 | #define __NR_eventfd 478 | |
36 | - | |
37 | +#define __NR_recvmmsg 479 | |
38 | +#define __NR_fallocate 480 | |
39 | +#define __NR_timerfd_create 481 | |
40 | +#define __NR_timerfd_settime 482 | |
41 | +#define __NR_timerfd_gettime 483 | |
42 | +#define __NR_signalfd4 484 | |
43 | +#define __NR_eventfd2 485 | |
44 | +#define __NR_epoll_create1 486 | |
45 | +#define __NR_dup3 487 | |
46 | +#define __NR_pipe2 488 | |
47 | +#define __NR_inotify_init1 489 | |
48 | +#define __NR_preadv 490 | |
49 | +#define __NR_pwritev 491 | |
50 | +#define __NR_rt_tgsigqueueinfo 492 | |
51 | +#define __NR_perf_event_open 493 | |
52 | +#define __NR_fanotify_init 494 | |
53 | +#define __NR_fanotify_mark 495 | |
54 | +#define __NR_prlimit64 496 | |
55 | +#define __NR_name_to_handle_at 497 | |
56 | +#define __NR_open_by_handle_at 498 | |
57 | +#define __NR_clock_adjtime 499 | |
58 | +#define __NR_syncfs 500 | |
59 | +#define __NR_setns 501 | |
60 | +#define __NR_accept4 502 | |
61 | +#define __NR_sendmmsg 503 | |
62 | +#define __NR_process_vm_readv 504 | |
63 | +#define __NR_process_vm_writev 505 | |
64 | +#define __NR_kcmp 506 | |
65 | +#define __NR_finit_module 507 | |
66 | +#define __NR_sched_setattr 508 | |
67 | +#define __NR_sched_getattr 509 | |
68 | +#define __NR_renameat2 510 | |
69 | ||
70 | #define syscall_weak(name,wsym,sym) \ | |
71 | .text ; \ | |
72 | diff -urN -x .git dietlibc-0.33/arm/__aeabi_read_tp.S dietlibc/arm/__aeabi_read_tp.S | |
73 | --- dietlibc-0.33/arm/__aeabi_read_tp.S 1970-01-01 00:00:00.000000000 +0000 | |
74 | +++ dietlibc/arm/__aeabi_read_tp.S 2015-01-01 12:14:43.454938895 +0000 | |
75 | @@ -0,0 +1,13 @@ | |
76 | +#include "arm-features.h" | |
77 | + | |
78 | +FUNC_START __aeabi_read_tp | |
79 | + | |
80 | +#if __ARM_ARCH__ < 6 | |
81 | + mvn r0, #0xf000 | |
82 | + sub pc, r0, #31 | |
83 | +#else | |
84 | + mrc 15, 0, r0, cr13, cr0, 3 | |
85 | + bx lr | |
86 | +#endif | |
87 | + | |
88 | +FUNC_END __aeabi_read_tp | |
89 | diff -urN -x .git dietlibc-0.33/arm/__aeabi_unwind_cpp.S dietlibc/arm/__aeabi_unwind_cpp.S | |
90 | --- dietlibc-0.33/arm/__aeabi_unwind_cpp.S 2008-04-11 22:51:11.000000000 +0000 | |
91 | +++ dietlibc/arm/__aeabi_unwind_cpp.S 2015-01-01 12:14:43.454938895 +0000 | |
92 | @@ -1,21 +1,14 @@ | |
93 | -.text | |
94 | -.global __aeabi_unwind_cpp_pr0 | |
95 | -.hidden __aeabi_unwind_cpp_pr0 | |
96 | -.type __aeabi_unwind_cpp_pr0, %function | |
97 | +#include "arm-features.h" | |
98 | ||
99 | -.global __aeabi_unwind_cpp_pr1 | |
100 | +FUNC_START __aeabi_unwind_cpp_pr0 | |
101 | +FUNC_START __aeabi_unwind_cpp_pr1 | |
102 | +FUNC_START __aeabi_unwind_cpp_pr2 | |
103 | +.hidden __aeabi_unwind_cpp_pr0 | |
104 | .hidden __aeabi_unwind_cpp_pr1 | |
105 | -.type __aeabi_unwind_cpp_pr1, %function | |
106 | - | |
107 | -.global __aeabi_unwind_cpp_pr2 | |
108 | .hidden __aeabi_unwind_cpp_pr2 | |
109 | -.type __aeabi_unwind_cpp_pr2, %function | |
110 | ||
111 | -__aeabi_unwind_cpp_pr0: | |
112 | -__aeabi_unwind_cpp_pr1: | |
113 | -__aeabi_unwind_cpp_pr2: | |
114 | - mov pc, lr @ return from subroutine | |
115 | + RET | |
116 | ||
117 | -.size __aeabi_unwind_cpp_pr0,.-__aeabi_unwind_cpp_pr0 | |
118 | -.size __aeabi_unwind_cpp_pr1,.-__aeabi_unwind_cpp_pr1 | |
119 | -.size __aeabi_unwind_cpp_pr2,.-__aeabi_unwind_cpp_pr2 | |
120 | +FUNC_END __aeabi_unwind_cpp_pr2 | |
121 | +FUNC_END __aeabi_unwind_cpp_pr1 | |
122 | +FUNC_END __aeabi_unwind_cpp_pr0 | |
123 | diff -urN -x .git dietlibc-0.33/arm/arm-features.h dietlibc/arm/arm-features.h | |
124 | --- dietlibc-0.33/arm/arm-features.h 1970-01-01 00:00:00.000000000 +0000 | |
125 | +++ dietlibc/arm/arm-features.h 2015-01-01 12:14:43.454938895 +0000 | |
126 | @@ -0,0 +1,110 @@ | |
127 | +/* --*- asm -*-- */ | |
128 | + | |
129 | +#ifndef H_DIETLIBC_ARM_FEATURES_H | |
130 | +#define H_DIETLIBC_ARM_FEATURES_H | |
131 | + | |
132 | +/* Stolen from gcc (gcc/config/arm/lib1funcs.asm) */ | |
133 | +#if defined(__ARM_ARCH_2__) | |
134 | +# define __ARM_ARCH__ 2 | |
135 | +#endif | |
136 | + | |
137 | +#if defined(__ARM_ARCH_3__) | |
138 | +# define __ARM_ARCH__ 3 | |
139 | +#endif | |
140 | + | |
141 | +#if defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__) \ | |
142 | + || defined(__ARM_ARCH_4T__) | |
143 | +# define __ARM_ARCH__ 4 | |
144 | +#endif | |
145 | + | |
146 | +#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \ | |
147 | + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \ | |
148 | + || defined(__ARM_ARCH_5TEJ__) | |
149 | +# define __ARM_ARCH__ 5 | |
150 | +#endif | |
151 | + | |
152 | +#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \ | |
153 | + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \ | |
154 | + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \ | |
155 | + || defined(__ARM_ARCH_6M__) | |
156 | +# define __ARM_ARCH__ 6 | |
157 | +#endif | |
158 | + | |
159 | +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \ | |
160 | + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) | |
161 | +# define __ARM_ARCH__ 7 | |
162 | +#endif | |
163 | + | |
164 | +#ifndef __ARM_ARCH__ | |
165 | +#error Unable to determine architecture. | |
166 | +#endif | |
167 | + | |
168 | +#define DIET_JMPBUFSZ_REGS_REGULAR 10*32/8 /* r4-r11, sp, pc */ | |
169 | +#define DIET_JMPBUFSZ_REGS_FPv4 16*64/8 /* d0-d15 */ | |
170 | + | |
171 | +#if !defined(__SOFTFP__) || defined(__IWMMXT__) | |
172 | +# define DIET_HAVE_COPROC_REGS 1 | |
173 | +#else | |
174 | +# undef DIET_HAVE_COPROC_REGS | |
175 | +#endif | |
176 | + | |
177 | +#ifdef __ASSEMBLER__ | |
178 | + | |
179 | +.macro FUNC_START name | |
180 | + .text | |
181 | + .align 0 | |
182 | + .global \name | |
183 | + .type \name, %function | |
184 | +\name: | |
185 | +.endm | |
186 | + | |
187 | +.macro FUNC_START_WEAK name | |
188 | + .text | |
189 | + .align 0 | |
190 | + .weak \name | |
191 | + .type \name, %function | |
192 | +\name: | |
193 | +.endm | |
194 | + | |
195 | +.macro FUNC_END name | |
196 | + .size \name, . - \name | |
197 | +.endm | |
198 | + | |
199 | +.macro RET | |
200 | +#if (__ARM_ARCH__ > 4) || defined(__ARM_ARCH_4T__) | |
201 | + bx lr | |
202 | +#else | |
203 | + mov pc, lr | |
204 | +#endif | |
205 | +.endm | |
206 | + | |
207 | +.macro SWI_UNIFIED name | |
208 | +#ifdef __ARM_EABI__ | |
209 | + b __unified_syscall_swi | |
210 | +#else | |
211 | + swi \name | |
212 | + b __unified_syscall | |
213 | +#endif | |
214 | +.endm | |
215 | + | |
216 | +.macro SWI_UNIFIED4 | |
217 | +#ifdef __ARM_EABI__ | |
218 | + b __unified_syscall_swi | |
219 | +#else | |
220 | + swi \name | |
221 | + b __unified_syscall4 | |
222 | +#endif | |
223 | +.endm | |
224 | + | |
225 | +.macro LOAD_ARG4_5 | |
226 | +#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_5T__) | |
227 | + ldr r4, [sp,#16] | |
228 | + ldr r5, [sp,#20] | |
229 | +#else | |
230 | + ldrd r4, [sp,#16] | |
231 | +#endif | |
232 | +.endm | |
233 | + | |
234 | +#endif /* __ASSEMBLER__ */ | |
235 | + | |
236 | +#endif /* H_DIETLIBC_ARM_FEATURES_H */ | |
237 | diff -urN -x .git dietlibc-0.33/arm/arm_set_tls.S dietlibc/arm/arm_set_tls.S | |
238 | --- dietlibc-0.33/arm/arm_set_tls.S 1970-01-01 00:00:00.000000000 +0000 | |
239 | +++ dietlibc/arm/arm_set_tls.S 2015-01-01 12:14:43.454938895 +0000 | |
240 | @@ -0,0 +1,27 @@ | |
241 | +#include "syscalls.h" | |
242 | +#include "arm-features.h" | |
243 | + | |
244 | +#ifdef __ARM_EABI__ | |
245 | + | |
246 | +@ Calling convention: | |
247 | +@ r0 ... thread data | |
248 | +@ Returns: | |
249 | +@ r0 ... low-level error code | |
250 | +FUNC_START __arm_set_tls | |
251 | + mov ip, r7 | |
252 | + ldr r7, =__ARM_NR_set_tls | |
253 | + swi 0 | |
254 | + mov r7, ip | |
255 | + | |
256 | + @ we do not have much options here to handle errors because | |
257 | + @ errno might not be available yet. Return error code as-is | |
258 | + @ and let it handle by the caller | |
259 | + | |
260 | + RET | |
261 | +FUNC_END __arm_set_tls | |
262 | + | |
263 | +#else | |
264 | + | |
265 | +#warning "setup-tls only implemented for ARM_EABI!" | |
266 | + | |
267 | +#endif | |
268 | diff -urN -x .git dietlibc-0.33/arm/clone.S dietlibc/arm/clone.S | |
269 | --- dietlibc-0.33/arm/clone.S 2008-12-10 20:00:58.000000000 +0000 | |
270 | +++ dietlibc/arm/clone.S 2015-01-01 12:14:43.454938895 +0000 | |
271 | @@ -1,11 +1,7 @@ | |
272 | - | |
273 | #include <errno.h> | |
274 | #include "syscalls.h" | |
275 | +#include "arm-features.h" | |
276 | ||
277 | - .text | |
278 | - .weak clone | |
279 | - .global __clone | |
280 | - | |
281 | @ | |
282 | @ Some slightly tricky stuff here... edit with care :-) | |
283 | @ | |
284 | @@ -15,13 +11,12 @@ | |
285 | ||
286 | #define CLONE_VM 0x00000100 | |
287 | #define CLONE_THREAD 0x00010000 | |
288 | - | |
289 | + | |
290 | @ ; don't do this yet | |
291 | @#define RESET_PID | |
292 | ||
293 | - | |
294 | -clone: | |
295 | -__clone: | |
296 | +FUNC_START_WEAK clone | |
297 | +FUNC_START __clone | |
298 | @ ; start with a sanity check | |
299 | cmp r0, #0 | |
300 | cmpne r1, #0 | |
301 | @@ -31,13 +26,13 @@ | |
302 | @ ; insert args into stack | |
303 | str r3, [r1, #-4]! | |
304 | str r0, [r1, #-4]! | |
305 | - | |
306 | + | |
307 | @ ; do the system call | |
308 | @ ; get the flags | |
309 | mov r0, r2 | |
310 | -#ifdef RESET_PID | |
311 | +#ifdef RESET_PID | |
312 | mov ip, r2 | |
313 | -#endif | |
314 | +#endif | |
315 | @ ; child sp is already in r1 | |
316 | stmfd sp!, {r4, r7} | |
317 | @stmdb sp!, {r4, r7} | |
318 | @@ -46,14 +41,14 @@ | |
319 | ldr r4, [sp, #16] | |
320 | ldr r7, =__NR_clone | |
321 | swi 0 | |
322 | - | |
323 | + | |
324 | cmp r0, #0 | |
325 | beq 1f | |
326 | - ldmfd sp!, {r4, r7} | |
327 | + ldmfd sp!, {r4, r7} | |
328 | blt __unified_syscall @ (return code < 0): handle as an error | |
329 | - bx lr | |
330 | -1: | |
331 | -#ifdef RESET_PID | |
332 | + RET | |
333 | +1: | |
334 | +#ifdef RESET_PID | |
335 | tst ip, #CLONE_THREAD | |
336 | bne 3f | |
337 | ||
338 | @@ -67,21 +62,22 @@ | |
339 | swi 0 | |
340 | str r0, [r1, #PID_OFFSET] @ ; not defined yet ?? | |
341 | str r0, [r1, #TID_OFFSET] @ ; not defined yet ?? | |
342 | -3: | |
343 | +3: | |
344 | #endif | |
345 | @ ; pick the function arg and call address off the stack and execute | |
346 | ldr r0, [sp, #4] | |
347 | mov lr, pc | |
348 | ldr pc, [sp], #8 | |
349 | - | |
350 | + | |
351 | @ ; and we're done, passing return value through r0 | |
352 | b _exit @ branch to _exit (PIC safe) | |
353 | +FUNC_END __clone | |
354 | +FUNC_END clone | |
355 | ||
356 | - | |
357 | #else | |
358 | - | |
359 | -clone: | |
360 | -__clone: | |
361 | + | |
362 | +FUNC_START_WEAK clone | |
363 | +FUNC_START __clone | |
364 | movs r12, r0 @ check function pointer | |
365 | cmpne r1, #0 @ if function check for stack pointer | |
366 | moveq r0, #-EINVAL @ if one is not available set errno value | |
367 | @@ -101,5 +97,7 @@ | |
368 | ldmia sp!, { r0, pc } @ load function param and jump to thread function | |
369 | ||
370 | 1: b _exit @ branch to _exit (PIC safe) | |
371 | +FUNC_END __clone | |
372 | +FUNC_END clone | |
373 | ||
374 | #endif | |
375 | diff -urN -x .git dietlibc-0.33/arm/dyn_syscalls.S dietlibc/arm/dyn_syscalls.S | |
376 | --- dietlibc-0.33/arm/dyn_syscalls.S 2012-01-24 18:24:24.000000000 +0000 | |
377 | +++ dietlibc/arm/dyn_syscalls.S 2015-01-01 12:14:43.454938895 +0000 | |
378 | @@ -3,16 +3,21 @@ | |
379 | * Olaf Dreesen | |
380 | */ | |
381 | ||
382 | +#include "arm-features.h" | |
383 | + | |
384 | #include "../syscalls.s/environ.S" | |
385 | #include "../syscalls.s/errno.S" | |
386 | ||
387 | #include <dietfeatures.h> | |
388 | #include "syscalls.h" | |
389 | ||
390 | -.text | |
391 | -__unified_syscall4: | |
392 | +#ifdef __ARM_EABI__ | |
393 | +# error "dyn_syscall.S not ported for EABI yet" | |
394 | +#endif | |
395 | + | |
396 | +FUNC_START __unified_syscall4 | |
397 | ldmfd sp!, {r4, r5, r6} | |
398 | -__unified_syscall: | |
399 | +FUNC_START __unified_syscall | |
400 | cmn r0, #4096 | |
401 | movcc pc, lr | |
402 | rsb r1, r0, #0 | |
403 | @@ -25,7 +30,9 @@ | |
404 | ||
405 | mvn r0, #0 | |
406 | #include "dietuglyweaks.h" | |
407 | - mov pc, lr | |
408 | + RET | |
409 | +FUNC_END __unified_syscall | |
410 | +FUNC_END __unified_syscall4 | |
411 | ||
412 | /* ok now include all syscalls.s (*.S) and sysdep *.S */ | |
413 | #include "mmap.S" | |
414 | @@ -104,7 +111,6 @@ | |
415 | #include "../syscalls.s/n_sigprocmask.S" | |
416 | #include "../syscalls.s/n_sigsuspend.S" | |
417 | #include "../syscalls.s/nanosleep.S" | |
418 | -#include "../syscalls.s/nice.S" | |
419 | #include "../syscalls.s/open.S" | |
420 | #include "../syscalls.s/pause.S" | |
421 | #include "../syscalls.s/personality.S" | |
422 | @@ -280,9 +286,11 @@ | |
423 | #include "../syscalls.s/fgetxattr.S" | |
424 | ||
425 | /* other asm-files w.o. changes ... */ | |
426 | -__exit: | |
427 | +FUNC_START __exit | |
428 | swi $__NR_exit | |
429 | eor pc,lr,lr | |
430 | +FUNC_END __exit | |
431 | + | |
432 | #define _exit __exit | |
433 | #include "clone.S" | |
434 | #undef _exit | |
435 | diff -urN -x .git dietlibc-0.33/arm/__fadvise.c dietlibc/arm/__fadvise.c | |
436 | --- dietlibc-0.33/arm/__fadvise.c 2011-03-03 18:40:05.000000000 +0000 | |
437 | +++ dietlibc/arm/__fadvise.c 2015-01-01 12:14:43.454938895 +0000 | |
438 | @@ -1,5 +1,7 @@ | |
439 | -#include <fcntl.h> | |
440 | #include "syscalls.h" | |
441 | +#define _LINUX_SOURCE | |
442 | +#include <fcntl.h> | |
443 | +#include <unistd.h> | |
444 | ||
445 | #ifndef __NR_fadvise64 | |
446 | long fadvise64_64(int fd, off64_t offset, off64_t len, int advice) | |
447 | diff -urN -x .git dietlibc-0.33/arm/__guard.S dietlibc/arm/__guard.S | |
448 | --- dietlibc-0.33/arm/__guard.S 2006-06-21 19:55:25.000000000 +0000 | |
449 | +++ dietlibc/arm/__guard.S 2015-01-01 12:14:43.454938895 +0000 | |
450 | @@ -1,4 +1,5 @@ | |
451 | .data | |
452 | +.align 2 | |
453 | .type __guard,#object | |
454 | .global __guard | |
455 | .type __stack_chk_guard,#object | |
456 | @@ -7,3 +8,5 @@ | |
457 | __stack_chk_guard: | |
458 | .long 0xaff00 | |
459 | ||
460 | +.size __guard, . - __guard | |
461 | +.size __stack_chk_guard, . - __stack_chk_guard | |
462 | diff -urN -x .git dietlibc-0.33/arm/__longjmp.S dietlibc/arm/__longjmp.S | |
463 | --- dietlibc-0.33/arm/__longjmp.S 2001-07-02 16:06:48.000000000 +0000 | |
464 | +++ dietlibc/arm/__longjmp.S 2015-01-01 12:14:43.454938895 +0000 | |
465 | @@ -1,11 +1,23 @@ | |
466 | -.text | |
467 | -.global __longjmp | |
468 | -.type __longjmp,function | |
469 | -__longjmp: | |
470 | +#include "arm-features.h" | |
471 | + | |
472 | +FUNC_START __longjmp | |
473 | mov ip, r0 | |
474 | movs r0, r1 | |
475 | moveq r0, #1 | |
476 | -#ifndef __SOFTFP__ | |
477 | - lfm f4, 4, [ip], #48 | |
478 | +#ifndef __SOFTFP__ | |
479 | +# if __ARM_ARCH__ == 7 | |
480 | + vldm ip!, {d0-d15} | |
481 | +# ifdef __ARM_NEON__ | |
482 | + vldm ip!, {d16-d31} | |
483 | +# endif | |
484 | +# else | |
485 | + lfm f4, 4, [ip]! | |
486 | +# endif | |
487 | #endif | |
488 | - ldmia ip, {r4-r11, sp, pc} | |
489 | + | |
490 | +#ifdef __IWMMXT__ | |
491 | +# warning "sigjmp will not restore iwmmxt coprocessor registers" | |
492 | +#endif | |
493 | + | |
494 | + ldmia ip!, {r4-r11, sp, pc} | |
495 | +FUNC_END __longjmp | |
496 | diff -urN -x .git dietlibc-0.33/arm/Makefile.add dietlibc/arm/Makefile.add | |
497 | --- dietlibc-0.33/arm/Makefile.add 2012-01-24 18:24:24.000000000 +0000 | |
498 | +++ dietlibc/arm/Makefile.add 2015-01-01 12:14:43.454938895 +0000 | |
499 | @@ -1,6 +1,7 @@ | |
500 | ||
501 | LIBOBJ+=$(OBJDIR)/md5asm.o $(OBJDIR)/__aeabi_unwind_cpp.o | |
502 | LIBOBJ+=$(OBJDIR)/__fadvise.o $(OBJDIR)/arm_fadvise.o | |
503 | +LIBOBJ+=$(OBJDIR)/__aeabi_read_tp.o $(OBJDIR)/arm_set_tls.o | |
504 | CFLAGS+=-Os -fomit-frame-pointer -fstrict-aliasing | |
505 | #ifdef __ARM_EABI__ | |
506 | #CFLAGS+=-mabi=aapcs-linux -mno-thumb-interwork | |
507 | diff -urN -x .git dietlibc-0.33/arm/mcount.S dietlibc/arm/mcount.S | |
508 | --- dietlibc-0.33/arm/mcount.S 2002-05-09 03:50:17.000000000 +0000 | |
509 | +++ dietlibc/arm/mcount.S 2015-01-01 12:14:43.454938895 +0000 | |
510 | @@ -1,4 +1,4 @@ | |
511 | - | |
512 | +#include "arm-features.h" | |
513 | @ | |
514 | @ mcount.S: ARM assembler implementation of mcount | |
515 | @ | |
516 | @@ -27,11 +27,7 @@ | |
517 | @ | |
518 | @ | |
519 | ||
520 | -.text | |
521 | - | |
522 | -.global mcount | |
523 | - | |
524 | -mcount: | |
525 | +FUNC_START mcount | |
526 | mov ip, sp | |
527 | stmdb sp!, { r0 - r3, fp, ip, lr, pc } @ build stack frame | |
528 | sub fp, ip, #4 @ setup new fp | |
529 | @@ -43,4 +39,4 @@ | |
530 | bl __mcount @ call __mcount | |
531 | ||
532 | ldmdb fp, { r0 - r3, fp, sp, pc } @ restore context from stack frame and return. | |
533 | - | |
534 | +FUNC_END mcount | |
535 | diff -urN -x .git dietlibc-0.33/arm/md5asm.S dietlibc/arm/md5asm.S | |
536 | --- dietlibc-0.33/arm/md5asm.S 2008-12-10 20:00:58.000000000 +0000 | |
537 | +++ dietlibc/arm/md5asm.S 2015-01-01 12:14:43.454938895 +0000 | |
538 | @@ -1,400 +1,394 @@ | |
539 | -/***************************************************************************** | |
540 | -* Copyright (C) 2002 Andre McCurdy <armccurdy@yahoo.co.uk> | |
541 | -* | |
542 | -* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" | |
543 | -* | |
544 | -* This program is free software. you can redistribute it and/or modify | |
545 | -* it under the terms of the GNU General Public License as published by | |
546 | -* the Free Software Foundation; either version 2 of the License, or | |
547 | -* (at your option) any later version. | |
548 | -* | |
549 | -* This program is distributed in the hope that it will be useful, | |
550 | -* but WITHOUT ANY WARRANTY, without even the implied warranty of | |
551 | -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
552 | -* GNU General Public License for more details. | |
553 | -* | |
554 | -* You should have received a copy of the GNU General Public License | |
555 | -* along with this program; if not, write to the Free Software | |
556 | -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
557 | -* | |
558 | -****************************************************************************** | |
559 | -* | |
560 | -* History: | |
561 | -* | |
562 | -* 2002/02/12: Andre McCurdy <armccurdy@yahoo.co.uk> | |
563 | -* - Original created. | |
564 | -* | |
565 | -* 2002/02/13: Andre McCurdy <armccurdy@yahoo.co.uk> | |
566 | -* - Rewrote MD5Update in assembler (saves 52 bytes). | |
567 | -* - Added guard so we don't compile anything for Big-Endian targets. | |
568 | -* | |
569 | -* 2002/02/22: Andre McCurdy <armccurdy@yahoo.co.uk> | |
570 | -* - Added new function MD5Update (a wrapper for the original version) which | |
571 | -* checks for correct 32bit alignment of the input data pointer. | |
572 | -* - Original MD5Update function renamed __MD5Update. | |
573 | -* - __MD5Transform symbol no longer exported. | |
574 | -* | |
575 | -* 2002/02/25: Andre McCurdy <armccurdy@yahoo.co.uk> | |
576 | -* - MD5Update re-written in assembler (saves 12 bytes + lots of cycles :-) | |
577 | -* | |
578 | -* 2002/03/07: Andre McCurdy <armccurdy@yahoo.co.uk> | |
579 | -* - _Finally_ fixed hashing from an unaligned buffer in all cases :-) | |
580 | -* | |
581 | -****************************************************************************** | |
582 | -* | |
583 | -* Notes: | |
584 | -* | |
585 | -* This code is believed to be Position Independent (ie can be safely used | |
586 | -* as part of a shared library). | |
587 | -* | |
588 | -*****************************************************************************/ | |
589 | - | |
590 | -#include <endian.h> | |
591 | - | |
592 | -#if (__BYTE_ORDER == __LITTLE_ENDIAN) | |
593 | - | |
594 | - .global MD5Init | |
595 | - .global MD5Update | |
596 | - | |
597 | - .text | |
598 | -#ifdef __ARM_EABI__ | |
599 | - .align 4 | |
600 | -#else | |
601 | - .align 2 | |
602 | -#endif | |
603 | - | |
604 | - @ -- | |
605 | - @ void MD5Init (MD5_CTX* context); | |
606 | - @ -- | |
607 | - | |
608 | -MD5Init: | |
609 | - | |
610 | - adr r1, 1f @ r1 = base address of MD5InitData array | |
611 | - ldmia r1, { r1 - r3, r12 } @ load 4 elements from MD5InitData array | |
612 | - stmia r0, { r1 - r3, r12 } @ store into MD5 context->state[0..3] | |
613 | - mov r1, #0 | |
614 | - str r1, [r0, #0x10] @ initial count[0] = 0 | |
615 | - str r1, [r0, #0x14] @ initial count[1] = 0 | |
616 | - mov pc, lr @ return | |
617 | - | |
618 | -1: .word 0x67452301 @ initial MD5 context->state[0] | |
619 | - .word 0xefcdab89 @ initial MD5 context->state[1] | |
620 | - .word 0x98badcfe @ initial MD5 context->state[2] | |
621 | - .word 0x10325476 @ initial MD5 context->state[3] | |
622 | - | |
623 | - | |
624 | - @ -- | |
625 | - @ void MD5Update (MD5_CTX* context, const uint8_t* buf, signed int len); | |
626 | - @ -- | |
627 | - | |
628 | -MD5Update: | |
629 | - | |
630 | - stmdb sp!, { r4 - r8, lr } | |
631 | - add r4, r0, #(6 * 4) @ r4 = &context->buffer[0] | |
632 | - ldmdb r4, { r0, r3 } @ r0 = count[0], r3 = count[1] | |
633 | - mov r5, r1 @ r5 = input | |
634 | - mov r6, r0, lsr #3 @ r6 = (context->count[0] >> 3) | |
635 | - and r6, r6, #0x3f @ r6 = byteIndex = ((context->count[0] >> 3) & 0x3f) | |
636 | - adds r0, r0, r2, lsl #3 | |
637 | - adc r3, r3, r2, lsr #29 | |
638 | - stmdb r4, { r0, r3 } @ context->count += (inputBytes * 8) | |
639 | - rsb r7, r6, #64 @ r7 = (64 - byteIndex) == partLen | |
640 | - subs r8, r2, r7 @ r8 = (inputBytes - partLen) | |
641 | - add r0, r4, r6 | |
642 | - bcc 2f | |
643 | - mov r2, r7 | |
644 | - bl memcpy @ memcpy (&context->buffer[byteIndex], input, partLen); | |
645 | - sub r0, r4, #(6 * 4) | |
646 | - mov r1, r4 | |
647 | - mov r2, #1 | |
648 | - bl __MD5Transform @ __MD5Transform (context->state, context->buffer, 1); | |
649 | - sub r0, r4, #(6 * 4) | |
650 | - add r1, r5, r7 | |
651 | - mov r2, r8, lsr #6 @ r2 = len = ((inputBytes - partLen) / 64) | |
652 | - tst r1, #3 @ if (input & 0x03) | |
653 | - adr lr, 1f | |
654 | - beq __MD5Transform @ __MD5Transform (context->state, &input[partLen], len); | |
655 | - bne __UnalignedMD5Transform @ else __UnalignedMD5Transform (context->state, &input[partLen], len); | |
656 | -1: mov r0, r4 | |
657 | - bic r2, r8, #0x3f | |
658 | - add r1, r2, r7 | |
659 | - add r1, r1, r5 | |
660 | - sub r2, r8, r2 | |
661 | -2: ldmia sp!, { r4 - r8, lr } | |
662 | - b memcpy @ classic tail-call optimisation... | |
663 | - | |
664 | - | |
665 | - @ -- | |
666 | - @ static void __MD5Transform (uint32_t *buf, const uint32_t *in, int repeat); | |
667 | - @ -- | |
668 | - | |
669 | -MD5MagicData: | |
670 | - | |
671 | -1: .word 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee | |
672 | - .word 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, ( 3f- 4f-4) | |
673 | - .word 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, ( 3f- 4f-4) | |
674 | - .word 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, ( 3f- 4f-4) | |
675 | - .word 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, ( 4f- 4f-4) | |
676 | - .word 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, ( 5f- 9f-4) | |
677 | - .word 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, ( 6f- 9f-4) | |
678 | - .word 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, ( 7f- 9f-4) | |
679 | - .word 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, ( 9f- 9f-4) | |
680 | - .word 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, (10f-14f-4) | |
681 | - .word 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, (11f-14f-4) | |
682 | - .word 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, (12f-14f-4) | |
683 | - .word 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, (14f-14f-4) | |
684 | - .word 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, (15f-19f-4) | |
685 | - .word 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, (16f-19f-4) | |
686 | - .word 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, (17f-19f-4) | |
687 | - .word 0x6e4120A9, 0x20657264, 0x7543634d, 0x00796472, (19f-19f-4) | |
688 | - | |
689 | -__MD5Transform: | |
690 | - | |
691 | - cmp r2, #0 | |
692 | - moveq pc, lr @ return if (repeat == 0) | |
693 | - stmdb sp!, { r0, r2, r4 - r11, lr } @ stack 'buf', 'repeat' and all callee saved registers | |
694 | - ldmia r0, { r2 - r5 } @ r2 = a, r3 = b, r4 = c, r5 = d | |
695 | -2: adr r0, 1b @ r0 = base address of MD5MagicData | |
696 | - ldmia r0!, { r6 - r9 } @ load first 4 elements from MD5MagicData | |
697 | -3: ldmia r1!, { r10 - r12, lr } @ r10 = in[i], r11 = in[i+1], r12 = in[i+2], lr = in[i+3] | |
698 | - | |
699 | - add r10, r10, r6 @ r10 = in[i] + MD5MagicData[i] | |
700 | - eor r6, r4, r5 @ r6 = (c ^ d) | |
701 | - and r6, r6, r3 @ r6 = ((c ^ d) & b) | |
702 | - eor r6, r6, r5 @ r6 = (((c ^ d) & b) ^ d) | |
703 | - add r2, r2, r6 @ a = (((c ^ d) & b) ^ d) + a | |
704 | - add r2, r2, r10 @ a = (((c ^ d) & b) ^ d) + a + (in[i] + MD5MagicData[i]) | |
705 | - add r2, r3, r2, ROR #(32 - 7) @ a = b + (a rotated left by 7 places) | |
706 | - | |
707 | - add r11, r11, r7 @ r11 = in[i+1] + MD5MagicData[i+1] | |
708 | - eor r7, r3, r4 @ r7 = (b ^ c) | |
709 | - and r7, r7, r2 @ r7 = ((b ^ c) & a) | |
710 | - eor r7, r7, r4 @ r7 = (((b ^ c) & a) ^ c) | |
711 | - add r5, r5, r7 @ d = (((b ^ c) & a) ^ c) + d | |
712 | - add r5, r5, r11 @ d = (((b ^ c) & a) ^ c) + d + (in[i+1] + MD5MagicData[i+1]) | |
713 | - add r5, r2, r5, ROR #(32 - 12) @ d = a + (d rotated left by 12 places) | |
714 | - | |
715 | - add r12, r12, r8 @ r12 = in[i+2] + MD5MagicData[i+2] | |
716 | - eor r8, r2, r3 @ r8 = (a ^ b) | |
717 | - and r8, r8, r5 @ r8 = ((a ^ b) & d) | |
718 | - eor r8, r8, r3 @ r8 = (((a ^ b) & d) ^ b) | |
719 | - add r4, r4, r8 @ c = (((a ^ b) & d) ^ b) + c | |
720 | - add r4, r4, r12 @ c = (((a ^ b) & d) ^ b) + c + (in[i+2] + MD5MagicData[i+2]) | |
721 | - add r4, r5, r4, ROR #(32 - 17) @ c = d + (c rotated left by 17 places) | |
722 | - | |
723 | - add lr, lr, r9 @ lr = in[i+3] + MD5MagicData[i+3] | |
724 | - eor r9, r5, r2 @ r9 = (d ^ a) | |
725 | - and r9, r9, r4 @ r9 = ((d ^ a) & c) | |
726 | - eor r9, r9, r2 @ r9 = (((d ^ a) & c) ^ a) | |
727 | - add r3, r3, r9 @ b = (((d ^ a) & c) ^ a) + b | |
728 | - add r3, r3, lr @ b = (((d ^ a) & c) ^ a) + b + (in[i+3] + MD5MagicData[i+3]) | |
729 | - add r3, r4, r3, ROR #(32 - 22) @ b = c + (b rotated left by 22 places) | |
730 | - | |
731 | - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
732 | - add pc, pc, r10 @ and branch to next state | |
733 | - | |
734 | -4: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1] | |
735 | - ldr r11, [r1, #-(10*4)] @ r11 = in[ 6] | |
736 | - ldr r12, [r1, #-( 5*4)] @ r12 = in[11] | |
737 | - ldr lr, [r1, #-(16*4)] @ lr = in[ 0] | |
738 | - b 8f | |
739 | -5: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5] | |
740 | - ldr r11, [r1, #-( 6*4)] @ r11 = in[10] | |
741 | - ldr r12, [r1, #-( 1*4)] @ r12 = in[15] | |
742 | - ldr lr, [r1, #-(12*4)] @ lr = in[ 4] | |
743 | - b 8f | |
744 | -6: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9] | |
745 | - ldr r11, [r1, #-( 2*4)] @ r11 = in[14] | |
746 | - ldr r12, [r1, #-(13*4)] @ r12 = in[ 3] | |
747 | - ldr lr, [r1, #-( 8*4)] @ lr = in[ 8] | |
748 | - b 8f | |
749 | -7: ldr r10, [r1, #-( 3*4)] @ r10 = in[13] | |
750 | - ldr r11, [r1, #-(14*4)] @ r11 = in[ 2] | |
751 | - ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7] | |
752 | - ldr lr, [r1, #-( 4*4)] @ lr = in[12] | |
753 | - | |
754 | -8: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
755 | - eor r6, r3, r4 @ r6 = (b ^ c) | |
756 | - and r6, r6, r5 @ r6 = ((b ^ c) & d) | |
757 | - eor r6, r6, r4 @ r6 = (((b ^ c) & d) ^ c) | |
758 | - add r2, r2, r6 @ a = (((b ^ c) & d) ^ c) + a | |
759 | - add r2, r2, r10 @ a = (((b ^ c) & d) ^ c) + a + (in[x] + MD5MagicData[i]) | |
760 | - add r2, r3, r2, ROR #(32 - 5) @ a = b + (a rotated left by 5 places) | |
761 | - | |
762 | - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1] | |
763 | - eor r7, r2, r3 @ r7 = (a ^ b) | |
764 | - and r7, r7, r4 @ r7 = ((a ^ b) & c) | |
765 | - eor r7, r7, r3 @ r7 = (((a ^ b) & c) ^ b) | |
766 | - add r5, r5, r7 @ d = (((a ^ b) & c) ^ b) + d | |
767 | - add r5, r5, r11 @ d = (((a ^ b) & c) ^ b) + d + (in[x] + MD5MagicData[i+1]) | |
768 | - add r5, r2, r5, ROR #(32 - 9) @ d = a + (d rotated left by 9 places) | |
769 | - | |
770 | - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2] | |
771 | - eor r8, r5, r2 @ r8 = (d ^ a) | |
772 | - and r8, r8, r3 @ r8 = ((d ^ a) & b) | |
773 | - eor r8, r8, r2 @ r8 = (((d ^ a) & b) ^ a) | |
774 | - add r4, r4, r8 @ c = (((d ^ a) & b) ^ a) + c | |
775 | - add r4, r4, r12 @ c = (((d ^ a) & b) ^ a) + c + (in[x] + MD5MagicData[i+2]) | |
776 | - add r4, r5, r4, ROR #(32 - 14) @ c = d + (c rotated left by 14 places) | |
777 | - | |
778 | - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3] | |
779 | - eor r9, r4, r5 @ r9 = (c ^ d) | |
780 | - and r9, r9, r2 @ r9 = ((c ^ d) & a) | |
781 | - eor r9, r9, r5 @ r9 = (((c ^ d) & a) ^ d) | |
782 | - add r3, r3, r9 @ b = (((c ^ d) & a) ^ d) + b | |
783 | - add r3, r3, lr @ b = (((c ^ d) & a) ^ d) + b + (in[x] + MD5MagicData[i+3]) | |
784 | - add r3, r4, r3, ROR #(32 - 20) @ b = c + (b rotated left by 20 places) | |
785 | - | |
786 | - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
787 | - add pc, pc, r10 @ and branch to next state | |
788 | - | |
789 | -9: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5] | |
790 | - ldr r11, [r1, #-( 8*4)] @ r11 = in[ 8] | |
791 | - ldr r12, [r1, #-( 5*4)] @ r12 = in[11] | |
792 | - ldr lr, [r1, #-( 2*4)] @ lr = in[14] | |
793 | - b 13f | |
794 | -10: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1] | |
795 | - ldr r11, [r1, #-(12*4)] @ r11 = in[ 4] | |
796 | - ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7] | |
797 | - ldr lr, [r1, #-( 6*4)] @ lr = in[10] | |
798 | - b 13f | |
799 | -11: ldr r10, [r1, #-( 3*4)] @ r10 = in[13] | |
800 | - ldr r11, [r1, #-(16*4)] @ r11 = in[ 0] | |
801 | - ldr r12, [r1, #-(13*4)] @ r12 = in[ 3] | |
802 | - ldr lr, [r1, #-(10*4)] @ lr = in[ 6] | |
803 | - b 13f | |
804 | -12: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9] | |
805 | - ldr r11, [r1, #-( 4*4)] @ r11 = in[12] | |
806 | - ldr r12, [r1, #-( 1*4)] @ r12 = in[15] | |
807 | - ldr lr, [r1, #-(14*4)] @ lr = in[ 2] | |
808 | - | |
809 | -13: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
810 | - add r2, r2, r10 @ a += in[x] + MD5MagicData[i] | |
811 | - eor r6, r3, r4 @ r6 = (b ^ c) | |
812 | - eor r10, r6, r5 @ r10 = (b ^ c ^ d) | |
813 | - add r2, r2, r10 @ a += (b ^ c ^ d) | |
814 | - add r2, r3, r2, ROR #(32 - 4) @ a = b + (a rotated left by 4 places) | |
815 | - | |
816 | - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1] | |
817 | - eor r7, r2, r6 @ r7 = (a ^ b ^ c) | |
818 | - add r5, r5, r7 @ d = (a ^ b ^ c) + d | |
819 | - add r5, r5, r11 @ d = (a ^ b ^ c) + d + (in[x] + MD5MagicData[i+1]) | |
820 | - add r5, r2, r5, ROR #(32 - 11) @ d = a + (d rotated left by 11 places) | |
821 | - | |
822 | - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2] | |
823 | - add r4, r4, r12 @ c += in[x] + MD5MagicData[i+2] | |
824 | - eor r8, r5, r2 @ r8 = (d ^ a) | |
825 | - eor r12, r8, r3 @ r12 = (d ^ a ^ b) | |
826 | - add r4, r4, r12 @ c += (d ^ a ^ b) | |
827 | - add r4, r5, r4, ROR #(32 - 16) @ c = d + (c rotated left by 16 places) | |
828 | - | |
829 | - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3] | |
830 | - eor r9, r4, r8 @ r9 = (c ^ d ^ a) | |
831 | - add r3, r3, r9 @ b = (c ^ d ^ a) + b | |
832 | - add r3, r3, lr @ b = (c ^ d ^ a) + b + (in[x] + MD5MagicData[i+3]) | |
833 | - add r3, r4, r3, ROR #(32 - 23) @ b = c + (b rotated left by 23 places) | |
834 | - | |
835 | - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
836 | - add pc, pc, r10 @ and branch to next state | |
837 | - | |
838 | -14: ldr r10, [r1, #-(16*4)] @ r10 = in[ 0] | |
839 | - ldr r11, [r1, #-( 9*4)] @ r11 = in[ 7] | |
840 | - ldr r12, [r1, #-( 2*4)] @ r12 = in[14] | |
841 | - ldr lr, [r1, #-(11*4)] @ lr = in[ 5] | |
842 | - b 18f | |
843 | -15: ldr r10, [r1, #-( 4*4)] @ r10 = in[12] | |
844 | - ldr r11, [r1, #-(13*4)] @ r11 = in[ 3] | |
845 | - ldr r12, [r1, #-( 6*4)] @ r12 = in[10] | |
846 | - ldr lr, [r1, #-(15*4)] @ lr = in[ 1] | |
847 | - b 18f | |
848 | -16: ldr r10, [r1, #-( 8*4)] @ r10 = in[ 8] | |
849 | - ldr r11, [r1, #-( 1*4)] @ r11 = in[15] | |
850 | - ldr r12, [r1, #-(10*4)] @ r12 = in[ 6] | |
851 | - ldr lr, [r1, #-( 3*4)] @ lr = in[13] | |
852 | - b 18f | |
853 | -17: ldr r10, [r1, #-(12*4)] @ r10 = in[ 4] | |
854 | - ldr r11, [r1, #-( 5*4)] @ r11 = in[11] | |
855 | - ldr r12, [r1, #-(14*4)] @ r12 = in[ 2] | |
856 | - ldr lr, [r1, #-( 7*4)] @ lr = in[ 9] | |
857 | - | |
858 | -18: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
859 | - add r2, r2, r10 @ a += in[x] + MD5MagicData[i] | |
860 | - mvn r6, r5 @ r6 = ( ~d) | |
861 | - orr r6, r6, r3 @ r6 = (b | ~d) | |
862 | - eor r6, r6, r4 @ r6 = (c ^ (b | ~d)) | |
863 | - add r2, r2, r6 @ a += (c ^ (b | ~d)) | |
864 | - add r2, r3, r2, ROR #(32 - 6) @ a = b + (a rotated left by 6 places) | |
865 | - | |
866 | - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i] | |
867 | - add r5, r5, r11 @ d += in[x] + MD5MagicData[i] | |
868 | - mvn r7, r4 @ r7 = ( ~c) | |
869 | - orr r7, r7, r2 @ r7 = (a | ~c) | |
870 | - eor r7, r7, r3 @ r7 = (b ^ (a | ~c)) | |
871 | - add r5, r5, r7 @ d += (b ^ (a | ~c)) | |
872 | - add r5, r2, r5, ROR #(32 - 10) @ d = a + (d rotated left by 10 places) | |
873 | - | |
874 | - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i] | |
875 | - add r4, r4, r12 @ c += in[x] + MD5MagicData[i] | |
876 | - mvn r8, r3 @ r8 = ( ~b) | |
877 | - orr r8, r8, r5 @ r8 = (d | ~b) | |
878 | - eor r8, r8, r2 @ r8 = (a ^ (d | ~b)) | |
879 | - add r4, r4, r8 @ c += (a ^ (d | ~b)) | |
880 | - add r4, r5, r4, ROR #(32 - 15) @ c = d + (c rotated left by 15 places) | |
881 | - | |
882 | - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i] | |
883 | - add r3, r3, lr @ b += in[x] + MD5MagicData[i] | |
884 | - mvn r9, r2 @ r9 = ( ~a) | |
885 | - orr r9, r9, r4 @ r9 = (c | ~a) | |
886 | - eor r9, r9, r5 @ r9 = (d ^ (c | ~a)) | |
887 | - add r3, r3, r9 @ b += (d ^ (c | ~a)) | |
888 | - add r3, r4, r3, ROR #(32 - 21) @ b = c + (b rotated left by 21 places) | |
889 | - | |
890 | - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
891 | - add pc, pc, r10 @ and branch to next state | |
892 | - | |
893 | -19: ldmia sp, { r0, r10 } @ fetch 'buf' and 'repeat' from the stack | |
894 | - ldmia r0, { r6 - r9 } @ r6 = buf[0], r7 = buf[1], r8 = buf[2], r9 = buf[3] (original values..) | |
895 | - subs r10, r10, #1 | |
896 | - strne r10, [sp, #4] | |
897 | - add r2, r6, r2 | |
898 | - add r3, r7, r3 | |
899 | - add r4, r8, r4 | |
900 | - add r5, r9, r5 | |
901 | - stmia r0, { r2 - r5 } | |
902 | - bne 2b | |
903 | - ldmia sp!, { r0, r2, r4 - r11, pc } @ restore all callee saved registers and return | |
904 | - | |
905 | - | |
906 | - @ -- | |
907 | - @ static void __UnalignedMD5Transform (uint32_t *buf, const uint8_t *in, int repeat); | |
908 | - @ -- | |
909 | - | |
910 | -__UnalignedMD5Transform: | |
911 | - | |
912 | - stmdb sp!, { r4 - r7, lr } | |
913 | - movs r4, r2, lsl #6 @ r4 = (repeat * 64) | |
914 | - ldmeqia sp!, { r4 - r7, pc } @ if ((repeat * 64) == 0) return; | |
915 | - mov r5, r0 @ r5 = state | |
916 | - mov r6, r1 @ r6 = in | |
917 | - sub sp, sp, #256 @ create 256 byte temp buffer | |
918 | -1: cmp r4, #256 | |
919 | - mov r0, sp | |
920 | - movcc r7, r4 | |
921 | - movcs r7, #256 @ r7 = (blockCount * 64) = min((repeat * 64), (4 * 64)) | |
922 | - mov r1, r6 | |
923 | - mov r2, r7 | |
924 | - bl memcpy @ memcpy (blockBuffer, in, (blockCount * 64)); | |
925 | - mov r0, r5 | |
926 | - mov r1, sp | |
927 | - mov r2, r7, lsr #6 | |
928 | - bl __MD5Transform @ __MD5Transform (state, blockBuffer, blockCount); | |
929 | - subs r4, r4, #256 @ (repeat * 64) -= (4 * 64); | |
930 | - add r6, r6, #256 @ in += (4 * 64); | |
931 | - bgt 1b @ loop while (repeat > 0) | |
932 | - add sp, sp, #256 @ return temp buffer to stack | |
933 | - ldmia sp!, { r4 - r7, pc } @ return | |
934 | - | |
935 | - | |
936 | -#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ | |
937 | - | |
938 | - | |
939 | +#include "arm-features.h" | |
940 | + | |
941 | +/***************************************************************************** | |
942 | +* Copyright (C) 2002 Andre McCurdy <armccurdy@yahoo.co.uk> | |
943 | +* | |
944 | +* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" | |
945 | +* | |
946 | +* This program is free software. you can redistribute it and/or modify | |
947 | +* it under the terms of the GNU General Public License as published by | |
948 | +* the Free Software Foundation; either version 2 of the License, or | |
949 | +* (at your option) any later version. | |
950 | +* | |
951 | +* This program is distributed in the hope that it will be useful, | |
952 | +* but WITHOUT ANY WARRANTY, without even the implied warranty of | |
953 | +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
954 | +* GNU General Public License for more details. | |
955 | +* | |
956 | +* You should have received a copy of the GNU General Public License | |
957 | +* along with this program; if not, write to the Free Software | |
958 | +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
959 | +* | |
960 | +****************************************************************************** | |
961 | +* | |
962 | +* History: | |
963 | +* | |
964 | +* 2002/02/12: Andre McCurdy <armccurdy@yahoo.co.uk> | |
965 | +* - Original created. | |
966 | +* | |
967 | +* 2002/02/13: Andre McCurdy <armccurdy@yahoo.co.uk> | |
968 | +* - Rewrote MD5Update in assembler (saves 52 bytes). | |
969 | +* - Added guard so we don't compile anything for Big-Endian targets. | |
970 | +* | |
971 | +* 2002/02/22: Andre McCurdy <armccurdy@yahoo.co.uk> | |
972 | +* - Added new function MD5Update (a wrapper for the original version) which | |
973 | +* checks for correct 32bit alignment of the input data pointer. | |
974 | +* - Original MD5Update function renamed __MD5Update. | |
975 | +* - __MD5Transform symbol no longer exported. | |
976 | +* | |
977 | +* 2002/02/25: Andre McCurdy <armccurdy@yahoo.co.uk> | |
978 | +* - MD5Update re-written in assembler (saves 12 bytes + lots of cycles :-) | |
979 | +* | |
980 | +* 2002/03/07: Andre McCurdy <armccurdy@yahoo.co.uk> | |
981 | +* - _Finally_ fixed hashing from an unaligned buffer in all cases :-) | |
982 | +* | |
983 | +****************************************************************************** | |
984 | +* | |
985 | +* Notes: | |
986 | +* | |
987 | +* This code is believed to be Position Independent (ie can be safely used | |
988 | +* as part of a shared library). | |
989 | +* | |
990 | +*****************************************************************************/ | |
991 | + | |
992 | +#include <endian.h> | |
993 | +#include "arm-features.h" | |
994 | + | |
995 | +#if (__BYTE_ORDER == __LITTLE_ENDIAN) | |
996 | + | |
997 | + @ -- | |
998 | + @ void MD5Init (MD5_CTX* context); | |
999 | + @ -- | |
1000 | + | |
1001 | +FUNC_START MD5Init | |
1002 | + adr r1, 1f @ r1 = base address of MD5InitData array | |
1003 | + ldmia r1, { r1 - r3, r12 } @ load 4 elements from MD5InitData array | |
1004 | + stmia r0, { r1 - r3, r12 } @ store into MD5 context->state[0..3] | |
1005 | + mov r1, #0 | |
1006 | + str r1, [r0, #0x10] @ initial count[0] = 0 | |
1007 | + str r1, [r0, #0x14] @ initial count[1] = 0 | |
1008 | + RET | |
1009 | + | |
1010 | + .align 3 | |
1011 | +1: .word 0x67452301 @ initial MD5 context->state[0] | |
1012 | + .word 0xefcdab89 @ initial MD5 context->state[1] | |
1013 | + .word 0x98badcfe @ initial MD5 context->state[2] | |
1014 | + .word 0x10325476 @ initial MD5 context->state[3] | |
1015 | +FUNC_END MD5Init | |
1016 | + | |
1017 | + @ -- | |
1018 | + @ void MD5Update (MD5_CTX* context, const uint8_t* buf, signed int len); | |
1019 | + @ -- | |
1020 | + | |
1021 | +FUNC_START MD5Update | |
1022 | + stmdb sp!, { r4 - r8, lr } | |
1023 | + add r4, r0, #(6 * 4) @ r4 = &context->buffer[0] | |
1024 | + ldmdb r4, { r0, r3 } @ r0 = count[0], r3 = count[1] | |
1025 | + mov r5, r1 @ r5 = input | |
1026 | + mov r6, r0, lsr #3 @ r6 = (context->count[0] >> 3) | |
1027 | + and r6, r6, #0x3f @ r6 = byteIndex = ((context->count[0] >> 3) & 0x3f) | |
1028 | + adds r0, r0, r2, lsl #3 | |
1029 | + adc r3, r3, r2, lsr #29 | |
1030 | + stmdb r4, { r0, r3 } @ context->count += (inputBytes * 8) | |
1031 | + rsb r7, r6, #64 @ r7 = (64 - byteIndex) == partLen | |
1032 | + subs r8, r2, r7 @ r8 = (inputBytes - partLen) | |
1033 | + add r0, r4, r6 | |
1034 | + bcc 2f | |
1035 | + mov r2, r7 | |
1036 | + bl memcpy @ memcpy (&context->buffer[byteIndex], input, partLen); | |
1037 | + sub r0, r4, #(6 * 4) | |
1038 | + mov r1, r4 | |
1039 | + mov r2, #1 | |
1040 | + bl __MD5Transform @ __MD5Transform (context->state, context->buffer, 1); | |
1041 | + sub r0, r4, #(6 * 4) | |
1042 | + add r1, r5, r7 | |
1043 | + mov r2, r8, lsr #6 @ r2 = len = ((inputBytes - partLen) / 64) | |
1044 | + tst r1, #3 @ if (input & 0x03) | |
1045 | + adr lr, 1f | |
1046 | + beq __MD5Transform @ __MD5Transform (context->state, &input[partLen], len); | |
1047 | + bne __UnalignedMD5Transform @ else __UnalignedMD5Transform (context->state, &input[partLen], len); | |
1048 | +1: mov r0, r4 | |
1049 | + bic r2, r8, #0x3f | |
1050 | + add r1, r2, r7 | |
1051 | + add r1, r1, r5 | |
1052 | + sub r2, r8, r2 | |
1053 | +2: ldmia sp!, { r4 - r8, lr } | |
1054 | + b memcpy @ classic tail-call optimisation... | |
1055 | +FUNC_END MD5Update | |
1056 | + | |
1057 | + @ -- | |
1058 | + @ static void __MD5Transform (uint32_t *buf, const uint32_t *in, int repeat); | |
1059 | + @ -- | |
1060 | + | |
1061 | +.align 3 | |
1062 | +MD5MagicData: | |
1063 | + | |
1064 | +1: .word 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee | |
1065 | + .word 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, ( 3f- 4f-4) | |
1066 | + .word 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, ( 3f- 4f-4) | |
1067 | + .word 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, ( 3f- 4f-4) | |
1068 | + .word 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, ( 4f- 4f-4) | |
1069 | + .word 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, ( 5f- 9f-4) | |
1070 | + .word 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, ( 6f- 9f-4) | |
1071 | + .word 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, ( 7f- 9f-4) | |
1072 | + .word 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, ( 9f- 9f-4) | |
1073 | + .word 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, (10f-14f-4) | |
1074 | + .word 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, (11f-14f-4) | |
1075 | + .word 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, (12f-14f-4) | |
1076 | + .word 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, (14f-14f-4) | |
1077 | + .word 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, (15f-19f-4) | |
1078 | + .word 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, (16f-19f-4) | |
1079 | + .word 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, (17f-19f-4) | |
1080 | + .word 0x6e4120A9, 0x20657264, 0x7543634d, 0x00796472, (19f-19f-4) | |
1081 | + | |
1082 | +.align 2 | |
1083 | +__MD5Transform: | |
1084 | + | |
1085 | + cmp r2, #0 | |
1086 | + moveq pc, lr @ return if (repeat == 0) | |
1087 | + stmdb sp!, { r0, r2, r4 - r11, lr } @ stack 'buf', 'repeat' and all callee saved registers | |
1088 | + ldmia r0, { r2 - r5 } @ r2 = a, r3 = b, r4 = c, r5 = d | |
1089 | +2: adr r0, 1b @ r0 = base address of MD5MagicData | |
1090 | + ldmia r0!, { r6 - r9 } @ load first 4 elements from MD5MagicData | |
1091 | +3: ldmia r1!, { r10 - r12, lr } @ r10 = in[i], r11 = in[i+1], r12 = in[i+2], lr = in[i+3] | |
1092 | + | |
1093 | + add r10, r10, r6 @ r10 = in[i] + MD5MagicData[i] | |
1094 | + eor r6, r4, r5 @ r6 = (c ^ d) | |
1095 | + and r6, r6, r3 @ r6 = ((c ^ d) & b) | |
1096 | + eor r6, r6, r5 @ r6 = (((c ^ d) & b) ^ d) | |
1097 | + add r2, r2, r6 @ a = (((c ^ d) & b) ^ d) + a | |
1098 | + add r2, r2, r10 @ a = (((c ^ d) & b) ^ d) + a + (in[i] + MD5MagicData[i]) | |
1099 | + add r2, r3, r2, ROR #(32 - 7) @ a = b + (a rotated left by 7 places) | |
1100 | + | |
1101 | + add r11, r11, r7 @ r11 = in[i+1] + MD5MagicData[i+1] | |
1102 | + eor r7, r3, r4 @ r7 = (b ^ c) | |
1103 | + and r7, r7, r2 @ r7 = ((b ^ c) & a) | |
1104 | + eor r7, r7, r4 @ r7 = (((b ^ c) & a) ^ c) | |
1105 | + add r5, r5, r7 @ d = (((b ^ c) & a) ^ c) + d | |
1106 | + add r5, r5, r11 @ d = (((b ^ c) & a) ^ c) + d + (in[i+1] + MD5MagicData[i+1]) | |
1107 | + add r5, r2, r5, ROR #(32 - 12) @ d = a + (d rotated left by 12 places) | |
1108 | + | |
1109 | + add r12, r12, r8 @ r12 = in[i+2] + MD5MagicData[i+2] | |
1110 | + eor r8, r2, r3 @ r8 = (a ^ b) | |
1111 | + and r8, r8, r5 @ r8 = ((a ^ b) & d) | |
1112 | + eor r8, r8, r3 @ r8 = (((a ^ b) & d) ^ b) | |
1113 | + add r4, r4, r8 @ c = (((a ^ b) & d) ^ b) + c | |
1114 | + add r4, r4, r12 @ c = (((a ^ b) & d) ^ b) + c + (in[i+2] + MD5MagicData[i+2]) | |
1115 | + add r4, r5, r4, ROR #(32 - 17) @ c = d + (c rotated left by 17 places) | |
1116 | + | |
1117 | + add lr, lr, r9 @ lr = in[i+3] + MD5MagicData[i+3] | |
1118 | + eor r9, r5, r2 @ r9 = (d ^ a) | |
1119 | + and r9, r9, r4 @ r9 = ((d ^ a) & c) | |
1120 | + eor r9, r9, r2 @ r9 = (((d ^ a) & c) ^ a) | |
1121 | + add r3, r3, r9 @ b = (((d ^ a) & c) ^ a) + b | |
1122 | + add r3, r3, lr @ b = (((d ^ a) & c) ^ a) + b + (in[i+3] + MD5MagicData[i+3]) | |
1123 | + add r3, r4, r3, ROR #(32 - 22) @ b = c + (b rotated left by 22 places) | |
1124 | + | |
1125 | + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
1126 | + add pc, pc, r10 @ and branch to next state | |
1127 | + | |
1128 | +4: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1] | |
1129 | + ldr r11, [r1, #-(10*4)] @ r11 = in[ 6] | |
1130 | + ldr r12, [r1, #-( 5*4)] @ r12 = in[11] | |
1131 | + ldr lr, [r1, #-(16*4)] @ lr = in[ 0] | |
1132 | + b 8f | |
1133 | +5: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5] | |
1134 | + ldr r11, [r1, #-( 6*4)] @ r11 = in[10] | |
1135 | + ldr r12, [r1, #-( 1*4)] @ r12 = in[15] | |
1136 | + ldr lr, [r1, #-(12*4)] @ lr = in[ 4] | |
1137 | + b 8f | |
1138 | +6: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9] | |
1139 | + ldr r11, [r1, #-( 2*4)] @ r11 = in[14] | |
1140 | + ldr r12, [r1, #-(13*4)] @ r12 = in[ 3] | |
1141 | + ldr lr, [r1, #-( 8*4)] @ lr = in[ 8] | |
1142 | + b 8f | |
1143 | +7: ldr r10, [r1, #-( 3*4)] @ r10 = in[13] | |
1144 | + ldr r11, [r1, #-(14*4)] @ r11 = in[ 2] | |
1145 | + ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7] | |
1146 | + ldr lr, [r1, #-( 4*4)] @ lr = in[12] | |
1147 | + | |
1148 | +8: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
1149 | + eor r6, r3, r4 @ r6 = (b ^ c) | |
1150 | + and r6, r6, r5 @ r6 = ((b ^ c) & d) | |
1151 | + eor r6, r6, r4 @ r6 = (((b ^ c) & d) ^ c) | |
1152 | + add r2, r2, r6 @ a = (((b ^ c) & d) ^ c) + a | |
1153 | + add r2, r2, r10 @ a = (((b ^ c) & d) ^ c) + a + (in[x] + MD5MagicData[i]) | |
1154 | + add r2, r3, r2, ROR #(32 - 5) @ a = b + (a rotated left by 5 places) | |
1155 | + | |
1156 | + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1] | |
1157 | + eor r7, r2, r3 @ r7 = (a ^ b) | |
1158 | + and r7, r7, r4 @ r7 = ((a ^ b) & c) | |
1159 | + eor r7, r7, r3 @ r7 = (((a ^ b) & c) ^ b) | |
1160 | + add r5, r5, r7 @ d = (((a ^ b) & c) ^ b) + d | |
1161 | + add r5, r5, r11 @ d = (((a ^ b) & c) ^ b) + d + (in[x] + MD5MagicData[i+1]) | |
1162 | + add r5, r2, r5, ROR #(32 - 9) @ d = a + (d rotated left by 9 places) | |
1163 | + | |
1164 | + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2] | |
1165 | + eor r8, r5, r2 @ r8 = (d ^ a) | |
1166 | + and r8, r8, r3 @ r8 = ((d ^ a) & b) | |
1167 | + eor r8, r8, r2 @ r8 = (((d ^ a) & b) ^ a) | |
1168 | + add r4, r4, r8 @ c = (((d ^ a) & b) ^ a) + c | |
1169 | + add r4, r4, r12 @ c = (((d ^ a) & b) ^ a) + c + (in[x] + MD5MagicData[i+2]) | |
1170 | + add r4, r5, r4, ROR #(32 - 14) @ c = d + (c rotated left by 14 places) | |
1171 | + | |
1172 | + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3] | |
1173 | + eor r9, r4, r5 @ r9 = (c ^ d) | |
1174 | + and r9, r9, r2 @ r9 = ((c ^ d) & a) | |
1175 | + eor r9, r9, r5 @ r9 = (((c ^ d) & a) ^ d) | |
1176 | + add r3, r3, r9 @ b = (((c ^ d) & a) ^ d) + b | |
1177 | + add r3, r3, lr @ b = (((c ^ d) & a) ^ d) + b + (in[x] + MD5MagicData[i+3]) | |
1178 | + add r3, r4, r3, ROR #(32 - 20) @ b = c + (b rotated left by 20 places) | |
1179 | + | |
1180 | + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
1181 | + add pc, pc, r10 @ and branch to next state | |
1182 | + | |
1183 | +9: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5] | |
1184 | + ldr r11, [r1, #-( 8*4)] @ r11 = in[ 8] | |
1185 | + ldr r12, [r1, #-( 5*4)] @ r12 = in[11] | |
1186 | + ldr lr, [r1, #-( 2*4)] @ lr = in[14] | |
1187 | + b 13f | |
1188 | +10: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1] | |
1189 | + ldr r11, [r1, #-(12*4)] @ r11 = in[ 4] | |
1190 | + ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7] | |
1191 | + ldr lr, [r1, #-( 6*4)] @ lr = in[10] | |
1192 | + b 13f | |
1193 | +11: ldr r10, [r1, #-( 3*4)] @ r10 = in[13] | |
1194 | + ldr r11, [r1, #-(16*4)] @ r11 = in[ 0] | |
1195 | + ldr r12, [r1, #-(13*4)] @ r12 = in[ 3] | |
1196 | + ldr lr, [r1, #-(10*4)] @ lr = in[ 6] | |
1197 | + b 13f | |
1198 | +12: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9] | |
1199 | + ldr r11, [r1, #-( 4*4)] @ r11 = in[12] | |
1200 | + ldr r12, [r1, #-( 1*4)] @ r12 = in[15] | |
1201 | + ldr lr, [r1, #-(14*4)] @ lr = in[ 2] | |
1202 | + | |
1203 | +13: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
1204 | + add r2, r2, r10 @ a += in[x] + MD5MagicData[i] | |
1205 | + eor r6, r3, r4 @ r6 = (b ^ c) | |
1206 | + eor r10, r6, r5 @ r10 = (b ^ c ^ d) | |
1207 | + add r2, r2, r10 @ a += (b ^ c ^ d) | |
1208 | + add r2, r3, r2, ROR #(32 - 4) @ a = b + (a rotated left by 4 places) | |
1209 | + | |
1210 | + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1] | |
1211 | + eor r7, r2, r6 @ r7 = (a ^ b ^ c) | |
1212 | + add r5, r5, r7 @ d = (a ^ b ^ c) + d | |
1213 | + add r5, r5, r11 @ d = (a ^ b ^ c) + d + (in[x] + MD5MagicData[i+1]) | |
1214 | + add r5, r2, r5, ROR #(32 - 11) @ d = a + (d rotated left by 11 places) | |
1215 | + | |
1216 | + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2] | |
1217 | + add r4, r4, r12 @ c += in[x] + MD5MagicData[i+2] | |
1218 | + eor r8, r5, r2 @ r8 = (d ^ a) | |
1219 | + eor r12, r8, r3 @ r12 = (d ^ a ^ b) | |
1220 | + add r4, r4, r12 @ c += (d ^ a ^ b) | |
1221 | + add r4, r5, r4, ROR #(32 - 16) @ c = d + (c rotated left by 16 places) | |
1222 | + | |
1223 | + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3] | |
1224 | + eor r9, r4, r8 @ r9 = (c ^ d ^ a) | |
1225 | + add r3, r3, r9 @ b = (c ^ d ^ a) + b | |
1226 | + add r3, r3, lr @ b = (c ^ d ^ a) + b + (in[x] + MD5MagicData[i+3]) | |
1227 | + add r3, r4, r3, ROR #(32 - 23) @ b = c + (b rotated left by 23 places) | |
1228 | + | |
1229 | + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
1230 | + add pc, pc, r10 @ and branch to next state | |
1231 | + | |
1232 | +14: ldr r10, [r1, #-(16*4)] @ r10 = in[ 0] | |
1233 | + ldr r11, [r1, #-( 9*4)] @ r11 = in[ 7] | |
1234 | + ldr r12, [r1, #-( 2*4)] @ r12 = in[14] | |
1235 | + ldr lr, [r1, #-(11*4)] @ lr = in[ 5] | |
1236 | + b 18f | |
1237 | +15: ldr r10, [r1, #-( 4*4)] @ r10 = in[12] | |
1238 | + ldr r11, [r1, #-(13*4)] @ r11 = in[ 3] | |
1239 | + ldr r12, [r1, #-( 6*4)] @ r12 = in[10] | |
1240 | + ldr lr, [r1, #-(15*4)] @ lr = in[ 1] | |
1241 | + b 18f | |
1242 | +16: ldr r10, [r1, #-( 8*4)] @ r10 = in[ 8] | |
1243 | + ldr r11, [r1, #-( 1*4)] @ r11 = in[15] | |
1244 | + ldr r12, [r1, #-(10*4)] @ r12 = in[ 6] | |
1245 | + ldr lr, [r1, #-( 3*4)] @ lr = in[13] | |
1246 | + b 18f | |
1247 | +17: ldr r10, [r1, #-(12*4)] @ r10 = in[ 4] | |
1248 | + ldr r11, [r1, #-( 5*4)] @ r11 = in[11] | |
1249 | + ldr r12, [r1, #-(14*4)] @ r12 = in[ 2] | |
1250 | + ldr lr, [r1, #-( 7*4)] @ lr = in[ 9] | |
1251 | + | |
1252 | +18: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i] | |
1253 | + add r2, r2, r10 @ a += in[x] + MD5MagicData[i] | |
1254 | + mvn r6, r5 @ r6 = ( ~d) | |
1255 | + orr r6, r6, r3 @ r6 = (b | ~d) | |
1256 | + eor r6, r6, r4 @ r6 = (c ^ (b | ~d)) | |
1257 | + add r2, r2, r6 @ a += (c ^ (b | ~d)) | |
1258 | + add r2, r3, r2, ROR #(32 - 6) @ a = b + (a rotated left by 6 places) | |
1259 | + | |
1260 | + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i] | |
1261 | + add r5, r5, r11 @ d += in[x] + MD5MagicData[i] | |
1262 | + mvn r7, r4 @ r7 = ( ~c) | |
1263 | + orr r7, r7, r2 @ r7 = (a | ~c) | |
1264 | + eor r7, r7, r3 @ r7 = (b ^ (a | ~c)) | |
1265 | + add r5, r5, r7 @ d += (b ^ (a | ~c)) | |
1266 | + add r5, r2, r5, ROR #(32 - 10) @ d = a + (d rotated left by 10 places) | |
1267 | + | |
1268 | + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i] | |
1269 | + add r4, r4, r12 @ c += in[x] + MD5MagicData[i] | |
1270 | + mvn r8, r3 @ r8 = ( ~b) | |
1271 | + orr r8, r8, r5 @ r8 = (d | ~b) | |
1272 | + eor r8, r8, r2 @ r8 = (a ^ (d | ~b)) | |
1273 | + add r4, r4, r8 @ c += (a ^ (d | ~b)) | |
1274 | + add r4, r5, r4, ROR #(32 - 15) @ c = d + (c rotated left by 15 places) | |
1275 | + | |
1276 | + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i] | |
1277 | + add r3, r3, lr @ b += in[x] + MD5MagicData[i] | |
1278 | + mvn r9, r2 @ r9 = ( ~a) | |
1279 | + orr r9, r9, r4 @ r9 = (c | ~a) | |
1280 | + eor r9, r9, r5 @ r9 = (d ^ (c | ~a)) | |
1281 | + add r3, r3, r9 @ b += (d ^ (c | ~a)) | |
1282 | + add r3, r4, r3, ROR #(32 - 21) @ b = c + (b rotated left by 21 places) | |
1283 | + | |
1284 | + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData | |
1285 | + add pc, pc, r10 @ and branch to next state | |
1286 | + | |
1287 | +19: ldmia sp, { r0, r10 } @ fetch 'buf' and 'repeat' from the stack | |
1288 | + ldmia r0, { r6 - r9 } @ r6 = buf[0], r7 = buf[1], r8 = buf[2], r9 = buf[3] (original values..) | |
1289 | + subs r10, r10, #1 | |
1290 | + strne r10, [sp, #4] | |
1291 | + add r2, r6, r2 | |
1292 | + add r3, r7, r3 | |
1293 | + add r4, r8, r4 | |
1294 | + add r5, r9, r5 | |
1295 | + stmia r0, { r2 - r5 } | |
1296 | + bne 2b | |
1297 | + ldmia sp!, { r0, r2, r4 - r11, pc } @ restore all callee saved registers and return | |
1298 | + | |
1299 | + | |
1300 | + @ -- | |
1301 | + @ static void __UnalignedMD5Transform (uint32_t *buf, const uint8_t *in, int repeat); | |
1302 | + @ -- | |
1303 | + | |
1304 | +__UnalignedMD5Transform: | |
1305 | + | |
1306 | + stmdb sp!, { r4 - r7, lr } | |
1307 | + movs r4, r2, lsl #6 @ r4 = (repeat * 64) | |
1308 | + ldmeqia sp!, { r4 - r7, pc } @ if ((repeat * 64) == 0) return; | |
1309 | + mov r5, r0 @ r5 = state | |
1310 | + mov r6, r1 @ r6 = in | |
1311 | + sub sp, sp, #256 @ create 256 byte temp buffer | |
1312 | +1: cmp r4, #256 | |
1313 | + mov r0, sp | |
1314 | + movcc r7, r4 | |
1315 | + movcs r7, #256 @ r7 = (blockCount * 64) = min((repeat * 64), (4 * 64)) | |
1316 | + mov r1, r6 | |
1317 | + mov r2, r7 | |
1318 | + bl memcpy @ memcpy (blockBuffer, in, (blockCount * 64)); | |
1319 | + mov r0, r5 | |
1320 | + mov r1, sp | |
1321 | + mov r2, r7, lsr #6 | |
1322 | + bl __MD5Transform @ __MD5Transform (state, blockBuffer, blockCount); | |
1323 | + subs r4, r4, #256 @ (repeat * 64) -= (4 * 64); | |
1324 | + add r6, r6, #256 @ in += (4 * 64); | |
1325 | + bgt 1b @ loop while (repeat > 0) | |
1326 | + add sp, sp, #256 @ return temp buffer to stack | |
1327 | + ldmia sp!, { r4 - r7, pc } @ return | |
1328 | + | |
1329 | + | |
1330 | +#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ | |
1331 | + | |
1332 | + | |
1333 | diff -urN -x .git dietlibc-0.33/arm/mmap.S dietlibc/arm/mmap.S | |
1334 | --- dietlibc-0.33/arm/mmap.S 2008-12-10 20:00:58.000000000 +0000 | |
1335 | +++ dietlibc/arm/mmap.S 2015-01-01 12:14:43.454938895 +0000 | |
1336 | @@ -1,3 +1,5 @@ | |
1337 | +#include "arm-features.h" | |
1338 | + | |
1339 | #include <errno.h> | |
1340 | #include "syscalls.h" | |
1341 | ||
1342 | @@ -28,7 +30,7 @@ | |
1343 | ldr r4, [sp], #4 | |
1344 | ldr r5, [sp], #4 | |
1345 | cmn r0, #4096 | |
1346 | - mov pc, lr @ return | |
1347 | + RET | |
1348 | ||
1349 | #else | |
1350 | ||
1351 | diff -urN -x .git dietlibc-0.33/arm/setjmp.S dietlibc/arm/setjmp.S | |
1352 | --- dietlibc-0.33/arm/setjmp.S 2008-12-10 20:00:58.000000000 +0000 | |
1353 | +++ dietlibc/arm/setjmp.S 2015-01-01 12:14:43.454938895 +0000 | |
1354 | @@ -1,17 +1,41 @@ | |
1355 | -.text | |
1356 | -.weak setjmp | |
1357 | -setjmp: | |
1358 | -.global __setjmp | |
1359 | -__setjmp: | |
1360 | +#include "arm-features.h" | |
1361 | + | |
1362 | +FUNC_START_WEAK setjmp | |
1363 | +FUNC_START __setjmp | |
1364 | mov r1, #0 | |
1365 | -.global __sigsetjmp | |
1366 | -__sigsetjmp: | |
1367 | -.weak sigsetjmp | |
1368 | -sigsetjmp: | |
1369 | -#ifndef __SOFTFP__ | |
1370 | - sfm f4, 4, [r0], #48 | |
1371 | +FUNC_END __setjmp | |
1372 | +FUNC_END setjmp | |
1373 | + | |
1374 | +FUNC_START_WEAK sigsetjmp | |
1375 | +FUNC_START __sigsetjmp | |
1376 | + | |
1377 | +#ifdef DIET_HAVE_COPROC_REGS | |
1378 | + /* we have to work on a copy of 'r0' (jmpbuf *) */ | |
1379 | + mov ip, r0 | |
1380 | +#endif | |
1381 | + | |
1382 | +#ifndef __SOFTFP__ | |
1383 | +# if __ARM_ARCH__ >= 7 | |
1384 | + vstmia ip!, {d0-d15} | |
1385 | +# ifdef __ARM_NEON__ | |
1386 | + vstmia ip!, {d16-d31} | |
1387 | +# endif | |
1388 | +# else | |
1389 | + sfm f4, 4, [ip]! | |
1390 | +# endif | |
1391 | +#endif | |
1392 | + | |
1393 | +#ifdef __IWMMXT__ | |
1394 | +# warning "setjmp will not save iwmmxt coprocessor registers" | |
1395 | #endif | |
1396 | + | |
1397 | +#ifndef DIET_HAVE_COPROC_REGS | |
1398 | stmia r0, {r4-r11, sp, lr} | |
1399 | - sub r0, r0, #48 | |
1400 | - b __sigjmp_save | |
1401 | ||
1402 | +#else | |
1403 | + stmia ip!, {r4-r11, sp, lr} | |
1404 | +#endif | |
1405 | + | |
1406 | + b __sigjmp_save | |
1407 | +FUNC_END __sigsetjmp | |
1408 | +FUNC_END sigsetjmp | |
1409 | diff -urN -x .git dietlibc-0.33/arm/start.S dietlibc/arm/start.S | |
1410 | --- dietlibc-0.33/arm/start.S 2012-01-24 18:24:24.000000000 +0000 | |
1411 | +++ dietlibc/arm/start.S 2015-01-01 12:14:43.454938895 +0000 | |
1412 | @@ -1,23 +1,10 @@ | |
1413 | - | |
1414 | #include "dietfeatures.h" | |
1415 | #include "syscalls.h" | |
1416 | - | |
1417 | - .text | |
1418 | -#ifdef __ARM_EABI__ | |
1419 | - .align 4 | |
1420 | -#else | |
1421 | - .align 2 | |
1422 | -#endif | |
1423 | - | |
1424 | - .global _start | |
1425 | - .weak exit | |
1426 | - .global _exit | |
1427 | - | |
1428 | +#include "arm-features.h" | |
1429 | ||
1430 | #ifdef __ARM_EABI__ | |
1431 | ||
1432 | -_start: | |
1433 | - | |
1434 | +FUNC_START _start | |
1435 | mov fp, #0 @ clear the frame pointer | |
1436 | ldr a1, [sp] @ argc | |
1437 | add a2, sp, #4 @ argv | |
1438 | @@ -25,27 +12,40 @@ | |
1439 | add a3, a2, a1, lsl #2 @ &argv[argc] | |
1440 | add a3, a3, #4 @ envp | |
1441 | str a3, [ip, #0] @ environ = envp | |
1442 | - bl main | |
1443 | - | |
1444 | + | |
1445 | +#ifdef WANT_ELFINFO | |
1446 | + mov r6, a3 @ work on a copy of a3 so that common | |
1447 | + @ 'main(argc, argv, envp)' function | |
1448 | + @ stays valid | |
1449 | +1: ldr r5, [r6], #4 @ load *envp and increment it | |
1450 | + cmp r5, #0 @ read value==0? | |
1451 | + bne 1b | |
1452 | + str r6, [ip, #4] @ __elfinfo = envp | |
1453 | +#endif | |
1454 | + | |
1455 | + bl CALL_IN_STARTCODE | |
1456 | + | |
1457 | @ | |
1458 | @ The exit status from main() is already in r0. | |
1459 | @ We need to branch to 'exit' in case we have linked with 'atexit'. | |
1460 | @ | |
1461 | bl exit | |
1462 | +FUNC_END _start | |
1463 | ||
1464 | -exit: | |
1465 | -_exit: | |
1466 | - | |
1467 | +FUNC_START _exit | |
1468 | +FUNC_START_WEAK exit | |
1469 | mov r7, #__NR_exit | |
1470 | swi 0 @ never returns. | |
1471 | ||
1472 | + .align 2 | |
1473 | .L3: .word environ | |
1474 | ||
1475 | - | |
1476 | -#else | |
1477 | +FUNC_END exit | |
1478 | +FUNC_END _exit | |
1479 | + | |
1480 | +#else | |
1481 | ||
1482 | - | |
1483 | -_start: | |
1484 | +FUNC_START _start | |
1485 | ||
1486 | #ifdef WANT_DYNAMIC | |
1487 | mov a4, a1 @ save dynamic ld.so _fini | |
1488 | @@ -59,11 +59,25 @@ | |
1489 | #ifdef __DYN_LIB | |
1490 | ldr sl, .L4 | |
1491 | 1: add sl, pc, sl | |
1492 | - str a3, [sl, ip] @ environ = envp | |
1493 | + str a3, [ip, sl]! @ environ = envp; ip = GOT(environ) | |
1494 | #else | |
1495 | str a3, [ip, #0] @ environ = envp | |
1496 | #endif | |
1497 | ||
1498 | +#ifdef WANT_ELFINFO | |
1499 | + mov r6, a3 @ work on a copy of a3 so that common | |
1500 | + @ 'main(argc, argv, envp)' function | |
1501 | + @ stays valid | |
1502 | +1: ldr r5, [r6], #4 @ load *envp and increment it | |
1503 | + cmp r5, #0 @ read value==0? | |
1504 | + bne 1b | |
1505 | +#ifdef __DYN_LIB | |
1506 | + str r6, [ip, sl] @ __elfinfo = envp | |
1507 | +#else | |
1508 | + str r6, [ip, #4] @ __elfinfo = envp | |
1509 | +#endif | |
1510 | +#endif | |
1511 | + | |
1512 | #ifdef PROFILING | |
1513 | stmdb sp!, { r0 - r3 } | |
1514 | ldr r0, .L5 | |
1515 | @@ -83,18 +97,20 @@ | |
1516 | @ We need to branch to 'exit' in case we have linked with 'atexit'. | |
1517 | @ | |
1518 | bl exit | |
1519 | +FUNC_END _start | |
1520 | ||
1521 | -exit: | |
1522 | -_exit: | |
1523 | - | |
1524 | +FUNC_START _exit | |
1525 | +FUNC_START_WEAK exit | |
1526 | #ifdef PROFILING | |
1527 | mov r4, r0 @ save a copy of exit status | |
1528 | bl _stop_monitor | |
1529 | mov r0, r4 | |
1530 | #endif | |
1531 | swi $__NR_exit @ never returns. | |
1532 | +FUNC_END exit | |
1533 | +FUNC_END _exit | |
1534 | ||
1535 | - | |
1536 | + .align 2 | |
1537 | #ifdef __DYN_LIB | |
1538 | .L3: .word environ(GOT) | |
1539 | .L4: .word _GLOBAL_OFFSET_TABLE_-(1b+8) | |
1540 | diff -urN -x .git dietlibc-0.33/arm/strcpy.S dietlibc/arm/strcpy.S | |
1541 | --- dietlibc-0.33/arm/strcpy.S 2005-08-05 00:29:18.000000000 +0000 | |
1542 | +++ dietlibc/arm/strcpy.S 2015-01-01 12:14:43.454938895 +0000 | |
1543 | @@ -1,10 +1,7 @@ | |
1544 | #include "dietfeatures.h" | |
1545 | +#include "arm-features.h" | |
1546 | ||
1547 | -.text | |
1548 | - .align 2 | |
1549 | - .global strcpy | |
1550 | - | |
1551 | -strcpy: | |
1552 | +FUNC_START strcpy | |
1553 | #ifndef WANT_SMALL_STRING_ROUTINES | |
1554 | mov ip, r0 | |
1555 | ands r2, r1, #3 | |
1556 | @@ -61,6 +58,5 @@ | |
1557 | ldrneb r2, [r1], #1 | |
1558 | #endif | |
1559 | bne .Lloop | |
1560 | - mov pc, lr | |
1561 | -.Lfe1: | |
1562 | - .size strcpy,.Lfe1-strcpy | |
1563 | + RET | |
1564 | +FUNC_END strcpy | |
1565 | diff -urN -x .git dietlibc-0.33/arm/strlen.S dietlibc/arm/strlen.S | |
1566 | --- dietlibc-0.33/arm/strlen.S 2005-08-05 00:29:18.000000000 +0000 | |
1567 | +++ dietlibc/arm/strlen.S 2015-01-01 12:14:43.454938895 +0000 | |
1568 | @@ -1,12 +1,7 @@ | |
1569 | #include "dietfeatures.h" | |
1570 | +#include "arm-features.h" | |
1571 | ||
1572 | - .text | |
1573 | - .align 2 | |
1574 | - | |
1575 | - .global strlen | |
1576 | - | |
1577 | -strlen: | |
1578 | - | |
1579 | +FUNC_START strlen | |
1580 | #if 0 | |
1581 | teq a1, #0 @ is string pointer NULL ?? | |
1582 | moveq pc, lr @ if so, return 0 | |
1583 | @@ -61,12 +56,10 @@ | |
1584 | sub a1, a1, a2 | |
1585 | #endif | |
1586 | ||
1587 | - mov pc, lr | |
1588 | + RET | |
1589 | ||
1590 | #ifndef WANT_SMALL_STRING_ROUTINES | |
1591 | .Lmagic: | |
1592 | .word 0x01010101 | |
1593 | #endif | |
1594 | - | |
1595 | -.Lstrlen: | |
1596 | - .size strlen,.Lstrlen-strlen | |
1597 | +FUNC_END strlen | |
1598 | diff -urN -x .git dietlibc-0.33/arm/syscalls.h dietlibc/arm/syscalls.h | |
1599 | --- dietlibc-0.33/arm/syscalls.h 2012-01-24 18:24:24.000000000 +0000 | |
1600 | +++ dietlibc/arm/syscalls.h 2015-01-01 12:14:43.454938895 +0000 | |
1601 | @@ -365,6 +365,38 @@ | |
1602 | #define __NR_fallocate (__NR_SYSCALL_BASE+352) | |
1603 | #define __NR_timerfd_settime (__NR_SYSCALL_BASE+353) | |
1604 | #define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354) | |
1605 | +#define __NR_signalfd4 (__NR_SYSCALL_BASE+355) | |
1606 | +#define __NR_eventfd2 (__NR_SYSCALL_BASE+356) | |
1607 | +#define __NR_epoll_create1 (__NR_SYSCALL_BASE+357) | |
1608 | +#define __NR_dup3 (__NR_SYSCALL_BASE+358) | |
1609 | +#define __NR_pipe2 (__NR_SYSCALL_BASE+359) | |
1610 | +#define __NR_inotify_init1 (__NR_SYSCALL_BASE+360) | |
1611 | +#define __NR_preadv (__NR_SYSCALL_BASE+361) | |
1612 | +#define __NR_pwritev (__NR_SYSCALL_BASE+362) | |
1613 | +#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363) | |
1614 | +#define __NR_perf_event_open (__NR_SYSCALL_BASE+364) | |
1615 | +#define __NR_recvmmsg (__NR_SYSCALL_BASE+365) | |
1616 | +#define __NR_accept4 (__NR_SYSCALL_BASE+366) | |
1617 | +#define __NR_fanotify_init (__NR_SYSCALL_BASE+367) | |
1618 | +#define __NR_fanotify_mark (__NR_SYSCALL_BASE+368) | |
1619 | +#define __NR_prlimit64 (__NR_SYSCALL_BASE+369) | |
1620 | +#define __NR_name_to_handle_at (__NR_SYSCALL_BASE+370) | |
1621 | +#define __NR_open_by_handle_at (__NR_SYSCALL_BASE+371) | |
1622 | +#define __NR_clock_adjtime (__NR_SYSCALL_BASE+372) | |
1623 | +#define __NR_syncfs (__NR_SYSCALL_BASE+373) | |
1624 | +#define __NR_sendmmsg (__NR_SYSCALL_BASE+374) | |
1625 | +#define __NR_setns (__NR_SYSCALL_BASE+375) | |
1626 | +#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376) | |
1627 | +#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377) | |
1628 | +#define __NR_kcmp (__NR_SYSCALL_BASE+378) | |
1629 | +#define __NR_finit_module (__NR_SYSCALL_BASE+379) | |
1630 | +#define __NR_sched_setattr (__NR_SYSCALL_BASE+380) | |
1631 | +#define __NR_sched_getattr (__NR_SYSCALL_BASE+381) | |
1632 | +#define __NR_renameat2 (__NR_SYSCALL_BASE+382) | |
1633 | +#define __NR_seccomp (__NR_SYSCALL_BASE+383) | |
1634 | +#define __NR_getrandom (__NR_SYSCALL_BASE+384) | |
1635 | +#define __NR_memfd_create (__NR_SYSCALL_BASE+385) | |
1636 | + | |
1637 | ||
1638 | /* | |
1639 | * The following SWIs are ARM private. | |
1640 | @@ -700,9 +732,9 @@ | |
1641 | #define __ARGS_getpeername 0 | |
1642 | #define __ARGS_socketpair 0 | |
1643 | #define __ARGS_send 0 | |
1644 | -#define __ARGS_sendto 0 | |
1645 | +#define __ARGS_sendto 6 | |
1646 | #define __ARGS_recv 0 | |
1647 | -#define __ARGS_recvfrom 0 | |
1648 | +#define __ARGS_recvfrom 6 | |
1649 | #define __ARGS_shutdown 0 | |
1650 | #define __ARGS_setsockopt 0 | |
1651 | #define __ARGS_getsockopt 0 | |
1652 | @@ -768,73 +800,59 @@ | |
1653 | #define __ARGS_timerfd_settime 0 | |
1654 | #define __ARGS_timerfd_gettime 0 | |
1655 | ||
1656 | +#define __ARGS_signalfd4 0 | |
1657 | +#define __ARGS_eventfd2 0 | |
1658 | +#define __ARGS_epoll_create1 0 | |
1659 | +#define __ARGS_dup3 0 | |
1660 | +#define __ARGS_pipe2 0 | |
1661 | +#define __ARGS_inotify_init1 0 | |
1662 | +#define __ARGS_preadv 0 | |
1663 | +#define __ARGS_pwritev 0 | |
1664 | +#define __ARGS_rt_tgsigqueueinfo 0 | |
1665 | +#define __ARGS_perf_event_open 1 | |
1666 | +#define __ARGS_recvmmsg 1 | |
1667 | +#define __ARGS_accept4 0 | |
1668 | +#define __ARGS_fanotify_init 0 | |
1669 | +#define __ARGS_fanotify_mark 1 | |
1670 | +#define __ARGS_prlimit64 0 | |
1671 | +#define __ARGS_name_to_handle_at 1 | |
1672 | +#define __ARGS_open_by_handle_at 0 | |
1673 | +#define __ARGS_clock_adjtime 0 | |
1674 | +#define __ARGS_syncfs 0 | |
1675 | +#define __ARGS_sendmmsg 0 | |
1676 | +#define __ARGS_setns 0 | |
1677 | +#define __ARGS_process_vm_readv 1 | |
1678 | +#define __ARGS_process_vm_writev 1 | |
1679 | +#define __ARGS_kcmp 1 | |
1680 | +#define __ARGS_finit_module 0 | |
1681 | + | |
1682 | ||
1683 | #ifdef __ASSEMBLER__ | |
1684 | ||
1685 | -#ifdef __ARM_EABI__ | |
1686 | +#include "arm-features.h" | |
1687 | ||
1688 | #define syscall_weak(name,wsym,sym) __syscall_weak __NR_##name, wsym, sym, __ARGS_##name | |
1689 | .macro __syscall_weak name wsym sym typ | |
1690 | -.text | |
1691 | -.type \wsym,function | |
1692 | -.weak \wsym | |
1693 | -\wsym: | |
1694 | -.type \sym,function | |
1695 | -.global \sym | |
1696 | -\sym: | |
1697 | - stmfd sp!,{r4,r5,r7,lr} | |
1698 | - ldr r4, [sp,#16] | |
1699 | - ldr r5, [sp,#20] | |
1700 | - ldr r7, =\name | |
1701 | - swi 0 | |
1702 | - b __unified_syscall | |
1703 | +FUNC_START_WEAK \wsym | |
1704 | +__syscall \name, \sym, \typ | |
1705 | +FUNC_END \wsym | |
1706 | .endm | |
1707 | ||
1708 | +#ifdef __ARM_EABI__ | |
1709 | ||
1710 | #define syscall(name,sym) __syscall __NR_##name, sym, __ARGS_##name | |
1711 | .macro __syscall name sym typ | |
1712 | -.text | |
1713 | -.type \sym,function | |
1714 | -.global \sym | |
1715 | -\sym: | |
1716 | - stmfd sp!,{r4,r5,r7,lr} | |
1717 | - ldr r4, [sp,#16] | |
1718 | - ldr r5, [sp,#20] | |
1719 | - ldr r7, =\name | |
1720 | - swi 0 | |
1721 | - b __unified_syscall | |
1722 | +FUNC_START \sym | |
1723 | + ldr ip, =\name | |
1724 | + b __unified_syscall_swi | |
1725 | +FUNC_END \sym | |
1726 | .endm | |
1727 | ||
1728 | #else | |
1729 | ||
1730 | -#define syscall_weak(name,wsym,sym) __syscall_weak $__NR_##name, wsym, sym, __ARGS_##name | |
1731 | -.macro __syscall_weak name wsym sym typ | |
1732 | -.text | |
1733 | -.type \wsym,function | |
1734 | -.weak \wsym | |
1735 | -\wsym: | |
1736 | -.type \sym,function | |
1737 | -.global \sym | |
1738 | -\sym: | |
1739 | -.ifgt \typ | |
1740 | - mov ip, sp | |
1741 | - stmfd sp!,{r4, r5, r6} | |
1742 | - ldmia ip, {r4, r5, r6} | |
1743 | -.endif | |
1744 | - swi \name | |
1745 | -.ifgt \typ | |
1746 | - b __unified_syscall4 | |
1747 | -.else | |
1748 | - b __unified_syscall | |
1749 | -.endif | |
1750 | -.endm | |
1751 | - | |
1752 | #define syscall(name,sym) __syscall $__NR_##name, sym, __ARGS_##name | |
1753 | .macro __syscall name sym typ | |
1754 | -.text | |
1755 | -.type \sym,function | |
1756 | -.global \sym | |
1757 | -\sym: | |
1758 | +FUNC_START \sym | |
1759 | .ifgt \typ | |
1760 | mov ip, sp | |
1761 | stmfd sp!,{r4, r5, r6} | |
1762 | @@ -846,6 +864,7 @@ | |
1763 | .else | |
1764 | b __unified_syscall | |
1765 | .endif | |
1766 | +FUNC_END \sym | |
1767 | .endm | |
1768 | ||
1769 | #endif | |
1770 | diff -urN -x .git dietlibc-0.33/arm/__testandset.S dietlibc/arm/__testandset.S | |
1771 | --- dietlibc-0.33/arm/__testandset.S 2001-03-09 19:30:52.000000000 +0000 | |
1772 | +++ dietlibc/arm/__testandset.S 2015-01-01 12:14:43.454938895 +0000 | |
1773 | @@ -1,7 +1,15 @@ | |
1774 | -.text | |
1775 | -.global __testandset | |
1776 | -__testandset: | |
1777 | +#include "arm-features.h" | |
1778 | + | |
1779 | +FUNC_START __testandset | |
1780 | mov r2, r0 | |
1781 | mov r1, #1 | |
1782 | +# if __ARM_ARCH__ < 6 | |
1783 | swp r0, r1, [r2] | |
1784 | - mov pc, lr | |
1785 | +# else | |
1786 | +1: ldrex r0, [r2] | |
1787 | + strex r3, r1, [r2] | |
1788 | + cmp r3, #0 | |
1789 | + bne 1b | |
1790 | +# endif | |
1791 | + RET | |
1792 | +FUNC_END __testandset | |
1793 | diff -urN -x .git dietlibc-0.33/arm/unified.S dietlibc/arm/unified.S | |
1794 | --- dietlibc-0.33/arm/unified.S 2012-01-24 18:24:24.000000000 +0000 | |
1795 | +++ dietlibc/arm/unified.S 2015-01-01 12:14:43.454938895 +0000 | |
1796 | @@ -1,22 +1,29 @@ | |
1797 | - | |
1798 | #include <dietfeatures.h> | |
1799 | - | |
1800 | - .text | |
1801 | -#ifdef __ARM_EABI__ | |
1802 | - .align 4 | |
1803 | -#else | |
1804 | - .align 2 | |
1805 | -#endif | |
1806 | - .global __unified_syscall | |
1807 | - .global __unified_syscall4 | |
1808 | - | |
1809 | +#include "arm-features.h" | |
1810 | ||
1811 | #ifdef __ARM_EABI__ | |
1812 | ||
1813 | -__unified_syscall4: | |
1814 | -__unified_syscall: | |
1815 | - | |
1816 | +/* expects: | |
1817 | + * r0-r3 ... syscall arguments 0-3 | |
1818 | + * ip ... syscall number | |
1819 | + */ | |
1820 | +FUNC_START __unified_syscall_swi | |
1821 | + .hidden __unified_syscall_swi | |
1822 | + stmfd sp!,{r4,r5,r7,lr} | |
1823 | + mov r7, ip | |
1824 | + LOAD_ARG4_5 | |
1825 | + swi 0 | |
1826 | + /* fallthrough to __unified4_syscall */ | |
1827 | +FUNC_END __unified_syscall_swi | |
1828 | + | |
1829 | +/* expects: | |
1830 | + * r0 ... syscall return value | |
1831 | + * original r4-r7 + lr on stack | |
1832 | + */ | |
1833 | +FUNC_START __unified_syscall | |
1834 | + .hidden __unified_syscall | |
1835 | cmn r0, #4096 | |
1836 | +#ifndef WANT_THREAD_SAFE | |
1837 | rsbcs r2, r0, #0 | |
1838 | ldrcs r3, 1f | |
1839 | mvncs r0, #0 | |
1840 | @@ -25,17 +32,28 @@ | |
1841 | .balign 4 | |
1842 | 1: | |
1843 | .word errno | |
1844 | - | |
1845 | +#else | |
1846 | + bcc 1f | |
1847 | + rsb r4, r0, #0 | |
1848 | + bl __errno_location | |
1849 | + str r4, [r0] | |
1850 | + mvn r0, #0 | |
1851 | +1: | |
1852 | + ldmfd sp!,{r4,r5,r7,pc} | |
1853 | +#endif | |
1854 | +FUNC_END __unified_syscall | |
1855 | + | |
1856 | /* here we go and "reuse" the return for weak-void functions */ | |
1857 | #include "dietuglyweaks.h" | |
1858 | ||
1859 | - mov pc, lr @ return | |
1860 | + RET | |
1861 | ||
1862 | -#else | |
1863 | - | |
1864 | -__unified_syscall4: | |
1865 | +#else | |
1866 | + | |
1867 | +FUNC_START __unified_syscall4 | |
1868 | ldmia sp!, {r4, r5, r6} | |
1869 | -__unified_syscall: | |
1870 | + | |
1871 | +FUNC_START __unified_syscall | |
1872 | cmn r0, #4096 | |
1873 | movcc pc, lr @ return value comes direct from kernel. | |
1874 | ||
1875 | @@ -53,10 +71,13 @@ | |
1876 | /* here we go and "reuse" the return for weak-void functions */ | |
1877 | #include "dietuglyweaks.h" | |
1878 | ||
1879 | - mov pc, lr @ return | |
1880 | + RET | |
1881 | ||
1882 | #ifndef WANT_THREAD_SAFE | |
1883 | +.align 2 | |
1884 | .L0: .long errno | |
1885 | #endif | |
1886 | +FUNC_END __unified_syscall | |
1887 | +FUNC_END __unified_syscall4 | |
1888 | ||
1889 | #endif | |
1890 | diff -urN -x .git dietlibc-0.33/arm/waitpid.S dietlibc/arm/waitpid.S | |
1891 | --- dietlibc-0.33/arm/waitpid.S 2008-12-10 20:00:58.000000000 +0000 | |
1892 | +++ dietlibc/arm/waitpid.S 2015-01-01 12:14:43.454938895 +0000 | |
1893 | @@ -1,15 +1,8 @@ | |
1894 | -.text | |
1895 | -#ifdef __ARM_EABI__ | |
1896 | -.align 4 | |
1897 | -#else | |
1898 | -.align 2 | |
1899 | -#endif | |
1900 | -.weak waitpid | |
1901 | -.type waitpid, %function | |
1902 | -waitpid: | |
1903 | -.global __libc_waitpid | |
1904 | -.type __libc_waitpid, %function | |
1905 | -__libc_waitpid: | |
1906 | - mov r3, #0 | |
1907 | - b wait4 | |
1908 | - .size waitpid, .-waitpid | |
1909 | +#include "arm-features.h" | |
1910 | + | |
1911 | +FUNC_START_WEAK waitpid | |
1912 | +FUNC_START __libc_waitpid | |
1913 | + mov r3, #0 | |
1914 | + b wait4 | |
1915 | +FUNC_END __libc_waitpid | |
1916 | +FUNC_END waitpid | |
1917 | diff -urN -x .git dietlibc-0.33/CHANGES dietlibc/CHANGES | |
1918 | --- dietlibc-0.33/CHANGES 2012-11-02 11:17:28.000000000 +0000 | |
1919 | +++ dietlibc/CHANGES 2015-01-01 12:14:43.451605563 +0000 | |
1920 | @@ -1,3 +1,19 @@ | |
1921 | +0.34: | |
1922 | + move stpcpy from libcompat to lib as it is now part of POSIX (Enrico Scholz) | |
1923 | + add linux/seccomp.h linux/prctl.h linux/audit.h linux/elf-em.h linux/filter.h | |
1924 | + SECURITY: make sure all assembler files mark the stack non-executable so | |
1925 | + the kernel can map the stack of the whole program as non-executable | |
1926 | + support compiling with clang (no cross compiling yet, and the resulting | |
1927 | + binary code is significantly larger than with gcc) | |
1928 | + implement experimental C11 threads | |
1929 | + fix fgets (Andreas Förster) | |
1930 | + add eventfd, inotify_init1, epoll_init1, accept4, recvmmsg, sendmmsg | |
1931 | + add dup3, fanotify_init, fanotify_mark, signalfd4, timerfd_settime | |
1932 | + add timerfd_gettime, setns, memfd_create, getrandom, syncfs | |
1933 | + add preadv, pwritev | |
1934 | + add getcontext, setcontext, makecontext, swapcontext (i386 and x86_64 only for now) | |
1935 | + add implementation of hsearch and friends | |
1936 | + | |
1937 | 0.33: | |
1938 | first stab at getting TLS to work in actual threads | |
1939 | use fs: to find current thread on x86_64 | |
1940 | diff -urN -x .git dietlibc-0.33/contrib/dnsd.c dietlibc/contrib/dnsd.c | |
1941 | --- dietlibc-0.33/contrib/dnsd.c 2010-09-25 17:03:25.000000000 +0000 | |
1942 | +++ dietlibc/contrib/dnsd.c 2015-01-01 12:14:43.458272230 +0000 | |
1943 | @@ -281,55 +281,54 @@ | |
1944 | } | |
1945 | ||
1946 | static void init_sockets(int* sock6,int* sock4,int port,char* v6ip,char* v4ip) { | |
1947 | - int s4,s6; | |
1948 | + int _s4,_s6; | |
1949 | int one=1; | |
1950 | *sock6=-1; *sock4=-1; | |
1951 | - s6=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); | |
1952 | - s4=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); | |
1953 | - if (s4==-1 && s6==-1) { | |
1954 | + _s6=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); | |
1955 | + _s4=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); | |
1956 | + if (_s4==-1 && _s6==-1) { | |
1957 | perror("socket"); | |
1958 | return; | |
1959 | } | |
1960 | - if (s6!=-1) { | |
1961 | - setsockopt(s6,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one)); | |
1962 | + if (_s6!=-1) { | |
1963 | + setsockopt(_s6,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one)); | |
1964 | memset(&sa6,0,sizeof(sa6)); | |
1965 | sa6.sin6_family=PF_INET6; | |
1966 | sa6.sin6_port=htons(port); | |
1967 | - if (bind(s6,(struct sockaddr*)&sa6,sizeof(struct sockaddr_in6))==-1) { | |
1968 | + if (bind(_s6,(struct sockaddr*)&sa6,sizeof(struct sockaddr_in6))==-1) { | |
1969 | perror("bind IPv6"); | |
1970 | - close(s6); | |
1971 | - s6=-1; | |
1972 | + close(_s6); | |
1973 | + _s6=-1; | |
1974 | } | |
1975 | } | |
1976 | - if (s4!=-1) { | |
1977 | - setsockopt(s4,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one)); | |
1978 | + if (_s4!=-1) { | |
1979 | + setsockopt(_s4,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one)); | |
1980 | memset(&sa4,0,sizeof(sa4)); | |
1981 | sa4.sin_family=PF_INET; | |
1982 | sa4.sin_port=htons(port); | |
1983 | - if (bind(s4,(struct sockaddr*)&sa4,sizeof(struct sockaddr_in))==-1) { | |
1984 | - if (errno!=EADDRINUSE || s6==-1) | |
1985 | + if (bind(_s4,(struct sockaddr*)&sa4,sizeof(struct sockaddr_in))==-1) { | |
1986 | + if (errno!=EADDRINUSE || _s6==-1) | |
1987 | perror("bind IPv4"); | |
1988 | - close(s4); | |
1989 | - s4=-1; | |
1990 | + close(_s4); | |
1991 | + _s4=-1; | |
1992 | } | |
1993 | } | |
1994 | - if (s4==-1 && s6==-1) return; | |
1995 | + if (_s4==-1 && _s6==-1) return; | |
1996 | ||
1997 | { | |
1998 | int val=255; | |
1999 | - int one=1; | |
2000 | - if (s6!=-1) { | |
2001 | + if (_s6!=-1) { | |
2002 | struct ipv6_mreq opt; | |
2003 | - setsockopt(s6,IPPROTO_IPV6,IPV6_UNICAST_HOPS,&val,sizeof(val)); | |
2004 | - setsockopt(s6,IPPROTO_IPV6,IPV6_MULTICAST_LOOP,&one,sizeof(one)); | |
2005 | + setsockopt(_s6,IPPROTO_IPV6,IPV6_UNICAST_HOPS,&val,sizeof(val)); | |
2006 | + setsockopt(_s6,IPPROTO_IPV6,IPV6_MULTICAST_LOOP,&one,sizeof(one)); | |
2007 | memcpy(&opt.ipv6mr_multiaddr,v6ip,16); | |
2008 | opt.ipv6mr_interface=0; | |
2009 | - setsockopt(s6,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt); | |
2010 | - setsockopt(s6,IPPROTO_IPV6,IPV6_PKTINFO,&one,sizeof one); | |
2011 | + setsockopt(_s6,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt); | |
2012 | + setsockopt(_s6,IPPROTO_IPV6,IPV6_PKTINFO,&one,sizeof one); | |
2013 | } | |
2014 | { | |
2015 | struct ip_mreq opt; | |
2016 | - int s=(s4==-1?s6:s4); | |
2017 | + int s=(_s4==-1?_s6:_s4); | |
2018 | setsockopt(s,SOL_IP,IP_TTL,&val,sizeof(val)); | |
2019 | memcpy(&opt.imr_multiaddr.s_addr,v4ip,4); | |
2020 | opt.imr_interface.s_addr=0; | |
2021 | @@ -338,8 +337,8 @@ | |
2022 | } | |
2023 | } | |
2024 | ||
2025 | - *sock4=s4; | |
2026 | - *sock6=s6; | |
2027 | + *sock4=_s4; | |
2028 | + *sock6=_s6; | |
2029 | } | |
2030 | ||
2031 | int main() { | |
2032 | diff -urN -x .git dietlibc-0.33/.cvsignore dietlibc/.cvsignore | |
2033 | --- dietlibc-0.33/.cvsignore 2007-03-09 13:42:12.000000000 +0000 | |
2034 | +++ dietlibc/.cvsignore 2015-01-01 12:14:43.451605563 +0000 | |
2035 | @@ -28,3 +28,5 @@ | |
2036 | bin-x86_64 | |
2037 | pic-x86_64 | |
2038 | cycles | |
2039 | +include/errno_definition.h | |
2040 | +bin-x32 | |
2041 | diff -urN -x .git dietlibc-0.33/diet.c dietlibc/diet.c | |
2042 | --- dietlibc-0.33/diet.c 2012-11-02 11:17:28.000000000 +0000 | |
2043 | +++ dietlibc/diet.c 2015-01-01 12:14:43.461605562 +0000 | |
2044 | @@ -25,10 +25,11 @@ | |
2045 | } | |
2046 | ||
2047 | static const char* Os[] = { | |
2048 | - "i386","-Os","-mpreferred-stack-boundary=2", | |
2049 | + "i386","-Os","-mpreferred-stack-boundary=4", | |
2050 | "-falign-functions=1","-falign-jumps=1", | |
2051 | "-falign-loops=1","-fomit-frame-pointer",0, | |
2052 | "x86_64","-Os",0, | |
2053 | + "x32","-Os",0, | |
2054 | "sparc","-Os","-mcpu=supersparc",0, | |
2055 | "sparc64","-Os","-m64","-mhard-quad-float",0, | |
2056 | "alpha","-Os","-fomit-frame-pointer",0, | |
2057 | @@ -41,7 +42,6 @@ | |
2058 | "s390x","-Os","-fomit-frame-pointer",0, | |
2059 | "sh","-Os","-fomit-frame-pointer",0, | |
2060 | "ia64","-Os","-fno-omit-frame-pointer",0, | |
2061 | - "x86_64","-Os","-fstrict-aliasing","-momit-leaf-frame-pointer","-mfancy-math-387",0, | |
2062 | 0}; | |
2063 | ||
2064 | static void usage(void) { | |
2065 | @@ -120,7 +120,6 @@ | |
2066 | } else break; | |
2067 | } while (1); | |
2068 | { | |
2069 | - int i; | |
2070 | m=0; | |
2071 | for (i=1; i<argc; ++i) { | |
2072 | if (!strcmp(argv[i],"-m32")) m=32; else | |
2073 | @@ -144,6 +143,10 @@ | |
2074 | memmove(shortplatform,argv[1],(size_t)(tmp2-cc)); | |
2075 | platform[tmp2-cc+len]=0; | |
2076 | if (shortplatform[0]=='i' && shortplatform[2]=='8' && shortplatform[3]=='6') shortplatform[1]='3'; | |
2077 | + else if (strcmp(shortplatform, "powerpc") == 0) | |
2078 | + strcpy(shortplatform, "ppc"); | |
2079 | + else if (strcmp(shortplatform, "powerpc64") == 0) | |
2080 | + strcpy(shortplatform, "ppc64"); | |
2081 | } else { | |
2082 | #ifdef __sparc__ | |
2083 | #ifdef __arch64__ | |
2084 | @@ -193,15 +196,14 @@ | |
2085 | shortplatform="ia64"; | |
2086 | #endif | |
2087 | { | |
2088 | - char *tmp=platform+strlen(platform); | |
2089 | - strcpy(tmp,shortplatform); | |
2090 | - shortplatform=tmp; | |
2091 | + char *tmp4=platform+strlen(platform); | |
2092 | + strcpy(tmp4,shortplatform); | |
2093 | + shortplatform=tmp4; | |
2094 | } | |
2095 | } | |
2096 | /* MIPS needs special handling. If argv contains -EL, change | |
2097 | * platform name to mipsel */ | |
2098 | if (!strcmp(shortplatform,"mips")) { | |
2099 | - int i; | |
2100 | for (i=1; i<argc; ++i) | |
2101 | if (!strcmp(argv[i],"-EL")) | |
2102 | strcpy(shortplatform,"mipsel"); | |
2103 | @@ -328,7 +330,7 @@ | |
2104 | } | |
2105 | if (mangleopts) | |
2106 | if (argv[i][0]=='-' && (argv[i][1]=='O' || argv[i][1]=='f' || | |
2107 | - (argv[i][1]=='m' && argv[i][2]!='3' && argv[i][2]!='6'))) { | |
2108 | + (argv[i][1]=='m' && argv[i][2]!='3' && argv[i][2]!='6' && argv[i][2]!='x'))) { | |
2109 | if (strcmp(argv[i],"-fpic") && strcmp(argv[i],"-fno-pic")) | |
2110 | continue; | |
2111 | } | |
2112 | @@ -351,7 +353,7 @@ | |
2113 | ||
2114 | { | |
2115 | int fd; | |
2116 | - char* tmp=getenv("HOME"); | |
2117 | + tmp=getenv("HOME"); | |
2118 | if (tmp) { | |
2119 | if (strlen(tmp)+strlen(cc)<900) { | |
2120 | strcpy(manglebuf,tmp); | |
2121 | @@ -362,7 +364,6 @@ | |
2122 | if ((fd=open(manglebuf,O_RDONLY))>=0) { | |
2123 | int len=read(fd,manglebuf,1023); | |
2124 | if (len>0) { | |
2125 | - int i; | |
2126 | manglebuf[len]=0; | |
2127 | *dest++=manglebuf; | |
2128 | for (i=1; i<len; ++i) { | |
2129 | @@ -416,7 +417,6 @@ | |
2130 | #endif | |
2131 | *dest=0; | |
2132 | if (verbose) { | |
2133 | - int i; | |
2134 | for (i=0; newargv[i]; i++) { | |
2135 | __write2(newargv[i]); | |
2136 | __write2(" "); | |
2137 | diff -urN -x .git dietlibc-0.33/dietdirent.h dietlibc/dietdirent.h | |
2138 | --- dietlibc-0.33/dietdirent.h 2002-07-03 20:33:37.000000000 +0000 | |
2139 | +++ dietlibc/dietdirent.h 2015-01-01 12:14:43.461605562 +0000 | |
2140 | @@ -1,8 +1,28 @@ | |
2141 | #include <sys/shm.h> | |
2142 | ||
2143 | +#include "dietpagesize.h" | |
2144 | + | |
2145 | struct __dirstream { | |
2146 | int fd; | |
2147 | - char buf[PAGE_SIZE-(sizeof (int)*3)]; | |
2148 | unsigned int num; | |
2149 | unsigned int cur; | |
2150 | + unsigned char is_64; | |
2151 | + char buf[] __attribute__((__aligned__(8))); | |
2152 | }; /* stream data from opendir() */ | |
2153 | + | |
2154 | +struct linux_dirent { | |
2155 | + unsigned long d_ino; | |
2156 | + unsigned long d_off; | |
2157 | + unsigned short d_reclen; | |
2158 | + char d_name[1]; | |
2159 | +}; | |
2160 | + | |
2161 | +struct linux_dirent64 { | |
2162 | + uint64_t d_ino; | |
2163 | + int64_t d_off; | |
2164 | + unsigned short d_reclen; | |
2165 | + unsigned char d_type; | |
2166 | + char d_name[0]; | |
2167 | +}; | |
2168 | + | |
2169 | +#define __DIRSTREAM_BUF_SIZE (__DIET_PAGE_SIZE - offsetof(struct __dirstream, buf)) | |
2170 | diff -urN -x .git dietlibc-0.33/dietelfinfo.h dietlibc/dietelfinfo.h | |
2171 | --- dietlibc-0.33/dietelfinfo.h 1970-01-01 00:00:00.000000000 +0000 | |
2172 | +++ dietlibc/dietelfinfo.h 2015-01-01 12:14:43.461605562 +0000 | |
2173 | @@ -0,0 +1,20 @@ | |
2174 | +#include "dietfeatures.h" | |
2175 | + | |
2176 | +#ifdef WANT_ELFINFO | |
2177 | +#include <elf.h> | |
2178 | +#include <endian.h> | |
2179 | +#include <stdint.h> | |
2180 | + | |
2181 | +/* TODO: exported interface from <linux/elf.h> has been changed in 2.6.25 so | |
2182 | + * the 'elf_addr_t' type is not available anymore. Hence, derive it from | |
2183 | + * __WORDSIZE__. */ | |
2184 | + | |
2185 | +#if __WORDSIZE == 64 | |
2186 | +typedef uint64_t __diet_elf_addr_t; | |
2187 | +#elif __WORDSIZE == 32 | |
2188 | +typedef uint32_t __diet_elf_addr_t; | |
2189 | +#endif | |
2190 | + | |
2191 | +__diet_elf_addr_t const * __get_elf_aux_value(unsigned int tag) | |
2192 | + __attribute__((__visibility__("hidden"),__const__)) __pure; | |
2193 | +#endif | |
2194 | diff -urN -x .git dietlibc-0.33/dietfeatures.h dietlibc/dietfeatures.h | |
2195 | --- dietlibc-0.33/dietfeatures.h 2012-11-02 11:17:28.000000000 +0000 | |
2196 | +++ dietlibc/dietfeatures.h 2015-01-01 12:14:43.461605562 +0000 | |
2197 | @@ -29,7 +29,7 @@ | |
2198 | #define WANT_TLS | |
2199 | ||
2200 | /* make the startcode, etc. dynamic aware ({con,de}structors) */ | |
2201 | -/* #define WANT_DYNAMIC */ | |
2202 | +// #define WANT_DYNAMIC | |
2203 | ||
2204 | /* GDB support in the dynamic linker */ | |
2205 | #define WANT_LD_SO_GDB_SUPPORT | |
2206 | @@ -142,6 +142,16 @@ | |
2207 | #define WANT_SSP | |
2208 | #endif | |
2209 | ||
2210 | +/* Some platforms like x86_64, ppc* or mips do not have a fixed PAGE_SIZE. | |
2211 | + * Select WANT_DYN_PAGESIZE to detect the current PAGE_SIZE at runtime. Else, | |
2212 | + * define WANT_STATIC_PAGESIZE to a proper value (must be a power of 2) | |
2213 | + * matching the configured pagesize of the kernel where your binaries are | |
2214 | + * running on. | |
2215 | + * | |
2216 | + * Selecting WANT_DYN_PAGESIZE enlarges the startup code by around 1-3 | |
2217 | + * instructions and might add an additional __elfinfo symbol */ | |
2218 | +#define WANT_DYN_PAGESIZE | |
2219 | +/* #define WANT_STATIC_PAGESIZE 0x10000UL */ | |
2220 | ||
2221 | ||
2222 | /* stop uncommenting here ;-) */ | |
2223 | @@ -161,13 +171,6 @@ | |
2224 | #define WANT_SMALL_STRING_ROUTINES | |
2225 | #endif | |
2226 | ||
2227 | -#ifdef WANT_THREAD_SAFE | |
2228 | -#ifndef __ASSEMBLER__ | |
2229 | -#define errno (*__errno_location()) | |
2230 | -#define _REENTRANT | |
2231 | -#endif | |
2232 | -#endif | |
2233 | - | |
2234 | #ifdef __DYN_LIB | |
2235 | /* with shared libraries you MUST have a dynamic aware startcode */ | |
2236 | #ifndef WANT_DYNAMIC | |
2237 | @@ -179,4 +182,12 @@ | |
2238 | #endif | |
2239 | #endif | |
2240 | ||
2241 | +#if defined(__x86_64__) && defined(__ILP32__) | |
2242 | +#undef WANT_LARGEFILE_BACKCOMPAT | |
2243 | +#endif | |
2244 | + | |
2245 | +#ifdef WANT_DYN_PAGESIZE | |
2246 | +#define WANT_ELFINFO | |
2247 | +#endif | |
2248 | + | |
2249 | #endif | |
2250 | diff -urN -x .git dietlibc-0.33/dietpagesize.h dietlibc/dietpagesize.h | |
2251 | --- dietlibc-0.33/dietpagesize.h 1970-01-01 00:00:00.000000000 +0000 | |
2252 | +++ dietlibc/dietpagesize.h 2015-01-01 12:14:43.461605562 +0000 | |
2253 | @@ -0,0 +1,31 @@ | |
2254 | +#ifndef H_DIETLIBC_DIETPAGESIZE_H | |
2255 | +#define H_DIETLIBC_DIETPAGESIZE_H | |
2256 | + | |
2257 | +#include <strings.h> | |
2258 | +#include "dietfeatures.h" | |
2259 | + | |
2260 | +extern size_t __libc_getpagesize(void) __attribute__((__const__)) __pure; | |
2261 | + | |
2262 | +#if defined(WANT_STATIC_PAGESIZE) | |
2263 | +# define __DIET_PAGE_SIZE_PREDEF (WANT_STATIC_PAGESIZE) | |
2264 | +# define __DIET_PAGE_SHIFT_PREDEF (ffs(__DIET_PAGE_SIZE_PREDEF)-1) | |
2265 | +#elif defined(__alpha__) || defined(__sparc__) | |
2266 | +# define __DIET_PAGE_SIZE_PREDEF (8192UL) | |
2267 | +# define __DIET_PAGE_SHIFT_PREDEF (13) | |
2268 | +#elif defined(__powerpc64__) | |
2269 | +# define __DIET_PAGE_SIZE_PREDEF (65536UL) | |
2270 | +# define __DIET_PAGE_SHIFT_PREDEF (16) | |
2271 | +#else | |
2272 | +# define __DIET_PAGE_SIZE_PREDEF (4096UL) | |
2273 | +# define __DIET_PAGE_SHIFT_PREDEF (12) | |
2274 | +#endif | |
2275 | + | |
2276 | +#ifdef WANT_DYN_PAGESIZE | |
2277 | +# define __DIET_PAGE_SIZE (__libc_getpagesize()) | |
2278 | +# define __DIET_PAGE_SHIFT (ffs(__DIET_PAGE_SIZE)-1) | |
2279 | +#else | |
2280 | +# define __DIET_PAGE_SIZE __DIET_PAGE_SIZE_PREDEF | |
2281 | +# define __DIET_PAGE_SHIFT __DIET_PAGE_SHIFT_PREDEF | |
2282 | +#endif | |
2283 | + | |
2284 | +#endif /* H_DIETLIBC_DIETPAGESIZE_H */ | |
2285 | diff -urN -x .git dietlibc-0.33/dietuglyweaks.h dietlibc/dietuglyweaks.h | |
2286 | --- dietlibc-0.33/dietuglyweaks.h 2004-06-30 05:52:30.000000000 +0000 | |
2287 | +++ dietlibc/dietuglyweaks.h 2015-01-01 12:14:43.461605562 +0000 | |
2288 | @@ -4,6 +4,18 @@ | |
2289 | /* if you change something here ... KNOW what you're doing ! | |
2290 | * it'll effect ALL platforms ! */ | |
2291 | ||
2292 | +#ifdef __clang__ | |
2293 | +.macro DEF_G name | |
2294 | +.global \name | |
2295 | +.type \name,@function | |
2296 | +\name: | |
2297 | +.endm | |
2298 | +.macro DEF_W name | |
2299 | +.weak \name | |
2300 | +.type \name,@function | |
2301 | +\name: | |
2302 | +.endm | |
2303 | +#else | |
2304 | .macro DEF_G name | |
2305 | .global \name | |
2306 | .type \name,function | |
2307 | @@ -14,6 +26,7 @@ | |
2308 | .type \name,function | |
2309 | \name: | |
2310 | .endm | |
2311 | +#endif | |
2312 | ||
2313 | DEF_W __fflush_stderr | |
2314 | DEF_W __fflush_stdin | |
2315 | diff -urN -x .git dietlibc-0.33/dietunaligned.h dietlibc/dietunaligned.h | |
2316 | --- dietlibc-0.33/dietunaligned.h 1970-01-01 00:00:00.000000000 +0000 | |
2317 | +++ dietlibc/dietunaligned.h 2015-01-01 12:14:43.461605562 +0000 | |
2318 | @@ -0,0 +1,35 @@ | |
2319 | +#ifndef H_DIETLIBC_UNALIGNED_H | |
2320 | +#define H_DIETLIBC_UNALIGNED_H | |
2321 | + | |
2322 | +#include <string.h> | |
2323 | +#include <inttypes.h> | |
2324 | + | |
2325 | +#define read_unaligned(_src) \ | |
2326 | + ({ \ | |
2327 | + struct { \ | |
2328 | + __typeof__(*(_src)) a; \ | |
2329 | + } __attribute__((__packed__)) *_tmp = (void *)(_src); \ | |
2330 | + _tmp->a; \ | |
2331 | + }) | |
2332 | + | |
2333 | +#define read_unaligned_s(_src, _type, _attr) \ | |
2334 | + read_unaligned((__typeof__(&((_type *)(0))->_attr))( \ | |
2335 | + (uintptr_t)(_src) + \ | |
2336 | + __builtin_offsetof(_type, _attr))) \ | |
2337 | + | |
2338 | + | |
2339 | +#define write_unaligned(_v, _dst) \ | |
2340 | + ({ \ | |
2341 | + struct { \ | |
2342 | + __typeof__(*(_dst)) a; \ | |
2343 | + } __attribute__((__packed__)) *_tmp = (void *)(_dst); \ | |
2344 | + _tmp->a = (_v); \ | |
2345 | + }) | |
2346 | + | |
2347 | +#define write_unaligned_s(_v, _dst, _type, _attr) \ | |
2348 | + write_unaligned(_v, \ | |
2349 | + (__typeof__(&((_type *)(0))->_attr))( \ | |
2350 | + (uintptr_t)(_dst) + \ | |
2351 | + __builtin_offsetof(_type, _attr))) \ | |
2352 | + | |
2353 | +#endif /* H_DIETLIBC_UNALIGNED_H */ | |
2354 | diff -urN -x .git dietlibc-0.33/dynlinker/ldso_start.S dietlibc/dynlinker/ldso_start.S | |
2355 | --- dietlibc-0.33/dynlinker/ldso_start.S 2007-03-09 13:42:12.000000000 +0000 | |
2356 | +++ dietlibc/dynlinker/ldso_start.S 2015-01-01 12:14:43.464938896 +0000 | |
2357 | @@ -86,6 +86,15 @@ | |
2358 | .long 0 | |
2359 | #endif | |
2360 | ||
2361 | +/* __elfinfo must follow __environ immediately */ | |
2362 | +.global __elfinfo | |
2363 | +__elfinfo: | |
2364 | +#if __WORDSIZE == 64 | |
2365 | + .quad 0 | |
2366 | +#else | |
2367 | + .long 0 | |
2368 | +#endif | |
2369 | + | |
2370 | .global fini_entry | |
2371 | fini_entry: | |
2372 | .long 0 | |
2373 | diff -urN -x .git dietlibc-0.33/dyn_start.c dietlibc/dyn_start.c | |
2374 | --- dietlibc-0.33/dyn_start.c 2008-05-06 17:18:34.000000000 +0000 | |
2375 | +++ dietlibc/dyn_start.c 2015-01-01 12:14:43.464938896 +0000 | |
2376 | @@ -54,10 +54,6 @@ | |
2377 | __deregister_frame_info(__EH_FRAME_BEGIN__); | |
2378 | } | |
2379 | ||
2380 | -#ifdef WANT_STACKGAP | |
2381 | -int stackgap(int argc,char* argv[],char* envp[]); | |
2382 | -#endif | |
2383 | - | |
2384 | #ifndef __DYN_LIB_SHARED | |
2385 | /* pre main, post _start */ | |
2386 | extern __attribute__((section(".init"))) void _init(void); | |
2387 | @@ -65,7 +61,7 @@ | |
2388 | int _dyn_start(int argc, char **argv, char **envp, structor dl_init); | |
2389 | int _dyn_start(int argc, char **argv, char **envp, structor dl_init) | |
2390 | { | |
2391 | - int main(int argc, char **argv, char **envp); | |
2392 | + int CALL_IN_STARTCODE(int argc, char **argv, char **envp); | |
2393 | ||
2394 | #ifndef __arm__ | |
2395 | /* GT: segfaults on arm, don't know why (for now) */ | |
2396 | @@ -82,11 +78,7 @@ | |
2397 | __register_frame_info(__EH_FRAME_BEGIN__, &ob); | |
2398 | } | |
2399 | ||
2400 | -#ifdef WANT_STACKGAP | |
2401 | - return stackgap(argc, argv, envp); | |
2402 | -#else | |
2403 | - return main(argc, argv, envp); | |
2404 | -#endif | |
2405 | + return CALL_IN_STARTCODE(argc, argv, envp); | |
2406 | } | |
2407 | #endif | |
2408 | #endif | |
2409 | diff -urN -x .git dietlibc-0.33/FAQ dietlibc/FAQ | |
2410 | --- dietlibc-0.33/FAQ 2010-11-09 18:38:34.000000000 +0000 | |
2411 | +++ dietlibc/FAQ 2015-01-01 12:14:43.451605563 +0000 | |
2412 | @@ -246,7 +246,7 @@ | |
2413 | code. Unfortunately, these options have been renamed on gcc 3. You | |
2414 | can fix this by creating a file ~/.diet/gcc containing this line: | |
2415 | ||
2416 | - -Os -fomit-frame-pointer -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=2 | |
2417 | + -Os -fomit-frame-pointer -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=4 | |
2418 | ||
2419 | If you get this options not for diet -Os gcc but for diet -Os | |
2420 | i386-linux-gcc, put this in ~/.diet/i386-linux-gcc instead. | |
2421 | diff -urN -x .git dietlibc-0.33/findcflags.sh dietlibc/findcflags.sh | |
2422 | --- dietlibc-0.33/findcflags.sh 2005-05-08 15:33:38.000000000 +0000 | |
2423 | +++ dietlibc/findcflags.sh 2015-01-01 12:14:43.464938896 +0000 | |
2424 | @@ -3,6 +3,6 @@ | |
2425 | case $version in | |
2426 | 2.9*) echo -march=i386 -Os -fomit-frame-pointer -malign-functions=1 -malign-jumps=1 -malign-loops=1 -mpreferred-stack-boundary=2 ;; | |
2427 | 3.0*) echo -march=i386 -Os -fomit-frame-pointer -malign-functions=1 -malign-jumps=1 -malign-loops=1 -mpreferred-stack-boundary=2 ;; | |
2428 | - [34]*) echo -Os -fomit-frame-pointer -falign-functions=1 -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=2;; | |
2429 | + [34]*) echo -Os -fomit-frame-pointer -falign-functions=1 -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=4;; | |
2430 | *) echo -O2 -pipe -fomit-frame-pointer ;; | |
2431 | esac | |
2432 | diff -urN -x .git dietlibc-0.33/.gitignore dietlibc/.gitignore | |
2433 | --- dietlibc-0.33/.gitignore 1970-01-01 00:00:00.000000000 +0000 | |
2434 | +++ dietlibc/.gitignore 2015-01-01 12:14:43.451605563 +0000 | |
2435 | @@ -0,0 +1,2 @@ | |
2436 | +/.cvsps | |
2437 | +/include/errno_definition.h | |
2438 | diff -urN -x .git dietlibc-0.33/i386/accept4.S dietlibc/i386/accept4.S | |
2439 | --- dietlibc-0.33/i386/accept4.S 1970-01-01 00:00:00.000000000 +0000 | |
2440 | +++ dietlibc/i386/accept4.S 2015-01-01 12:14:43.464938896 +0000 | |
2441 | @@ -0,0 +1,4 @@ | |
2442 | +#include <linuxnet.h> | |
2443 | +#include <syscalls.h> | |
2444 | + | |
2445 | +__socketcall(accept4,ACCEPT4) | |
2446 | diff -urN -x .git dietlibc-0.33/i386/dyn_syscalls.S dietlibc/i386/dyn_syscalls.S | |
2447 | --- dietlibc-0.33/i386/dyn_syscalls.S 2012-01-24 18:24:24.000000000 +0000 | |
2448 | +++ dietlibc/i386/dyn_syscalls.S 2015-01-01 12:14:43.464938896 +0000 | |
2449 | @@ -191,7 +191,6 @@ | |
2450 | #include "../syscalls.s/n_sigpending.S" | |
2451 | #include "../syscalls.s/n_sigprocmask.S" | |
2452 | #include "../syscalls.s/n_sigsuspend.S" | |
2453 | -#include "../syscalls.s/nice.S" | |
2454 | #include "../syscalls.s/pause.S" | |
2455 | #include "../syscalls.s/personality.S" | |
2456 | #include "../syscalls.s/query_module.S" | |
2457 | diff -urN -x .git dietlibc-0.33/i386/getcontext.S dietlibc/i386/getcontext.S | |
2458 | --- dietlibc-0.33/i386/getcontext.S 1970-01-01 00:00:00.000000000 +0000 | |
2459 | +++ dietlibc/i386/getcontext.S 2015-01-01 12:14:43.464938896 +0000 | |
2460 | @@ -0,0 +1,45 @@ | |
2461 | +#include "syscalls.h" | |
2462 | + | |
2463 | +.text | |
2464 | +.global getcontext | |
2465 | +.type getcontext,@function | |
2466 | +/* store current CPU context into struct ucontext* */ | |
2467 | +getcontext: | |
2468 | + movl 4(%esp),%eax /* load ucontext* */ | |
2469 | + /* the registers are in uc_mcontext, which starts at offset 20 */ | |
2470 | + movw %gs,20(%eax) | |
2471 | + movw %fs,24(%eax) | |
2472 | + movw %es,28(%eax) | |
2473 | + movw %ds,32(%eax) | |
2474 | + movl %edi,36(%eax) | |
2475 | + movl %esi,40(%eax) | |
2476 | + movl %ebp,44(%eax) | |
2477 | + /* skip esp until we stored ecx */ | |
2478 | + movl %ebx,52(%eax) | |
2479 | + movl %edx,56(%eax) | |
2480 | + movl %ecx,60(%eax) | |
2481 | + lea 4(%esp),%ecx /* store esp+4 to esp */ | |
2482 | + mov %ecx,48(%eax) | |
2483 | + movl $0,64(%eax) /* eax */ | |
2484 | + /* not touching trapno and err, no idea what do store there */ | |
2485 | + movl (%esp),%ecx | |
2486 | + movl %ecx,76(%eax) /* store return value from stack into eip of struct */ | |
2487 | + movw %cs,80(%eax) | |
2488 | + /* 84: eflags */ | |
2489 | + /* 88: esp_at_signal */ | |
2490 | + movw %ss,92(%eax) | |
2491 | + | |
2492 | + lea 236(%eax),%ecx | |
2493 | + movl %ecx,96(%eax) | |
2494 | + fnstenv (%ecx) | |
2495 | + fldenv (%ecx) | |
2496 | + mov %ebx,%edi | |
2497 | + xor %ebx,%ebx | |
2498 | + xor %ecx,%ecx | |
2499 | + lea 108(%eax),%edx | |
2500 | + mov $__NR_sigprocmask,%eax | |
2501 | + int $0x80 | |
2502 | + mov %edi,%ebx | |
2503 | + xor %eax,%eax | |
2504 | + ret | |
2505 | +.size getcontext, .-getcontext | |
2506 | diff -urN -x .git dietlibc-0.33/i386/Makefile.add dietlibc/i386/Makefile.add | |
2507 | --- dietlibc-0.33/i386/Makefile.add 2012-01-24 18:24:24.000000000 +0000 | |
2508 | +++ dietlibc/i386/Makefile.add 2015-01-01 12:14:43.464938896 +0000 | |
2509 | @@ -1,7 +1,7 @@ | |
2510 | ||
2511 | M:=$(shell ./findcflags.sh $(CC)) | |
2512 | LIBOBJ+=$(OBJDIR)/__ten.o $(OBJDIR)/md5asm.o $(OBJDIR)/__restore_rt.o \ | |
2513 | -$(OBJDIR)/__CAS.o | |
2514 | +$(OBJDIR)/__CAS.o $(OBJDIR)/getcontext.o $(OBJDIR)/setcontext.o | |
2515 | LIBMATH+=acos.o asin.o atan.o ceil.o cos.o exp.o exp10.o exp2.o expm1.o fabs.o floor.o hypot.o log.o log2.o log10.o sin.o sqrt.o copysign.o sincos.o __half.o ldexp.o ilogb.o cbrt.o log1p.o fmod.o libm2.o atan2.o tan.o | |
2516 | LIBMATH:=$(filter-out acosh.o asinh.o atanh.o cbrt.o copysign.o exp10.o exp2.o expm1.o ilogb.o log2.o,$(LIBMATH)) | |
2517 | #CFLAGS+=-march=i386 -Os -fomit-frame-pointer -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mpreferred-stack-boundary=2 | |
2518 | diff -urN -x .git dietlibc-0.33/i386/recvmmsg.S dietlibc/i386/recvmmsg.S | |
2519 | --- dietlibc-0.33/i386/recvmmsg.S 1970-01-01 00:00:00.000000000 +0000 | |
2520 | +++ dietlibc/i386/recvmmsg.S 2015-01-01 12:14:43.468272228 +0000 | |
2521 | @@ -0,0 +1,4 @@ | |
2522 | +#include <linuxnet.h> | |
2523 | +#include <syscalls.h> | |
2524 | + | |
2525 | +__socketcall(recvmmsg,RECVMMSG) | |
2526 | diff -urN -x .git dietlibc-0.33/i386/sendmmsg.S dietlibc/i386/sendmmsg.S | |
2527 | --- dietlibc-0.33/i386/sendmmsg.S 1970-01-01 00:00:00.000000000 +0000 | |
2528 | +++ dietlibc/i386/sendmmsg.S 2015-01-01 12:14:43.468272228 +0000 | |
2529 | @@ -0,0 +1,4 @@ | |
2530 | +#include <linuxnet.h> | |
2531 | +#include <syscalls.h> | |
2532 | + | |
2533 | +__socketcall(sendmmsg,SENDMMSG) | |
2534 | diff -urN -x .git dietlibc-0.33/i386/setcontext.S dietlibc/i386/setcontext.S | |
2535 | --- dietlibc-0.33/i386/setcontext.S 1970-01-01 00:00:00.000000000 +0000 | |
2536 | +++ dietlibc/i386/setcontext.S 2015-01-01 12:14:43.468272228 +0000 | |
2537 | @@ -0,0 +1,48 @@ | |
2538 | +#include "syscalls.h" | |
2539 | + | |
2540 | +.text | |
2541 | +.global __setcontext_trampoline | |
2542 | +.type __setcontext_trampoline,@function | |
2543 | +__setcontext_trampoline: | |
2544 | + mov %ebx,4(%esp) | |
2545 | + /* fall through */ | |
2546 | +.size __setcontext_trampoline,.-__setcontext_trampoline | |
2547 | + | |
2548 | +.global setcontext | |
2549 | +.type setcontext,@function | |
2550 | +/* switch to stored CPU context from struct ucontext* */ | |
2551 | +setcontext: | |
2552 | + movl 4(%esp),%eax /* load ucontext* */ | |
2553 | + /* first, load the signal mask */ | |
2554 | + movl %ebx,%edi | |
2555 | + xorl %edx,%edx | |
2556 | + movl $2,%ebx /* SIG_SETMASK */ | |
2557 | + lea 108(%eax),%ecx | |
2558 | + movl $__NR_sigprocmask,%eax | |
2559 | + int $0x80 | |
2560 | + cmp $-4095,%eax | |
2561 | + jb .Lnoerror | |
2562 | + jmp __error_unified_syscall | |
2563 | +.Lnoerror: | |
2564 | + movl 4(%esp),%eax /* load ucontext* */ | |
2565 | + mov %edi,%ebx | |
2566 | + lea 236(%eax),%ecx | |
2567 | + fldenv (%ecx) | |
2568 | + | |
2569 | + /* the registers are in uc_mcontext, which starts at offset 20 */ | |
2570 | + /* do not restore gs because it's thread-specific */ | |
2571 | + movw 24(%eax),%fs | |
2572 | + movw 28(%eax),%es | |
2573 | + movw 32(%eax),%ds | |
2574 | + movl 36(%eax),%edi | |
2575 | + movl 40(%eax),%esi | |
2576 | + movl 44(%eax),%ebp | |
2577 | + movl 48(%eax),%esp | |
2578 | + movw 92(%eax),%ss | |
2579 | + movl 52(%eax),%ebx | |
2580 | + movl 56(%eax),%edx | |
2581 | + movl 60(%eax),%ecx | |
2582 | + | |
2583 | + movl 76(%eax),%eax | |
2584 | + jmp *%eax | |
2585 | +.size setcontext, .-setcontext | |
2586 | diff -urN -x .git dietlibc-0.33/i386/start.S dietlibc/i386/start.S | |
2587 | --- dietlibc-0.33/i386/start.S 2012-01-24 18:24:24.000000000 +0000 | |
2588 | +++ dietlibc/i386/start.S 2015-01-01 12:14:43.468272228 +0000 | |
2589 | @@ -20,12 +20,18 @@ | |
2590 | PIC_INIT /* non-PIC: this is an empty line */ | |
2591 | PUT_VAR %esi, environ, %ecx /* non-PIC: movl %esi,environ */ | |
2592 | ||
2593 | -#ifdef WANT_SYSENTER | |
2594 | +#if defined(WANT_ELFINFO) || defined(WANT_SYSENTER) | |
2595 | /* skip environment, scan for NULL */ | |
2596 | 1: | |
2597 | lodsl | |
2598 | testl %eax,%eax | |
2599 | jnz 1b | |
2600 | +# ifdef WANT_ELFINFO | |
2601 | + PUT_VAR %esi, __elfinfo, %ecx | |
2602 | +# endif | |
2603 | +#endif | |
2604 | + | |
2605 | +#ifdef WANT_SYSENTER | |
2606 | /* The ELF auxvec follows the environment, consists of key/value pairs. | |
2607 | We are looking for key 32, which stands for the vsyscall page */ | |
2608 | 1: | |
2609 | diff -urN -x .git dietlibc-0.33/i386/syscalls.h dietlibc/i386/syscalls.h | |
2610 | --- dietlibc-0.33/i386/syscalls.h 2012-01-24 18:24:24.000000000 +0000 | |
2611 | +++ dietlibc/i386/syscalls.h 2015-01-01 12:14:43.468272228 +0000 | |
2612 | @@ -339,6 +339,23 @@ | |
2613 | #define __NR_fanotify_init 338 | |
2614 | #define __NR_fanotify_mark 339 | |
2615 | #define __NR_prlimit64 340 | |
2616 | +#define __NR_name_to_handle_at 341 | |
2617 | +#define __NR_open_by_handle_at 342 | |
2618 | +#define __NR_clock_adjtime 343 | |
2619 | +#define __NR_syncfs 344 | |
2620 | +#define __NR_sendmmsg 345 | |
2621 | +#define __NR_setns 346 | |
2622 | +#define __NR_process_vm_readv 347 | |
2623 | +#define __NR_process_vm_writev 348 | |
2624 | +#define __NR_kcmp 349 | |
2625 | +#define __NR_finit_module 350 | |
2626 | +#define __NR_sched_setattr 351 | |
2627 | +#define __NR_sched_getattr 352 | |
2628 | +#define __NR_renameat2 353 | |
2629 | +#define __NR_seccomp 354 | |
2630 | +#define __NR_getrandom 355 | |
2631 | +#define __NR_memfd_create 356 | |
2632 | + | |
2633 | ||
2634 | #define syscall_weak(name,wsym,sym) \ | |
2635 | .text; \ | |
2636 | @@ -368,7 +385,6 @@ | |
2637 | .Lend##sym: ; \ | |
2638 | .size sym,.Lend##sym-sym | |
2639 | ||
2640 | -#ifndef __PIC__ | |
2641 | #define __socketcall(name,NAME) \ | |
2642 | .text; \ | |
2643 | .type name,@function; \ | |
2644 | @@ -381,6 +397,3 @@ | |
2645 | jmp socketcall; \ | |
2646 | .Lend##name:; \ | |
2647 | .size name,.Lend##name-name | |
2648 | -#else | |
2649 | -#define __socketcall(name,NAME) | |
2650 | -#endif | |
2651 | diff -urN -x .git dietlibc-0.33/ia64/clone.S dietlibc/ia64/clone.S | |
2652 | --- dietlibc-0.33/ia64/clone.S 2006-06-23 17:29:33.000000000 +0000 | |
2653 | +++ dietlibc/ia64/clone.S 2015-01-01 12:14:43.468272228 +0000 | |
2654 | @@ -1,4 +1,4 @@ | |
2655 |