diff options
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/h8300/__longjmp.S | 6 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/bsd-_setjmp.S | 10 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/bsd-setjmp.S | 13 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/clone.S | 36 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/crt1.S (renamed from libc/sysdeps/linux/h8300/crt0.S) | 38 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/crti.S | 8 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/crtn.S | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/setjmp.S | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/h8300/vfork.S | 54 |
9 files changed, 120 insertions, 53 deletions
diff --git a/libc/sysdeps/linux/h8300/__longjmp.S b/libc/sysdeps/linux/h8300/__longjmp.S index eb433df23..bcb098510 100644 --- a/libc/sysdeps/linux/h8300/__longjmp.S +++ b/libc/sysdeps/linux/h8300/__longjmp.S @@ -4,10 +4,10 @@ .h8300h #endif .text - -.global ___longjmp -___longjmp: +.global __longjmp + +__longjmp: mov.l er1,er1 bne 1f sub.l er1,er1 diff --git a/libc/sysdeps/linux/h8300/bsd-_setjmp.S b/libc/sysdeps/linux/h8300/bsd-_setjmp.S index fbe702599..766d9cc91 100644 --- a/libc/sysdeps/linux/h8300/bsd-_setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-_setjmp.S @@ -1,4 +1,4 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */ #include <jmpbuf-offsets.h> @@ -8,10 +8,10 @@ .h8300h #endif .text - -.global __setjmp -__setjmp: +.global _setjmp + +_setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -23,3 +23,5 @@ __setjmp: sub.l er0,er0 mov.l er0,@(JB_SIZE:16,er1) rts + + .end diff --git a/libc/sysdeps/linux/h8300/bsd-setjmp.S b/libc/sysdeps/linux/h8300/bsd-setjmp.S index 74ebb8f9a..77c810fe0 100644 --- a/libc/sysdeps/linux/h8300/bsd-setjmp.S +++ b/libc/sysdeps/linux/h8300/bsd-setjmp.S @@ -1,4 +1,4 @@ -/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */ #include <jmpbuf-offsets.h> @@ -8,10 +8,10 @@ .h8300h #endif .text - -.global _setjmp -_setjmp: +.global setjmp + +setjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 @@ -21,8 +21,9 @@ _setjmp: mov.l er4,@-er0 sub.l er0,er0 #if !defined(__PIC__) - jmp @___sigjmp_save + jmp @__sigjmp_save #else - mov.l @(___sigjmp_save@GOTOFF,er5),er1 + mov.l @(__sigjmp_save@GOTOFF,er5),er1 jmp @er3 #endif + .end diff --git a/libc/sysdeps/linux/h8300/clone.S b/libc/sysdeps/linux/h8300/clone.S index 554a29703..a00eba4cb 100644 --- a/libc/sysdeps/linux/h8300/clone.S +++ b/libc/sysdeps/linux/h8300/clone.S @@ -1,5 +1,4 @@ -/* Adapted from glibc */ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. */ +/* Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */ /* clone is even more special than fork as it mucks with stacks and invokes a function in the right context after its all over. */ @@ -8,7 +7,8 @@ #include <bits/errno.h> #include <sys/syscall.h> -/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ +/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg + void *parent_tidptr, void *tls, void *child_tidptr) */ #ifdef __H8300H__ .h8300h @@ -18,8 +18,8 @@ #endif .text -.globl _clone -_clone: +.globl clone +clone: /* Sanity check arguments. */ mov.l #-EINVAL,er3 mov.l er0,er0 /* no NULL function pointers */ @@ -31,13 +31,25 @@ _clone: mov.l @(4:16,sp),er3 mov.l er3,@-er1 - /* Do the system call */ + /* setup argument */ mov.l er0,er3 /* er3 = child entry */ - mov.l er1,er0 - mov.l er2,er1 /* er1 = flags */ - mov.l er0,er2 /* er2 = child sp */ - mov.l #__NR_clone,r0 + sub.l #20,sp + mov.l er2,@sp /* flags */ + mov.l er1,@(4,sp) /* new sp */ + mov.l sp,er1 + mov.l @(20+8,sp),er0 + mov.l er0,@er1 /* parent tid */ + adds #4,er1 + mov.l @(20+16,sp),er0 + mov.l er0,@er1 /* child tid */ + adds #4,er1 + mov.l @(20+12,sp),er0 + mov.l er0,@er1 /* tls */ + /* do the system call */ + mov.l sp,er1 + mov.l #__NR_clone,er0 trapa #0 + add.l #20,sp mov.l er0,er0 bmi __syscall_error beq thread_start @@ -62,7 +74,9 @@ __syscall_error: thread_start: mov.l @sp+,er0 /* restore args */ - jsr @er3 + jsr @er3 mov.l er0,er1 mov.l #__NR_exit,er0 trapa #0 + + .end diff --git a/libc/sysdeps/linux/h8300/crt0.S b/libc/sysdeps/linux/h8300/crt1.S index be6768de6..847872ad7 100644 --- a/libc/sysdeps/linux/h8300/crt0.S +++ b/libc/sysdeps/linux/h8300/crt1.S @@ -28,17 +28,39 @@ not, see <http://www.gnu.org/licenses/>. */ #else .h8300h #endif +/* +void __uClibc_main(int (*main)(int, char **, char **), int argc, + char **argv, void (*app_init)(void), void (*app_fini)(void), + void (*rtld_fini)(void),void *stack_end attribute_unused) +*/ .text _start: /* put here so that references to _start work with elf-PIC */ - mov.l @(0,sp),er0 /* argc */ - mov.l @(4,sp),er1 /* argv */ - mov.l @(8,sp),er2 /* envp */ + mov.l @sp+,er1 /* argc */ + mov.l @sp+,er2 /* argv */ + add.l #4,sp + #if !defined(__PIC__) - jsr @___uClibc_main + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l #_fini,er0 + mov.l er0,@-sp + mov.l #_init,er0 + mov.l er0,@-sp + mov.l #main,er0 + jsr @__uClibc_main #else - mov.l @(___uClibc_main@GOTOFF,er5),er3 + mov.l sp, @-sp + sub.l er0,er0 + mov.l er0,@-sp + mov.l @(_fini@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(_init@GOTOFF,er5),er0 + mov.l er0,@-sp + mov.l @(main@GOTOFF,er5),er0 + mov.l @(__uClibc_main@GOTOFF,er5),er3 jsr @er3 #endif @@ -61,9 +83,9 @@ empty_func: /* Define a symbol for the first piece of initialized data. */ .data - .globl __data_start -__data_start: + .globl _data_start +_data_start: .long 0 .weak data_start - data_start = __data_start + data_start = _data_start diff --git a/libc/sysdeps/linux/h8300/crti.S b/libc/sysdeps/linux/h8300/crti.S index 270df276e..cc6afe902 100644 --- a/libc/sysdeps/linux/h8300/crti.S +++ b/libc/sysdeps/linux/h8300/crti.S @@ -10,8 +10,8 @@ .section .init ; #NO_APP .align 1 - .global __init -__init: + .global _init +_init: mov.l er6,@-er7 mov.l er7,er6 ; #APP @@ -20,8 +20,8 @@ __init: .section .fini ; #NO_APP .align 1 - .global __fini -__fini: + .global _fini +_fini: mov.l er6,@-er7 mov.l er7,er6 ; #APP diff --git a/libc/sysdeps/linux/h8300/crtn.S b/libc/sysdeps/linux/h8300/crtn.S index 8f9fa1fac..a390704a6 100644 --- a/libc/sysdeps/linux/h8300/crtn.S +++ b/libc/sysdeps/linux/h8300/crtn.S @@ -10,7 +10,7 @@ .section .init ; #NO_APP .align 1 - .global __init + .global _init ; #NO_APP mov.l @er7+,er6 rts @@ -19,7 +19,7 @@ .section .fini ; #NO_APP .align 1 - .global __fini + .global _fini ; #NO_APP mov.l @er7+,er6 rts diff --git a/libc/sysdeps/linux/h8300/setjmp.S b/libc/sysdeps/linux/h8300/setjmp.S index f2795fa54..0b8f052ce 100644 --- a/libc/sysdeps/linux/h8300/setjmp.S +++ b/libc/sysdeps/linux/h8300/setjmp.S @@ -7,9 +7,9 @@ #endif .text -.global ___sigsetjmp +.global __sigsetjmp -___sigsetjmp: +__sigsetjmp: add.l #JB_SIZE,er0 mov.l @sp,er1 ; return PC mov.l er1,@-er0 diff --git a/libc/sysdeps/linux/h8300/vfork.S b/libc/sysdeps/linux/h8300/vfork.S index 9b65f4fe0..1c70dd2f5 100644 --- a/libc/sysdeps/linux/h8300/vfork.S +++ b/libc/sysdeps/linux/h8300/vfork.S @@ -1,10 +1,7 @@ +/* Copyright 2002, 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */ #include <sys/syscall.h> -#ifndef __NR_vfork -#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */ -#endif - #ifdef __H8300S__ .h8300s #else @@ -12,29 +9,60 @@ #endif .text .align 2 - .globl ___vfork - .hidden ___vfork - .type ___vfork,@function -___vfork: + .globl __vfork + .hidden __vfork + .type __vfork,@function +__vfork: +#ifdef __NR_vfork mov.l @sp+, er1 sub.l er0,er0 mov.b #__NR_vfork,r0l trapa #0 + mov.l #-4096, er2 cmp.l er0,er2 bcs fix_errno - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ fix_errno: neg.l er0 -#if !defined(__PIC__) +# if !defined(__PIC__) mov.l er0,@_errno -#else +# else mov.l @(_errno@GOTOFF,er5),er2 mov.l er0,@er2 -#endif +# endif sub.l er0,er0 dec.l #1,er0 - jmp @er1 /* don't return, just jmp directly */ + jmp @er1 /* don't return, just jmp directly */ +#else + mov.l @sp+,er2 /* er2 = return address */ + mov.l #vfork_args,er1 + sub.l er0,er0 + mov.b #__NR_clone,r0l + trapa #0 + mov.l #-4096,er1 + cmp.l er0,er1 + bcc done + neg.l er0 +# if !defined(__PIC__) + mov.l er0,@errno +# else + mov.l @(errno@GOTOFF,er5),er1 + mov.l er0,@er1 +# endif + sub.l er0,er0 + dec.l #1,er0 +done: + jmp @er2 + +vfork_args: + .long 0x80004100 /* CLONE_VFORK | CLONE_VM | SIGCHLD */ + .long 0 + .long 0 + .long 0 + .long 0 +#endif weak_alias(__vfork,vfork) libc_hidden_def(vfork) + .end |