From d115c0d8f666ec4d55ccb8e42ec2c2effd99f75b Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Sat, 23 Oct 2004 00:33:35 +0000 Subject: Added Matsushita AM33/2.0 port. --- ChangeLog.am33 | 207 +++++++++ sysdeps/am33/Implies | 3 + sysdeps/am33/__longjmp.S | 61 +++ sysdeps/am33/atomicity.h | 87 ++++ sysdeps/am33/bits/endian.h | 7 + sysdeps/am33/bits/setjmp.h | 34 ++ sysdeps/am33/bsd-_setjmp.S | 1 + sysdeps/am33/bsd-setjmp.S | 1 + sysdeps/am33/dl-machine.h | 481 +++++++++++++++++++++ sysdeps/am33/elf/start.S | 81 ++++ sysdeps/am33/fpu/bits/fenv.h | 67 +++ sysdeps/am33/fpu/fclrexcpt.c | 52 +++ sysdeps/am33/fpu/fedisblxcpt.c | 42 ++ sysdeps/am33/fpu/feenablxcpt.c | 42 ++ sysdeps/am33/fpu/fegetenv.c | 35 ++ sysdeps/am33/fpu/fegetexcept.c | 35 ++ sysdeps/am33/fpu/fegetround.c | 35 ++ sysdeps/am33/fpu/feholdexcpt.c | 39 ++ sysdeps/am33/fpu/fenv_libc.h | 33 ++ sysdeps/am33/fpu/fesetenv.c | 60 +++ sysdeps/am33/fpu/fesetround.c | 29 ++ sysdeps/am33/fpu/feupdateenv.c | 47 ++ sysdeps/am33/fpu/fgetexcptflg.c | 44 ++ sysdeps/am33/fpu/fpu_control.h | 75 ++++ sysdeps/am33/fpu/fraiseexcpt.c | 79 ++++ sysdeps/am33/fpu/fsetexcptflg.c | 57 +++ sysdeps/am33/fpu/ftestexcept.c | 34 ++ sysdeps/am33/linuxthreads/pspinlock.c | 74 ++++ sysdeps/am33/linuxthreads/pt-machine.h | 68 +++ sysdeps/am33/memusage.h | 23 + sysdeps/am33/preconfigure | 5 + sysdeps/am33/setjmp.S | 80 ++++ sysdeps/am33/shlib-versions | 1 + sysdeps/am33/stackinfo.h | 28 ++ sysdeps/am33/sys/ucontext.h | 123 ++++++ sysdeps/am33/sysdep.h | 82 ++++ sysdeps/unix/am33/sysdep.S | 64 +++ sysdeps/unix/am33/sysdep.h | 33 ++ sysdeps/unix/sysv/linux/am33/Makefile | 3 + sysdeps/unix/sysv/linux/am33/bits/fcntl.h | 179 ++++++++ sysdeps/unix/sysv/linux/am33/bits/mman.h | 97 +++++ sysdeps/unix/sysv/linux/am33/brk.c | 46 ++ sysdeps/unix/sysv/linux/am33/chown.c | 1 + sysdeps/unix/sysv/linux/am33/clone.S | 81 ++++ sysdeps/unix/sysv/linux/am33/configure | 4 + sysdeps/unix/sysv/linux/am33/configure.in | 4 + sysdeps/unix/sysv/linux/am33/fchown.c | 1 + sysdeps/unix/sysv/linux/am33/fcntl.c | 1 + sysdeps/unix/sysv/linux/am33/fxstat.c | 1 + sysdeps/unix/sysv/linux/am33/getegid.c | 1 + sysdeps/unix/sysv/linux/am33/geteuid.c | 1 + sysdeps/unix/sysv/linux/am33/getgid.c | 1 + sysdeps/unix/sysv/linux/am33/getgroups.c | 1 + sysdeps/unix/sysv/linux/am33/getmsg.c | 1 + sysdeps/unix/sysv/linux/am33/getresgid.c | 1 + sysdeps/unix/sysv/linux/am33/getresuid.c | 1 + sysdeps/unix/sysv/linux/am33/getrlimit.c | 1 + sysdeps/unix/sysv/linux/am33/getuid.c | 1 + sysdeps/unix/sysv/linux/am33/lchown.c | 1 + sysdeps/unix/sysv/linux/am33/lockf64.c | 1 + sysdeps/unix/sysv/linux/am33/lxstat.c | 1 + sysdeps/unix/sysv/linux/am33/profil-counter.h | 27 ++ sysdeps/unix/sysv/linux/am33/putmsg.c | 1 + sysdeps/unix/sysv/linux/am33/setegid.c | 1 + sysdeps/unix/sysv/linux/am33/seteuid.c | 1 + sysdeps/unix/sysv/linux/am33/setfsgid.c | 1 + sysdeps/unix/sysv/linux/am33/setfsuid.c | 1 + sysdeps/unix/sysv/linux/am33/setgid.c | 1 + sysdeps/unix/sysv/linux/am33/setgroups.c | 1 + sysdeps/unix/sysv/linux/am33/setregid.c | 1 + sysdeps/unix/sysv/linux/am33/setresgid.c | 1 + sysdeps/unix/sysv/linux/am33/setresuid.c | 1 + sysdeps/unix/sysv/linux/am33/setreuid.c | 1 + sysdeps/unix/sysv/linux/am33/setrlimit.c | 1 + sysdeps/unix/sysv/linux/am33/setuid.c | 1 + sysdeps/unix/sysv/linux/am33/socket.S | 73 ++++ sysdeps/unix/sysv/linux/am33/syscall.S | 43 ++ sysdeps/unix/sysv/linux/am33/sysdep.S | 42 ++ sysdeps/unix/sysv/linux/am33/sysdep.h | 317 ++++++++++++++ sysdeps/unix/sysv/linux/am33/xstat.c | 1 + .../unix/sysv/linux/linuxthreads/sysdep-cancel.h | 159 +++++++ 81 files changed, 3454 insertions(+) create mode 100644 ChangeLog.am33 create mode 100644 sysdeps/am33/Implies create mode 100644 sysdeps/am33/__longjmp.S create mode 100644 sysdeps/am33/atomicity.h create mode 100644 sysdeps/am33/bits/endian.h create mode 100644 sysdeps/am33/bits/setjmp.h create mode 100644 sysdeps/am33/bsd-_setjmp.S create mode 100644 sysdeps/am33/bsd-setjmp.S create mode 100644 sysdeps/am33/dl-machine.h create mode 100644 sysdeps/am33/elf/start.S create mode 100644 sysdeps/am33/fpu/bits/fenv.h create mode 100644 sysdeps/am33/fpu/fclrexcpt.c create mode 100644 sysdeps/am33/fpu/fedisblxcpt.c create mode 100644 sysdeps/am33/fpu/feenablxcpt.c create mode 100644 sysdeps/am33/fpu/fegetenv.c create mode 100644 sysdeps/am33/fpu/fegetexcept.c create mode 100644 sysdeps/am33/fpu/fegetround.c create mode 100644 sysdeps/am33/fpu/feholdexcpt.c create mode 100644 sysdeps/am33/fpu/fenv_libc.h create mode 100644 sysdeps/am33/fpu/fesetenv.c create mode 100644 sysdeps/am33/fpu/fesetround.c create mode 100644 sysdeps/am33/fpu/feupdateenv.c create mode 100644 sysdeps/am33/fpu/fgetexcptflg.c create mode 100644 sysdeps/am33/fpu/fpu_control.h create mode 100644 sysdeps/am33/fpu/fraiseexcpt.c create mode 100644 sysdeps/am33/fpu/fsetexcptflg.c create mode 100644 sysdeps/am33/fpu/ftestexcept.c create mode 100644 sysdeps/am33/linuxthreads/pspinlock.c create mode 100644 sysdeps/am33/linuxthreads/pt-machine.h create mode 100644 sysdeps/am33/memusage.h create mode 100644 sysdeps/am33/preconfigure create mode 100644 sysdeps/am33/setjmp.S create mode 100644 sysdeps/am33/shlib-versions create mode 100644 sysdeps/am33/stackinfo.h create mode 100644 sysdeps/am33/sys/ucontext.h create mode 100644 sysdeps/am33/sysdep.h create mode 100644 sysdeps/unix/am33/sysdep.S create mode 100644 sysdeps/unix/am33/sysdep.h create mode 100644 sysdeps/unix/sysv/linux/am33/Makefile create mode 100644 sysdeps/unix/sysv/linux/am33/bits/fcntl.h create mode 100644 sysdeps/unix/sysv/linux/am33/bits/mman.h create mode 100644 sysdeps/unix/sysv/linux/am33/brk.c create mode 100644 sysdeps/unix/sysv/linux/am33/chown.c create mode 100644 sysdeps/unix/sysv/linux/am33/clone.S create mode 100755 sysdeps/unix/sysv/linux/am33/configure create mode 100644 sysdeps/unix/sysv/linux/am33/configure.in create mode 100644 sysdeps/unix/sysv/linux/am33/fchown.c create mode 100644 sysdeps/unix/sysv/linux/am33/fcntl.c create mode 100644 sysdeps/unix/sysv/linux/am33/fxstat.c create mode 100644 sysdeps/unix/sysv/linux/am33/getegid.c create mode 100644 sysdeps/unix/sysv/linux/am33/geteuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/getgid.c create mode 100644 sysdeps/unix/sysv/linux/am33/getgroups.c create mode 100644 sysdeps/unix/sysv/linux/am33/getmsg.c create mode 100644 sysdeps/unix/sysv/linux/am33/getresgid.c create mode 100644 sysdeps/unix/sysv/linux/am33/getresuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/getrlimit.c create mode 100644 sysdeps/unix/sysv/linux/am33/getuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/lchown.c create mode 100644 sysdeps/unix/sysv/linux/am33/lockf64.c create mode 100644 sysdeps/unix/sysv/linux/am33/lxstat.c create mode 100644 sysdeps/unix/sysv/linux/am33/profil-counter.h create mode 100644 sysdeps/unix/sysv/linux/am33/putmsg.c create mode 100644 sysdeps/unix/sysv/linux/am33/setegid.c create mode 100644 sysdeps/unix/sysv/linux/am33/seteuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setfsgid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setfsuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setgid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setgroups.c create mode 100644 sysdeps/unix/sysv/linux/am33/setregid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setresgid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setresuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setreuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/setrlimit.c create mode 100644 sysdeps/unix/sysv/linux/am33/setuid.c create mode 100644 sysdeps/unix/sysv/linux/am33/socket.S create mode 100644 sysdeps/unix/sysv/linux/am33/syscall.S create mode 100644 sysdeps/unix/sysv/linux/am33/sysdep.S create mode 100644 sysdeps/unix/sysv/linux/am33/sysdep.h create mode 100644 sysdeps/unix/sysv/linux/am33/xstat.c create mode 100644 sysdeps/unix/sysv/linux/linuxthreads/sysdep-cancel.h diff --git a/ChangeLog.am33 b/ChangeLog.am33 new file mode 100644 index 0000000000..dfca6e832c --- /dev/null +++ b/ChangeLog.am33 @@ -0,0 +1,207 @@ +2004-10-22 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/bits/mman.h (PROT_GROWSDOWN): New. + (PROT_GROWSUP): New. + +2004-08-16 Alexandre Oliva + + * sysdeps/am33/shlib-versions: Moved from top level. + +2004-08-09 Alexandre Oliva + + * sysdeps/am33/preconfigure: Renamed from configure. + * Makefile: Removed. + +2004-07-20 Alexandre Oliva + + Moved from separate linuxthreads tree into am33/linuxthreads + subdirs: + 2004-07-01 Alexandre Oliva + * sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h + (PSEUDO): Save value returned by CENABLE and pass it to CDISABLE. + * sysdeps/am33/linuxthreads/pt-machine.h (testandset): Take + volatile argument. Improve asm statement. + 2001-10-31 Alexandre Oliva + * sysdeps/am33/linuxthreads/pspinlock.c: New file. + * sysdeps/am33/linuxthreads/pt-machine.h: New file. + +2004-07-19 Alexandre Oliva + + * configure: New. + * mach.sh: Removed. + * sysdeps/am33/Makefile: Likewise. + +2004-06-28 Alexandre Oliva + + * sysdeps/am33/Makefile: New file. + * sysdeps/unix/sysv/linux/am33/configure.in: New file. + * sysdeps/unix/sysv/linux/am33/configure: New file. + * mach.sh: New file. + +2004-06-19 Alexandre Oliva + + * sysdeps/am33/fpu/bits/fenv.h: New file. + * sysdeps/am33/fpu/fpu_control.h: New file. + * sysdeps/am33/fpu/fenv_libc.h: New file. + * sysdeps/am33/fpu/fclrexcpt.c: New file. + * sysdeps/am33/fpu/fedisblxcpt.c: New file. + * sysdeps/am33/fpu/feenablxcpt.c: New file. + * sysdeps/am33/fpu/fegetenv.c: New file. + * sysdeps/am33/fpu/fegetexcept.c: New file. + * sysdeps/am33/fpu/fegetround.c: New file. + * sysdeps/am33/fpu/feholdexcpt.c: New file. + * sysdeps/am33/fpu/fesetenv.c: New file. + * sysdeps/am33/fpu/fesetround.c: New file. + * sysdeps/am33/fpu/feupdateenv.c: New file. + * sysdeps/am33/fpu/fgetexcptflg.c: New file. + * sysdeps/am33/fpu/fraiseexcpt.c: New file. + * sysdeps/am33/fpu/fsetexcptflg.c: New file. + * sysdeps/am33/fpu/ftestexcept.c: New file. + + * sysdeps/unix/am33/sysdep.h: Use relative pathnames. + * sysdeps/unix/sysv/linux/am33/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/am33/sysdep.S: Likewise. + * configure, Makefile: Do nothing. + +2004-06-09 Alexandre Oliva + + * sysdeps/am33/bsd-setjmp.S: Move into... + * sysdeps/am33/setjmp.S: ... this file. + * sysdeps/am33/bsd-_setjmp.S: Likewise. + * sysdeps/am33/dl-machine.h (_dl_start_user): Do not do double + indirection to obtain _dl_loaded. + (elf_machine_rela_relative): Do not add addend. + +2004-06-08 Alexandre Oliva + + * sysdeps/am33/sysdep.h (JUMPTARGET): Undef before redefining. + * sysdeps/unix/sysv/linux/am33/sysdep.h (PSEUDO_NOERROR, + PSEUDO_END_NOERROR, ret_NOERROR, PSEUDO_ERRVAL, PSEUDO_END_ERRVAL, + ret_ERRVAL, INTERNAL_SYSCALL, INTERNAL_SYSCALL_DECL, + INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New. + (INLINE_SYSCALL): Rewrite in terms of INTERNAL_SYSCALL macros. + (DO_CALL): Reorder arguments. + * sysdeps/am33/dl-machine.h (elf_machine_rela): Update prototype. + +2003-05-16 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/Makefile: New file. + * sysdeps/unix/sysv/linux/am33/sysdep.h (INLINE_SYSCALL1): Drop + comma before args when calling inline_syscall0. + * sysdeps/unix/sysv/linux/am33/chown.c: New file. + * sysdeps/unix/sysv/linux/am33/fchown.c: New file. + * sysdeps/unix/sysv/linux/am33/fxstat.c: New file. + * sysdeps/unix/sysv/linux/am33/getegid.c: New file. + * sysdeps/unix/sysv/linux/am33/geteuid.c: New file. + * sysdeps/unix/sysv/linux/am33/getgid.c: New file. + * sysdeps/unix/sysv/linux/am33/getrlimit.c: New file. + * sysdeps/unix/sysv/linux/am33/getuid.c: New file. + * sysdeps/unix/sysv/linux/am33/lchown.c: New file. + * sysdeps/unix/sysv/linux/am33/lockf64.c: New file. + * sysdeps/unix/sysv/linux/am33/lxstat.c: New file. + * sysdeps/unix/sysv/linux/am33/setegid.c: New file. + * sysdeps/unix/sysv/linux/am33/seteuid.c: New file. + * sysdeps/unix/sysv/linux/am33/setfsgid.c: New file. + * sysdeps/unix/sysv/linux/am33/setfsuid.c: New file. + * sysdeps/unix/sysv/linux/am33/setgid.c: New file. + * sysdeps/unix/sysv/linux/am33/setregid.c: New file. + * sysdeps/unix/sysv/linux/am33/setresgid.c: New file. + * sysdeps/unix/sysv/linux/am33/setresuid.c: New file. + * sysdeps/unix/sysv/linux/am33/setreuid.c: New file. + * sysdeps/unix/sysv/linux/am33/setrlimit.c: New file. + * sysdeps/unix/sysv/linux/am33/setuid.c: New file. + * sysdeps/unix/sysv/linux/am33/xstat.c: New file. + * sysdeps/unix/sysv/linux/am33/syscalls.list: Removed, reverting + 2003-03-26's patch. + * sysdeps/unix/sysv/linux/am33/getresgid.c: New file. + * sysdeps/unix/sysv/linux/am33/getresuid.c: New file. + +2003-05-09 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/getgroups.c: New file. + * sysdeps/unix/sysv/linux/am33/setgroups.c: New file. + +2003-05-07 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/getmsg.c: New file. + * sysdeps/unix/sysv/linux/am33/putmsg.c: New file. + +2003-03-26 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/syscalls.list: Added getresuid and + getresgid. + +2003-01-17 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/fcntl.c: New file. + +2002-02-08 Alexandre Oliva + + * sysdeps/am33/sys/ucontext.h (fpregset_t): Make it a structure. + +2002-01-07 Alexandre Oliva + + * sysdeps/am33/sys/ucontext.h (NFREG): Increment by 1, to make + room for FPCR. + +2001-12-13 Alexandre Oliva + + * shlib-versions: Set GLIBC_2.2.5 as the earliest symbol set. + +2001-12-07 Alexandre Oliva + + * sysdeps/am33/__longjmp.S: Tabify. + * sysdeps/am33/setjmp.S: Likewise. + * sysdeps/am33/dl-debug.h: Remove. + * sysdeps/am33/dl-machine.h: Delete commented-out uses of + macros defined in dl-debug. + (elf_machine_rela): Optimize if HAVE_Z_COMBRELOC. Fix + prediction of R_MN10300_NONE. Don't test for impossible + condition. + * sysdeps/am33/sysdep.h (ASM_TYPE_DIRECTIVE, + ASM_SIZE_DIRECTIVE): Define to nothing if ! HAVE_ELF. + +2001-11-09 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/clone.S: Avoid branch overflow in + static link. + +2001-11-08 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/clone.S: Load arguments correctly + for syscall. + +2001-11-07 Alexandre Oliva + + * sysdeps/unix/sysv/linux/am33/clone.S: Fix argument-passing + to thread_start. + +2001-10-31 Alexandre Oliva + + * shlib-versions: Added am33_2.0 support. + * sysdeps/am33/Implies: New file. + * sysdeps/am33/__longjmp.S: New file. + * sysdeps/am33/atomicity.h: New file. + * sysdeps/am33/bsd-_setjmp.S: New file. + * sysdeps/am33/bsd-setjmp.S: New file. + * sysdeps/am33/dl-debug.h: New file. + * sysdeps/am33/dl-machine.h: New file. + * sysdeps/am33/memusage.h: New file. + * sysdeps/am33/setjmp.S: New file. + * sysdeps/am33/stackinfo.h: New file. + * sysdeps/am33/sysdep.h: New file. + * sysdeps/am33/bits/endian.h: New file. + * sysdeps/am33/bits/setjmp.h: New file. + * sysdeps/am33/elf/start.S: New file. + * sysdeps/am33/sys/ucontext.h: New file. + * sysdeps/unix/am33/sysdep.S: New file. + * sysdeps/unix/am33/sysdep.h: New file. + * sysdeps/unix/sysv/linux/am33/brk.c: New file. + * sysdeps/unix/sysv/linux/am33/clone.S: New file. + * sysdeps/unix/sysv/linux/am33/profil-counter.h: New file. + * sysdeps/unix/sysv/linux/am33/socket.S: New file. + * sysdeps/unix/sysv/linux/am33/syscall.S: New file. + * sysdeps/unix/sysv/linux/am33/sysdep.S: New file. + * sysdeps/unix/sysv/linux/am33/sysdep.h: New file. + * sysdeps/unix/sysv/linux/am33/bits/fcntl.h: New file. + * sysdeps/unix/sysv/linux/am33/bits/mman.h: New file. diff --git a/sysdeps/am33/Implies b/sysdeps/am33/Implies new file mode 100644 index 0000000000..780c4e2467 --- /dev/null +++ b/sysdeps/am33/Implies @@ -0,0 +1,3 @@ +wordsize-32 +ieee754/flt-32 +ieee754/dbl-64 diff --git a/sysdeps/am33/__longjmp.S b/sysdeps/am33/__longjmp.S new file mode 100644 index 0000000000..9bdcc489e8 --- /dev/null +++ b/sysdeps/am33/__longjmp.S @@ -0,0 +1,61 @@ +/* longjmp for AM33. + Copyright 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#define _ASM +#define _SETJMP_H +#include +#include + +ENTRY (__longjmp) + mov d0,a0 + mov (8,a0),d2 + mov d2,mdr + mov (0,a0),d2 + mov (4,a0),d3 + mov (12,a0),a2 + mov (16,a0),a3 + mov (20,a0),a1 + mov a1,sp + add 24,a0 + mov (a0+),r4 + mov (a0+),r5 + mov (a0+),r6 + mov (a0+),r7 +#ifdef __AM33_2__ + fmov (a0+),fs4 + fmov (a0+),fs5 + fmov (a0+),fs6 + fmov (a0+),fs7 + fmov (a0+),fs8 + fmov (a0+),fs9 + fmov (a0+),fs10 + fmov (a0+),fs11 + fmov (a0+),fs12 + fmov (a0+),fs13 + fmov (a0+),fs14 + fmov (a0+),fs15 + fmov (a0+),fs16 + fmov (a0+),fs17 + fmov (a0+),fs18 + fmov (a0+),fs19 +#endif + mov d1,d0 + retf [],0 +END (__longjmp) diff --git a/sysdeps/am33/atomicity.h b/sysdeps/am33/atomicity.h new file mode 100644 index 0000000000..d7765338ac --- /dev/null +++ b/sysdeps/am33/atomicity.h @@ -0,0 +1,87 @@ +/* Low-level functions for atomic operations. AM33 version. + Copyright 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva . + Based on ../sparc/sparc32/atomicity.h + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _ATOMICITY_H +#define _ATOMICITY_H 1 + +#include + +#define __acquire_lock(lock) \ + __asm__ __volatile__("1: bset %1, (%0)\n\t" \ + " beq 1b" \ + : : "a" (&(lock)), "d" (1) \ + : "memory") + +#define __release_lock(lock) lock = 0 + +static int +__attribute__ ((unused)) +exchange_and_add (volatile uint32_t *mem, int val) +{ + static unsigned char lock; + int result; + + __acquire_lock (lock); + + result = *mem; + *mem += val; + + __release_lock (lock); + + return result; +} + +static void +__attribute__ ((unused)) +atomic_add (volatile uint32_t *mem, int val) +{ + static unsigned char lock; + + __acquire_lock (lock); + + *mem += val; + + __release_lock (lock); +} + +static int +__attribute__ ((unused)) +compare_and_swap (volatile long int *p, long int oldval, long int newval) +{ + static unsigned char lock; + int ret; + + __acquire_lock (lock); + + if (*p != oldval) + ret = 0; + else + { + *p = newval; + ret = 1; + } + + __release_lock (lock); + + return ret; +} + +#endif /* atomicity.h */ diff --git a/sysdeps/am33/bits/endian.h b/sysdeps/am33/bits/endian.h new file mode 100644 index 0000000000..7423f09570 --- /dev/null +++ b/sysdeps/am33/bits/endian.h @@ -0,0 +1,7 @@ +/* AM33 is little-endian. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/sysdeps/am33/bits/setjmp.h b/sysdeps/am33/bits/setjmp.h new file mode 100644 index 0000000000..5864b92e64 --- /dev/null +++ b/sysdeps/am33/bits/setjmp.h @@ -0,0 +1,34 @@ +/* Copyright 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Define the machine-dependent type `jmp_buf'. AM33 version. */ + +#ifndef _SETJMP_H +# error "Never include directly; use instead." +#endif + +#ifndef _ASM +typedef int __jmp_buf[26]; +#endif + +#define __JMP_BUF_SP 20 + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP])) diff --git a/sysdeps/am33/bsd-_setjmp.S b/sysdeps/am33/bsd-_setjmp.S new file mode 100644 index 0000000000..9bbfcbbba7 --- /dev/null +++ b/sysdeps/am33/bsd-_setjmp.S @@ -0,0 +1 @@ +/* _setjmp is in setjmp.S */ diff --git a/sysdeps/am33/bsd-setjmp.S b/sysdeps/am33/bsd-setjmp.S new file mode 100644 index 0000000000..b6b239e67d --- /dev/null +++ b/sysdeps/am33/bsd-setjmp.S @@ -0,0 +1 @@ +/* setjmp is in setjmp.S */ diff --git a/sysdeps/am33/dl-machine.h b/sysdeps/am33/dl-machine.h new file mode 100644 index 0000000000..808fd9cc82 --- /dev/null +++ b/sysdeps/am33/dl-machine.h @@ -0,0 +1,481 @@ +/* Machine-dependent ELF dynamic relocation inline functions. AM33 version. + Copyright (C) 1995,96,97,98,99,2000,2001, 2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef dl_machine_h +#define dl_machine_h + +#define ELF_MACHINE_NAME "mn10300" + +#include + +/* Return nonzero iff ELF header is compatible with the running host. */ +static inline int __attribute__ ((unused)) +elf_machine_matches_host (const Elf32_Ehdr *ehdr) +{ + return ehdr->e_machine == EM_MN10300; +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. This must be inlined in a function which + uses global data. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_dynamic (void) +{ + register Elf32_Addr *got asm ("a2"); + return *got; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr __attribute__ ((unused)) +elf_machine_load_address (void) +{ + register Elf32_Addr gotaddr asm ("a2"); + Elf32_Addr off, gotval; + + asm ("mov _dl_start@GOTOFF,%0" : "=r" (off)); + asm ("mov (_dl_start@GOT,%1),%0" : "=r" (gotval) : "r" (gotaddr)); + + return off + gotaddr - gotval; +} + +#if !defined PROF && !__BOUNDED_POINTERS__ +/* We add a declaration of this function here so that in dl-runtime.c + the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters + in registers. + + We cannot use this scheme for profiling because the _mcount call + destroys the passed register information. */ +/* GKM FIXME: Fix trampoline to pass bounds so we can do + without the `__unbounded' qualifier. */ +static ElfW(Addr) fixup (struct link_map *__unbounded l, ElfW(Word) reloc_offset) + __attribute__ ((unused)); +static ElfW(Addr) profile_fixup (struct link_map *l, ElfW(Word) reloc_offset, + ElfW(Addr) retaddr) + __attribute__ ((unused)); +#endif + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((unused)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + Elf32_Addr *got; + extern void _dl_runtime_resolve (Elf32_Word) attribute_hidden; + extern void _dl_runtime_profile (Elf32_Word) attribute_hidden; + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been filled + in. Their initial contents will arrange when called to push an + offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1], + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ + got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (__builtin_expect (profile, 0)) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + + if (_dl_name_match_p (GLRO(dl_profile), l)) + /* This is the object we are looking for. Say that we really + want profiling and the timers are started. */ + GL(dl_profile_map) = l; + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; + } + + return lazy; +} + +/* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ +#if !defined PROF && !__BOUNDED_POINTERS__ +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .text\n\ + .globl _dl_runtime_resolve\n\ + .type _dl_runtime_resolve, @function\n\ +_dl_runtime_resolve:\n\ + add -12,sp # Preserve registers otherwise clobbered.\n\ + mov d1,(20,sp)\n\ + mov d0,(16,sp)\n\ + mov r1,d0\n\ + mov r0,d1\n\ + call fixup,[],0 # Call resolver.\n\ + mov d0,a0\n\ + mov (12,sp),d1 # Copy return address back to mdr,\n\ + mov d1,mdr # in case the callee returns with retf\n\ + mov (16,sp),d0 # Get register content back.\n\ + mov (20,sp),d1\n\ + add 12,sp\n\ + jmp (a0)\n\ + .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ +\n\ + .globl _dl_runtime_profile\n\ + .type _dl_runtime_profile, @function\n\ +_dl_runtime_profile:\n\ + add -12,sp # Preserve registers otherwise clobbered.\n\ + mov d1,(20,sp)\n\ + mov d0,(16,sp)\n\ + mov r1,d0\n\ + mov r0,d1\n\ + call profile_fixup,[],0 # Call resolver.\n\ + mov d0,a0\n\ + mov (12,sp),d1 # Copy return address back to mdr,\n\ + mov d1,mdr # in case the callee returns with retf\n\ + mov (16,sp),d0 # Get register content back.\n\ + mov (20,sp),d1\n\ + add 12,sp\n\ + jmp (a0)\n\ + .size _dl_runtime_profile, .-_dl_runtime_profile\n\ + .previous\n\ +"); +#else +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\n\ + .text\n\ + .globl _dl_runtime_resolve\n\ + .globl _dl_runtime_profile\n\ + .type _dl_runtime_resolve, @function\n\ + .type _dl_runtime_profile, @function\n\ +_dl_runtime_resolve:\n\ +_dl_runtime_profile:\n\ + add -12,sp # Preserve registers otherwise clobbered.\n\ + mov d1,(20,sp)\n\ + mov d0,(16,sp)\n\ + mov r1,d0\n\ + mov r0,d1\n\ + call profile_fixup,[],0 # Call resolver.\n\ + mov d0,a0\n\ + mov (12,sp),d1 # Copy return address back to mdr,\n\ + mov d1,mdr # in case the callee returns with retf\n\ + mov (16,sp),d0 # Get register content back.\n\ + mov (20,sp),d1\n\ + add 12,sp\n\ + jmp (a0)\n\ + .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\ + .size _dl_runtime_profile, .-_dl_runtime_profile\n\ + .previous\n\ +"); +#endif + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ +#define RTLD_START asm ("\n\ + .text\n\ +.globl _start\n\ +.globl _dl_start_user\n\ +_start:\n\ + mov 0,a3 # Mark the top of the stack\n\ + mov sp,a1\n\ + add -20,sp # Prepare for function call\n\ + mov a1,d0\n\ + call _dl_start,[],0\n\ +_dl_start_user:\n\ + # Save the user entry point address in d2.\n\ + mov d0,d2\n\ + # Point a2 at the GOT.\n\ +0: mov pc,a2\n\ + add _GLOBAL_OFFSET_TABLE_ - (0b-.),a2\n\ + # Store the highest stack address\n\ + mov (__libc_stack_end@GOT,a2),a0\n\ + mov a1,(a0)\n\ + # See if we were run as a command with the executable file\n\ + # name as an extra leading argument.\n\ + mov (_dl_skip_args@GOT,a2),a0\n\ + mov (a0),d0\n\ + # Pop the original argument count.\n\ + mov (20,sp),d3\n\ + # Subtract _dl_skip_args from it.\n\ + sub d0,d3\n\ + # Adjust the stack pointer to skip _dl_skip_args words.\n\ + asl2 d0\n\ + mov sp,a0\n\ + add d0,a0\n\ + mov a0,sp\n\ + # Push argc back on the stack.\n\ + mov d3,(20,sp)\n\ + # The special initializer gets called with the stack just\n\ + # as the application's entry point will see it; it can\n\ + # switch stacks if it moves these contents over.\n\ +" RTLD_START_SPECIAL_INIT "\n\ + # Load the parameters again.\n\ + # (d0, d1, (12,sp), (16,sp)) = (_dl_loaded, argc, argv, envp)\n\ + add 24,a0\n\ + mov a0,(12,sp) # a0 is 24+sp\n\ + mov d3,d1 # d3 contained argc\n\ + inc d3\n\ + asl2 d3 # d3 is now (argc+1)*4,\n\ + add d3,a0 # the offset between argv and envp\n\ + mov a0,(16,sp)\n\ + mov (_rtld_local@GOTOFF,a2),d0\n\ + # Call the function to run the initializers.\n\ + call _dl_init@PLT,[],0\n\ + # Pass our finalizer function to the user in d0, as per ELF ABI.\n\ + mov (_dl_fini@GOT,a2),d0\n\ + add 20,sp\n\ + # Jump to the user's entry point.\n\ + mov d2,a1\n\ + jmp (a1)\n\ + .previous\n\ +"); + +#ifndef RTLD_START_SPECIAL_INIT +#define RTLD_START_SPECIAL_INIT /* nothing */ +#endif + +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so + PLT entries should not be allowed to define the value. + ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one + of the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_type_class(type) \ + ((((type) == R_MN10300_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \ + | (((type) == R_MN10300_COPY) * ELF_RTYPE_CLASS_COPY)) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_MN10300_JMP_SLOT + +static inline Elf32_Addr +elf_machine_fixup_plt (struct link_map *map, lookup_t t, + const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + return *reloc_addr = value; +} + +/* Return the final value of a plt relocation. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value + reloc->r_addend; +} + +#endif /* !dl_machine_h */ + +#ifdef RESOLVE + +/* The mn10300 never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +static inline void +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + void *const reloc_addr_arg) +{ + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + Elf32_Addr value, *reloc_addr; + + /* Make sure we drop any previous alignment assumptions. */ + asm ("" : "=r" (reloc_addr) : "0" (reloc_addr_arg)); + +#define COPY_UNALIGNED_WORD(sw, tw, align) \ + { \ + unsigned long *__sl = (void*)&(sw), *__tl = (void*)&(tw); \ + unsigned short *__ss = (void*)&(sw), *__ts = (void*)&(tw); \ + unsigned char *__sc = (void*)&(sw), *__tc = (void*)&(tw); \ + switch ((align)) \ + { \ + case 0: \ + *__tl = *__sl; \ + break; \ + case 2: \ + *__ts++ = *__ss++; \ + *__ts = *__ss; \ + break; \ + default: \ + *__tc++ = *__sc++; \ + *__tc++ = *__sc++; \ + *__tc++ = *__sc++; \ + *__tc = *__sc; \ + break; \ + } \ + } + +#define COPY_UNALIGNED_HALFWORD(sw, tw, align) \ + { \ + unsigned short *__ss = (void*)&(sw), *__ts = (void*)&(tw); \ + unsigned char *__sc = (void*)&(sw), *__tc = (void*)&(tw); \ + switch ((align)) \ + { \ + case 0: \ + *__ts = *__ss; \ + break; \ + default: \ + *__tc++ = *__sc++; \ + *__tc = *__sc; \ + break; \ + } \ + } + +#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC + if (__builtin_expect (r_type == R_MN10300_RELATIVE, 0)) + { +# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC + /* This is defined in rtld.c, but nowhere in the static libc.a; + make the reference weak so static programs can still link. + This declaration cannot be done when compiling rtld.c (i.e. + #ifdef RTLD_BOOTSTRAP) because rtld.c contains the common + defn for _dl_rtld_map, which is incompatible with a weak decl + in the same file. */ + weak_extern (_dl_rtld_map); + if (map != &_dl_rtld_map) /* Already done in rtld itself. */ +# endif + { + COPY_UNALIGNED_WORD (*reloc_addr, value, (int) reloc_addr & 3); + value += map->l_addr; + COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3); + } + } +# ifndef RTLD_BOOTSTRAP + else if (__builtin_expect (r_type == R_MN10300_NONE, 0)) + return; +# endif + else +#endif + { +#ifndef RTLD_BOOTSTRAP + const Elf32_Sym *const refsym = sym; +#endif + + value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info)); + if (sym) + value += sym->st_value; + value += reloc->r_addend; /* Assume copy relocs have zero addend. */ + + switch (r_type) + { +#ifndef RTLD_BOOTSTRAP + case R_MN10300_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (sym->st_size > refsym->st_size + || (GLRO(dl_verbose) && sym->st_size < refsym->st_size)) + { + extern char **_dl_argv; + const char *strtab; + + strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); + _dl_error_printf ("\ +%s: Symbol `%s' has different size in shared object, consider re-linking\n", + _dl_argv[0] ?: "", + strtab + refsym->st_name); + } + memcpy (reloc_addr, (void *) value, MIN (sym->st_size, + refsym->st_size)); + break; +#endif + case R_MN10300_GLOB_DAT: + case R_MN10300_JMP_SLOT: + /* These addresses are always aligned. */ + *reloc_addr = value; + break; + case R_MN10300_32: + COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3); + break; +#ifndef RTLD_BOOTSTRAP + case R_MN10300_16: + COPY_UNALIGNED_HALFWORD (value, *reloc_addr, (int) reloc_addr & 1); + break; + case R_MN10300_8: + *(char *) reloc_addr = value; + break; + case R_MN10300_PCREL32: + value -= (Elf32_Addr) reloc_addr; + COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3); + break; + case R_MN10300_PCREL16: + value -= (Elf32_Addr) reloc_addr; + COPY_UNALIGNED_HALFWORD (value, *reloc_addr, (int) reloc_addr & 1); + break; + case R_MN10300_PCREL8: + value -= (Elf32_Addr) reloc_addr; + *(char *) reloc_addr = (value - (Elf32_Addr) reloc_addr); + break; +#endif + case R_MN10300_NONE: /* Alright, Wilbur. */ + break; +#if !defined RTLD_BOOTSTRAP || defined _NDEBUG + default: + _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0); + break; +#endif + } + + } +} + +static inline void +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, + void *const reloc_addr_arg) +{ + Elf32_Addr value, *reloc_addr; + + asm ("" : "=r" (reloc_addr) : "0" (reloc_addr_arg)); + + COPY_UNALIGNED_WORD (*reloc_addr, value, (int)reloc_addr & 3); + value += l_addr; + COPY_UNALIGNED_WORD (value, *reloc_addr, (int)reloc_addr & 3); +} + +static inline void +elf_machine_lazy_rel (struct link_map *map, + Elf32_Addr l_addr, const Elf32_Rela *reloc) +{ + unsigned long int const r_type = ELF32_R_TYPE (reloc->r_info); + + /* Check for unexpected PLT reloc type. */ + if (__builtin_expect (r_type, R_MN10300_JMP_SLOT) == R_MN10300_JMP_SLOT) + { + Elf32_Addr* const reloc_addr = (void *)(l_addr + reloc->r_offset); + Elf32_Addr value; + + /* Perform a RELATIVE reloc on the .got entry that transfers + to the .plt. */ + COPY_UNALIGNED_WORD (*reloc_addr, value, (int)reloc_addr & 3); + value += l_addr; + COPY_UNALIGNED_WORD (value, *reloc_addr, (int)reloc_addr & 3); + } + else if (__builtin_expect (r_type, R_MN10300_NONE) != R_MN10300_NONE) + _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1); + +} + +#endif /* RESOLVE */ diff --git a/sysdeps/am33/elf/start.S b/sysdeps/am33/elf/start.S new file mode 100644 index 0000000000..1b654595c4 --- /dev/null +++ b/sysdeps/am33/elf/start.S @@ -0,0 +1,81 @@ +/* Startup code compliant to the ELF MN10300 ABI. + Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc. + Contributed by Alexandre Oliva + Based on ../../i386/elf/start.S. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This is the canonical entry point, usually the first thing in the text + segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry + point runs, most registers' values are unspecified, except for: + + a0 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + sp The stack contains the arguments and environment: + (4,sp) argc + (8,sp) argv[0] + ... + (4*(argc+1),sp) NULL + (4*(argc+2),sp) envp[0] + ... + NULL +*/ + +#include "bp-sym.h" + + .text + .globl _start + .type _start,@function +_start: + /* Extract the arguments as encoded on the stack and set up + the arguments for `main': argc, argv. envp will be determined + later in __libc_start_main. */ + mov sp,a3 + add -32,sp + + mov a3,(28,sp) /* stack_end. */ + mov d0,(24,sp) /* rtld_fini. */ + mov _fini, d3 + mov d3,(20,sp) /* fini. */ + mov _init, d2 + mov d2,(16,sp) /* init. */ + inc4 a3 + mov a3,(12,sp) /* argv. */ + + /* Set the initial frame pointer as 0, so that the bottom of + the stack is clearly marked. */ + mov 0,a3 + + mov (32,sp), d1 /* argc. */ + mov BP_SYM (main), d0 /* main. */ + + /* Call the user's main function, and exit with its value. + But let the libc call main. */ + call BP_SYM (__libc_start_main),[],0 + + call BP_SYM (abort),[],0 /* Crash if somehow `exit' does return. */ + +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff --git a/sysdeps/am33/fpu/bits/fenv.h b/sysdeps/am33/fpu/bits/fenv.h new file mode 100644 index 0000000000..04fe293b13 --- /dev/null +++ b/sysdeps/am33/fpu/bits/fenv.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on the corresponding file in the mips port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + + +/* Define bits representing the exception. We use the EF bit + positions of the appropriate bits in the FPCR register. */ +enum + { + FE_INEXACT = 0x01, +#define FE_INEXACT FE_INEXACT + FE_UNDERFLOW = 0x02, +#define FE_UNDERFLOW FE_UNDERFLOW + FE_OVERFLOW = 0x04, +#define FE_OVERFLOW FE_OVERFLOW + FE_DIVBYZERO = 0x08, +#define FE_DIVBYZERO FE_DIVBYZERO + FE_INVALID = 0x10, +#define FE_INVALID FE_INVALID + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The AM33/2.0 FPU supports only Round to nearest. Bits 3<<16 are + reserved to represent other rounding modes. */ +enum + { + FE_TONEAREST = 0x00000, +#define FE_TONEAREST FE_TONEAREST + }; + + +/* Type representing exception flags. */ +typedef unsigned int fexcept_t; + + +/* Type representing floating-point environment. */ +typedef unsigned int fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((__const fenv_t *) -1) + +#ifdef __USE_GNU +/* Floating-point environment where none of the exception is masked. */ +# define FE_NOMASK_ENV ((__const fenv_t *) -2) +#endif diff --git a/sysdeps/am33/fpu/fclrexcpt.c b/sysdeps/am33/fpu/fclrexcpt.c new file mode 100644 index 0000000000..0c98b4ea99 --- /dev/null +++ b/sysdeps/am33/fpu/fclrexcpt.c @@ -0,0 +1,52 @@ +/* Clear given exceptions in current floating-point environment. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include + +int +__feclearexcept (int excepts) +{ + fpu_control_t cw; + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + /* Read the complete control word. */ + _FPU_GETCW (cw); + + /* Clear exception flag bits and cause bits. EF bits are cleared by + assigning 1 to them (and there's no way to set them); other bits + are copied normally. */ + + cw &= ~((excepts << CAUSE_SHIFT) | FE_ALL_EXCEPT); + cw |= excepts; + + /* Put the new data in effect. */ + _FPU_SETFCW (cw); + + /* Success. */ + return 0; +} + +versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2); diff --git a/sysdeps/am33/fpu/fedisblxcpt.c b/sysdeps/am33/fpu/fedisblxcpt.c new file mode 100644 index 0000000000..b4a5977737 --- /dev/null +++ b/sysdeps/am33/fpu/fedisblxcpt.c @@ -0,0 +1,42 @@ +/* Disable floating-point exceptions. + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +fedisableexcept (int excepts) +{ + fpu_control_t new_exc, old_exc; + + /* Get the current control word. */ + _FPU_GETCW (new_exc); + + old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT; + + excepts &= FE_ALL_EXCEPT; + + new_exc &= ~(excepts << ENABLE_SHIFT); + _FPU_SETCW (new_exc); + + return old_exc; +} diff --git a/sysdeps/am33/fpu/feenablxcpt.c b/sysdeps/am33/fpu/feenablxcpt.c new file mode 100644 index 0000000000..0ecaa18877 --- /dev/null +++ b/sysdeps/am33/fpu/feenablxcpt.c @@ -0,0 +1,42 @@ +/* Enable floating-point exceptions. + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +feenableexcept (int excepts) +{ + fpu_control_t new_exc, old_exc; + + /* Get the current control word. */ + _FPU_GETCW (new_exc); + + old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT; + + excepts &= FE_ALL_EXCEPT; + + new_exc |= excepts << ENABLE_SHIFT; + _FPU_SETCW (new_exc); + + return old_exc; +} diff --git a/sysdeps/am33/fpu/fegetenv.c b/sysdeps/am33/fpu/fegetenv.c new file mode 100644 index 0000000000..f0828011bf --- /dev/null +++ b/sysdeps/am33/fpu/fegetenv.c @@ -0,0 +1,35 @@ +/* Store current floating-point environment. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +__fegetenv (fenv_t *envp) +{ + _FPU_GETCW (*envp); + + /* Success. */ + return 0; +} + +versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2); diff --git a/sysdeps/am33/fpu/fegetexcept.c b/sysdeps/am33/fpu/fegetexcept.c new file mode 100644 index 0000000000..500a0f8228 --- /dev/null +++ b/sysdeps/am33/fpu/fegetexcept.c @@ -0,0 +1,35 @@ +/* Get enabled floating-point exceptions. + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +fegetexcept (void) +{ + unsigned int exc; + + /* Get the current control word. */ + _FPU_GETCW (exc); + + return (exc & ENABLE_MASK) >> ENABLE_SHIFT; +} diff --git a/sysdeps/am33/fpu/fegetround.c b/sysdeps/am33/fpu/fegetround.c new file mode 100644 index 0000000000..2b914075be --- /dev/null +++ b/sysdeps/am33/fpu/fegetround.c @@ -0,0 +1,35 @@ +/* Return current rounding direction. + Copyright (C) 1998, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +fegetround (void) +{ + int cw; + + /* Get control word. */ + _FPU_GETCW (cw); + + return (cw & ROUND_MASK); +} diff --git a/sysdeps/am33/fpu/feholdexcpt.c b/sysdeps/am33/fpu/feholdexcpt.c new file mode 100644 index 0000000000..e90fb67daf --- /dev/null +++ b/sysdeps/am33/fpu/feholdexcpt.c @@ -0,0 +1,39 @@ +/* Store current floating-point environment and clear exceptions. + Copyright (C) 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +int +feholdexcept (fenv_t *envp) +{ + fpu_control_t cw; + + /* Save the current state. */ + _FPU_GETCW (cw); + *envp = cw; + + /* Clear all exception enable bits and flags. */ + cw &= ~(_FPU_MASK_V|_FPU_MASK_Z|_FPU_MASK_O|_FPU_MASK_U|_FPU_MASK_I); + _FPU_SETFCW (cw); + + return 0; +} diff --git a/sysdeps/am33/fpu/fenv_libc.h b/sysdeps/am33/fpu/fenv_libc.h new file mode 100644 index 0000000000..508145470f --- /dev/null +++ b/sysdeps/am33/fpu/fenv_libc.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on the corresponding file in the mips port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FENV_LIBC_H +#define _FENV_LIBC_H 1 + +/* Mask for enabling exceptions and for the CAUSE bits. */ +#define ENABLE_MASK 0x003E0U +#define CAUSE_MASK 0x07C00U +#define ROUND_MASK 0x30000U + +/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits. */ +#define ENABLE_SHIFT 5 +#define CAUSE_SHIFT 10 + +#endif /* _FENV_LIBC_H */ diff --git a/sysdeps/am33/fpu/fesetenv.c b/sysdeps/am33/fpu/fesetenv.c new file mode 100644 index 0000000000..4c551a5c1d --- /dev/null +++ b/sysdeps/am33/fpu/fesetenv.c @@ -0,0 +1,60 @@ +/* Install given floating-point environment. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +__fesetenv (const fenv_t *envp) +{ + fpu_control_t cw; + + /* We want to clear all EF bits for the default end IEEE. */ + + if (envp == FE_DFL_ENV) + _FPU_SETFCW (_FPU_DEFAULT|FE_ALL_EXCEPT); + else if (envp == FE_NOMASK_ENV) + _FPU_SETFCW (_FPU_IEEE|FE_ALL_EXCEPT); + else + { + fpu_control_t temp; + + _FPU_GETCW (temp); + cw = *envp; + + /* If EF bits are cleared and the user requests them to be set, + we have to fail, because there's no way to do it. */ + if (~temp & cw & FE_ALL_EXCEPT) + return -1; + + /* We clear EF bits by storing a 1 in them, so flip the + FE_ALL_EXCEPT bits. */ + cw = (cw & ~FE_ALL_EXCEPT) | (~cw & FE_ALL_EXCEPT); + _FPU_SETFCW (cw); + } + + /* Success. */ + return 0; +} + +libm_hidden_ver (__fesetenv, fesetenv) +versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2); diff --git a/sysdeps/am33/fpu/fesetround.c b/sysdeps/am33/fpu/fesetround.c new file mode 100644 index 0000000000..b1e2b240c2 --- /dev/null +++ b/sysdeps/am33/fpu/fesetround.c @@ -0,0 +1,29 @@ +/* Set current rounding direction. + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +int +fesetround (int round) +{ + /* The only supported rounding mode is to-nearest. Just check + whether we're switching to it. */ + return (round != FE_TONEAREST); +} diff --git a/sysdeps/am33/fpu/feupdateenv.c b/sysdeps/am33/fpu/feupdateenv.c new file mode 100644 index 0000000000..e4a0e39d2f --- /dev/null +++ b/sysdeps/am33/fpu/feupdateenv.c @@ -0,0 +1,47 @@ +/* Install given floating-point environment and raise exceptions. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +__feupdateenv (const fenv_t *envp) +{ + int temp; + + /* Save current exceptions. */ + _FPU_GETCW (temp); + temp &= FE_ALL_EXCEPT; + + /* Install new environment. */ + fesetenv (envp); + + /* Raise the safed exception. Incidently for us the implementation + defined format of the values in objects of type fexcept_t is the + same as the ones specified using the FE_* constants. */ + feraiseexcept (temp); + + /* Success. */ + return 0; +} + +versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2); diff --git a/sysdeps/am33/fpu/fgetexcptflg.c b/sysdeps/am33/fpu/fgetexcptflg.c new file mode 100644 index 0000000000..0e8512c9cb --- /dev/null +++ b/sysdeps/am33/fpu/fgetexcptflg.c @@ -0,0 +1,44 @@ +/* Store current representation for exceptions. + Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Alexandre Oliva + based on corresponding file in the MIPS port. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +int +__fegetexceptflag (fexcept_t *flagp, int excepts) +{ + fexcept_t temp; + + /* Get the current exceptions. */ + _FPU_GETCW (temp); + + /* We only save the relevant bits here. In particular, care has to be + taken with the CAUSE bits, as an inadvertent restore later on could + generate unexpected exceptions. */ + + *flagp = temp