From 522e6ee3b45808ea845ec0ac11d5fffcd737baba Mon Sep 17 00:00:00 2001 From: Chung-Lin Tang Date: Sat, 17 Jan 2015 22:29:12 -0800 Subject: Commit nios2 port to master. --- ChangeLog | 104 + NEWS | 2 + sysdeps/nios2/Implies | 3 + sysdeps/nios2/Makefile | 35 + sysdeps/nios2/Subdirs | 1 + sysdeps/nios2/Versions | 12 + sysdeps/nios2/__longjmp.S | 80 + sysdeps/nios2/abort-instr.h | 2 + sysdeps/nios2/backtrace.c | 1 + sysdeps/nios2/bits/endian.h | 12 + sysdeps/nios2/bits/fenv.h | 44 + sysdeps/nios2/bits/link.h | 54 + sysdeps/nios2/bits/setjmp.h | 30 + sysdeps/nios2/bsd-_setjmp.S | 1 + sysdeps/nios2/bsd-setjmp.S | 1 + sysdeps/nios2/configure | 162 ++ sysdeps/nios2/configure.ac | 13 + sysdeps/nios2/crti.S | 96 + sysdeps/nios2/crtn.S | 49 + sysdeps/nios2/dl-init.c | 30 + sysdeps/nios2/dl-machine.h | 335 +++ sysdeps/nios2/dl-sysdep.h | 23 + sysdeps/nios2/dl-tls.h | 48 + sysdeps/nios2/dl-trampoline.S | 79 + sysdeps/nios2/gccframe.h | 21 + sysdeps/nios2/gmp-mparam.h | 23 + sysdeps/nios2/jmpbuf-offsets.h | 48 + sysdeps/nios2/jmpbuf-unwind.h | 37 + sysdeps/nios2/ldsodefs.h | 43 + sysdeps/nios2/libc-tls.c | 32 + sysdeps/nios2/libm-test-ulps | 333 +++ sysdeps/nios2/machine-gmon.h | 64 + sysdeps/nios2/math-tests.h | 28 + sysdeps/nios2/math_private.h | 33 + sysdeps/nios2/memusage.h | 23 + sysdeps/nios2/nptl/Makefile | 22 + sysdeps/nios2/nptl/bits/pthreadtypes.h | 189 ++ sysdeps/nios2/nptl/bits/semaphore.h | 32 + sysdeps/nios2/nptl/pthread_spin_lock.c | 24 + sysdeps/nios2/nptl/pthreaddef.h | 32 + sysdeps/nios2/nptl/tcb-offsets.sym | 14 + sysdeps/nios2/nptl/tls.h | 174 ++ sysdeps/nios2/preconfigure | 6 + sysdeps/nios2/s_fma.c | 1 + sysdeps/nios2/s_fmaf.c | 1 + sysdeps/nios2/setjmp.S | 73 + sysdeps/nios2/sfp-machine.h | 51 + sysdeps/nios2/sotruss-lib.c | 51 + sysdeps/nios2/stackguard-macros.h | 6 + sysdeps/nios2/stackinfo.h | 33 + sysdeps/nios2/start.S | 146 ++ sysdeps/nios2/sysdep.h | 65 + sysdeps/nios2/tls-macros.h | 46 + sysdeps/nios2/tst-audit.h | 23 + sysdeps/unix/sysv/linux/nios2/Implies | 3 + sysdeps/unix/sysv/linux/nios2/Makefile | 13 + sysdeps/unix/sysv/linux/nios2/Versions | 6 + sysdeps/unix/sysv/linux/nios2/arch-fork.h | 33 + sysdeps/unix/sysv/linux/nios2/bits/atomic.h | 92 + sysdeps/unix/sysv/linux/nios2/bits/mman.h | 42 + sysdeps/unix/sysv/linux/nios2/c++-types.data | 67 + sysdeps/unix/sysv/linux/nios2/cacheflush.c | 29 + sysdeps/unix/sysv/linux/nios2/clone.S | 107 + sysdeps/unix/sysv/linux/nios2/configure | 4 + sysdeps/unix/sysv/linux/nios2/configure.ac | 4 + sysdeps/unix/sysv/linux/nios2/getcontext.S | 66 + sysdeps/unix/sysv/linux/nios2/kernel-features.h | 31 + sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h | 26 + sysdeps/unix/sysv/linux/nios2/ld.abilist | 12 + .../unix/sysv/linux/nios2/libBrokenLocale.abilist | 3 + sysdeps/unix/sysv/linux/nios2/libanl.abilist | 6 + sysdeps/unix/sysv/linux/nios2/libc.abilist | 2123 ++++++++++++++++++++ sysdeps/unix/sysv/linux/nios2/libcrypt.abilist | 9 + sysdeps/unix/sysv/linux/nios2/libdl.abilist | 11 + sysdeps/unix/sysv/linux/nios2/libm.abilist | 370 ++++ sysdeps/unix/sysv/linux/nios2/libnsl.abilist | 123 ++ sysdeps/unix/sysv/linux/nios2/libpthread.abilist | 224 +++ sysdeps/unix/sysv/linux/nios2/libresolv.abilist | 93 + sysdeps/unix/sysv/linux/nios2/librt.abilist | 37 + sysdeps/unix/sysv/linux/nios2/libthread_db.abilist | 42 + sysdeps/unix/sysv/linux/nios2/libutil.abilist | 8 + sysdeps/unix/sysv/linux/nios2/localplt.data | 35 + sysdeps/unix/sysv/linux/nios2/makecontext.c | 79 + sysdeps/unix/sysv/linux/nios2/profil-counter.h | 2 + sysdeps/unix/sysv/linux/nios2/setcontext.S | 103 + sysdeps/unix/sysv/linux/nios2/shlib-versions | 2 + sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h | 35 + sysdeps/unix/sysv/linux/nios2/swapcontext.S | 125 ++ sysdeps/unix/sysv/linux/nios2/sys/cachectl.h | 36 + sysdeps/unix/sysv/linux/nios2/sys/procfs.h | 123 ++ sysdeps/unix/sysv/linux/nios2/sys/ucontext.h | 48 + sysdeps/unix/sysv/linux/nios2/sys/user.h | 58 + sysdeps/unix/sysv/linux/nios2/syscall.S | 36 + sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 141 ++ sysdeps/unix/sysv/linux/nios2/sysdep.S | 50 + sysdeps/unix/sysv/linux/nios2/sysdep.h | 260 +++ sysdeps/unix/sysv/linux/nios2/ucontext_i.sym | 29 + sysdeps/unix/sysv/linux/nios2/vfork.S | 44 + 98 files changed, 7681 insertions(+) create mode 100644 sysdeps/nios2/Implies create mode 100644 sysdeps/nios2/Makefile create mode 100644 sysdeps/nios2/Subdirs create mode 100644 sysdeps/nios2/Versions create mode 100644 sysdeps/nios2/__longjmp.S create mode 100644 sysdeps/nios2/abort-instr.h create mode 100644 sysdeps/nios2/backtrace.c create mode 100644 sysdeps/nios2/bits/endian.h create mode 100644 sysdeps/nios2/bits/fenv.h create mode 100644 sysdeps/nios2/bits/link.h create mode 100644 sysdeps/nios2/bits/setjmp.h create mode 100644 sysdeps/nios2/bsd-_setjmp.S create mode 100644 sysdeps/nios2/bsd-setjmp.S create mode 100644 sysdeps/nios2/configure create mode 100644 sysdeps/nios2/configure.ac create mode 100644 sysdeps/nios2/crti.S create mode 100644 sysdeps/nios2/crtn.S create mode 100644 sysdeps/nios2/dl-init.c create mode 100644 sysdeps/nios2/dl-machine.h create mode 100644 sysdeps/nios2/dl-sysdep.h create mode 100644 sysdeps/nios2/dl-tls.h create mode 100644 sysdeps/nios2/dl-trampoline.S create mode 100644 sysdeps/nios2/gccframe.h create mode 100644 sysdeps/nios2/gmp-mparam.h create mode 100644 sysdeps/nios2/jmpbuf-offsets.h create mode 100644 sysdeps/nios2/jmpbuf-unwind.h create mode 100644 sysdeps/nios2/ldsodefs.h create mode 100644 sysdeps/nios2/libc-tls.c create mode 100644 sysdeps/nios2/libm-test-ulps create mode 100644 sysdeps/nios2/machine-gmon.h create mode 100644 sysdeps/nios2/math-tests.h create mode 100644 sysdeps/nios2/math_private.h create mode 100644 sysdeps/nios2/memusage.h create mode 100644 sysdeps/nios2/nptl/Makefile create mode 100644 sysdeps/nios2/nptl/bits/pthreadtypes.h create mode 100644 sysdeps/nios2/nptl/bits/semaphore.h create mode 100644 sysdeps/nios2/nptl/pthread_spin_lock.c create mode 100644 sysdeps/nios2/nptl/pthreaddef.h create mode 100644 sysdeps/nios2/nptl/tcb-offsets.sym create mode 100644 sysdeps/nios2/nptl/tls.h create mode 100644 sysdeps/nios2/preconfigure create mode 100644 sysdeps/nios2/s_fma.c create mode 100644 sysdeps/nios2/s_fmaf.c create mode 100644 sysdeps/nios2/setjmp.S create mode 100644 sysdeps/nios2/sfp-machine.h create mode 100644 sysdeps/nios2/sotruss-lib.c create mode 100644 sysdeps/nios2/stackguard-macros.h create mode 100644 sysdeps/nios2/stackinfo.h create mode 100644 sysdeps/nios2/start.S create mode 100644 sysdeps/nios2/sysdep.h create mode 100644 sysdeps/nios2/tls-macros.h create mode 100644 sysdeps/nios2/tst-audit.h create mode 100644 sysdeps/unix/sysv/linux/nios2/Implies create mode 100644 sysdeps/unix/sysv/linux/nios2/Makefile create mode 100644 sysdeps/unix/sysv/linux/nios2/Versions create mode 100644 sysdeps/unix/sysv/linux/nios2/arch-fork.h create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/atomic.h create mode 100644 sysdeps/unix/sysv/linux/nios2/bits/mman.h create mode 100644 sysdeps/unix/sysv/linux/nios2/c++-types.data create mode 100644 sysdeps/unix/sysv/linux/nios2/cacheflush.c create mode 100644 sysdeps/unix/sysv/linux/nios2/clone.S create mode 100644 sysdeps/unix/sysv/linux/nios2/configure create mode 100644 sysdeps/unix/sysv/linux/nios2/configure.ac create mode 100644 sysdeps/unix/sysv/linux/nios2/getcontext.S create mode 100644 sysdeps/unix/sysv/linux/nios2/kernel-features.h create mode 100644 sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h create mode 100644 sysdeps/unix/sysv/linux/nios2/ld.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libanl.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libc.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libcrypt.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libdl.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libm.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libnsl.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libpthread.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libresolv.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/librt.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libthread_db.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/libutil.abilist create mode 100644 sysdeps/unix/sysv/linux/nios2/localplt.data create mode 100644 sysdeps/unix/sysv/linux/nios2/makecontext.c create mode 100644 sysdeps/unix/sysv/linux/nios2/profil-counter.h create mode 100644 sysdeps/unix/sysv/linux/nios2/setcontext.S create mode 100644 sysdeps/unix/sysv/linux/nios2/shlib-versions create mode 100644 sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h create mode 100644 sysdeps/unix/sysv/linux/nios2/swapcontext.S create mode 100644 sysdeps/unix/sysv/linux/nios2/sys/cachectl.h create mode 100644 sysdeps/unix/sysv/linux/nios2/sys/procfs.h create mode 100644 sysdeps/unix/sysv/linux/nios2/sys/ucontext.h create mode 100644 sysdeps/unix/sysv/linux/nios2/sys/user.h create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall.S create mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h create mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.S create mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.h create mode 100644 sysdeps/unix/sysv/linux/nios2/ucontext_i.sym create mode 100644 sysdeps/unix/sysv/linux/nios2/vfork.S diff --git a/ChangeLog b/ChangeLog index d3b6b448ac..7392f2fb03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,107 @@ +2015-01-18 Chung-Lin Tang + Sandra Loosemore + Andrew Jenner + Joseph Myers + Nathan Sidwell + + * NEWS: Mention new Nios II port. + * sysdeps/nios2/Implies: New file. + * sysdeps/nios2/Makefile: New file. + * sysdeps/nios2/Subdirs: New file. + * sysdeps/nios2/Versions: New file. + * sysdeps/nios2/__longjmp.S: New file. + * sysdeps/nios2/abort-instr.h: New file. + * sysdeps/nios2/backtrace.c: New file. + * sysdeps/nios2/bits/endian.h: New file. + * sysdeps/nios2/bits/fenv.h: New file. + * sysdeps/nios2/bits/link.h: New file. + * sysdeps/nios2/bits/setjmp.h: New file. + * sysdeps/nios2/bsd-_setjmp.S: New file. + * sysdeps/nios2/bsd-setjmp.S: New file. + * sysdeps/nios2/configure: New generated file. + * sysdeps/nios2/configure.ac: New file. + * sysdeps/nios2/crti.S: New file. + * sysdeps/nios2/crtn.S: New file. + * sysdeps/nios2/dl-init.c: New file. + * sysdeps/nios2/dl-machine.h: New file. + * sysdeps/nios2/dl-sysdep.h: New file. + * sysdeps/nios2/dl-tls.h: New file. + * sysdeps/nios2/dl-trampoline.S: New file. + * sysdeps/nios2/gccframe.h: New file. + * sysdeps/nios2/gmp-mparam.h: New file. + * sysdeps/nios2/jmpbuf-offsets.h: New file. + * sysdeps/nios2/jmpbuf-unwind.h: New file. + * sysdeps/nios2/ldsodefs.h: New file. + * sysdeps/nios2/libc-tls.c: New file. + * sysdeps/nios2/libm-test-ulps: New file. + * sysdeps/nios2/machine-gmon.h: New file. + * sysdeps/nios2/math-tests.h: New file. + * sysdeps/nios2/math_private.h: New file. + * sysdeps/nios2/memusage.h: New file. + * sysdeps/nios2/nptl/Makefile: New file. + * sysdeps/nios2/nptl/bits/pthreadtypes.h: New file. + * sysdeps/nios2/nptl/bits/semaphore.h: New file. + * sysdeps/nios2/nptl/pthread_spin_lock.c: New file. + * sysdeps/nios2/nptl/pthreaddef.h: New file. + * sysdeps/nios2/nptl/tcb-offsets.sym: New file. + * sysdeps/nios2/nptl/tls.h: New file. + * sysdeps/nios2/preconfigure: New file. + * sysdeps/nios2/s_fma.c: New file. + * sysdeps/nios2/s_fmaf.c: New file. + * sysdeps/nios2/setjmp.S: New file. + * sysdeps/nios2/sfp-machine.h: New file. + * sysdeps/nios2/sotruss-lib.c: New file. + * sysdeps/nios2/stackguard-macros.h: New file. + * sysdeps/nios2/stackinfo.h: New file. + * sysdeps/nios2/start.S: New file. + * sysdeps/nios2/sysdep.h: New file. + * sysdeps/nios2/tls-macros.h: New file. + * sysdeps/nios2/tst-audit.h: New file. + * sysdeps/unix/sysv/linux/nios2/Implies: New file. + * sysdeps/unix/sysv/linux/nios2/Makefile: New file. + * sysdeps/unix/sysv/linux/nios2/Versions: New file. + * sysdeps/unix/sysv/linux/nios2/arch-fork.h: New file. + * sysdeps/unix/sysv/linux/nios2/bits/atomic.h: New file. + * sysdeps/unix/sysv/linux/nios2/bits/mman.h: New file. + * sysdeps/unix/sysv/linux/nios2/cacheflush.c: New file. + * sysdeps/unix/sysv/linux/nios2/clone.S: New file. + * sysdeps/unix/sysv/linux/nios2/configure: New generated file. + * sysdeps/unix/sysv/linux/nios2/configure.ac: New file. + * sysdeps/unix/sysv/linux/nios2/getcontext.S: New file. + * sysdeps/unix/sysv/linux/nios2/kernel-features.h: New file. + * sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h: New file. + * sysdeps/unix/sysv/linux/nios2/makecontext.c: New file. + * sysdeps/unix/sysv/linux/nios2/profil-counter.h: New file. + * sysdeps/unix/sysv/linux/nios2/setcontext.S: New file. + * sysdeps/unix/sysv/linux/nios2/shlib-versions: New file. + * sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h: New file. + * sysdeps/unix/sysv/linux/nios2/swapcontext.S: New file. + * sysdeps/unix/sysv/linux/nios2/sys/cachectl.h: New file. + * sysdeps/unix/sysv/linux/nios2/sys/procfs.h: New file. + * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: New file. + * sysdeps/unix/sysv/linux/nios2/sys/user.h: New file. + * sysdeps/unix/sysv/linux/nios2/syscall.S: New file. + * sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h: New file. + * sysdeps/unix/sysv/linux/nios2/sysdep.S: New file. + * sysdeps/unix/sysv/linux/nios2/sysdep.h: New file. + * sysdeps/unix/sysv/linux/nios2/ucontext_i.sym: New file. + * sysdeps/unix/sysv/linux/nios2/vfork.S: New file. + * sysdeps/unix/sysv/linux/nios2/c++-types.data: New file. + * sysdeps/unix/sysv/linux/nios2/ld.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libanl.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libc.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libcrypt.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libdl.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libm.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libnsl.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libpthread.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libresolv.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/librt.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libthread_db.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/libutil.abilist: New file. + * sysdeps/unix/sysv/linux/nios2/localplt.data: New file. + 2015-01-16 Stefan Liebler [BZ #17844] diff --git a/NEWS b/NEWS index 6fdb27db21..9086b7ed17 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,8 @@ Version 2.21 17744, 17745, 17746, 17747, 17748, 17775, 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, 17803, 17806, 17834, 17844, 17848 +* Port to Altera Nios II has been contributed by Mentor Graphics. + * Optimized strcpy, stpcpy, strncpy, stpncpy, strcmp, and strncmp implementations for powerpc64/powerpc64le. Implemented by Adhemerval Zanella (IBM). diff --git a/sysdeps/nios2/Implies b/sysdeps/nios2/Implies new file mode 100644 index 0000000000..387a0ca052 --- /dev/null +++ b/sysdeps/nios2/Implies @@ -0,0 +1,3 @@ +wordsize-32 +ieee754/dbl-64 +ieee754/flt-32 diff --git a/sysdeps/nios2/Makefile b/sysdeps/nios2/Makefile new file mode 100644 index 0000000000..e4e88dafc2 --- /dev/null +++ b/sysdeps/nios2/Makefile @@ -0,0 +1,35 @@ +# Copyright (C) 1993-2015 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, see +# . + +pic-ccflag = -fpic + +# We don't support long doubles as a distinct type. We don't need to set +# this variable; it's here mostly for documentational purposes. +long-double-fcts = no + +ifeq ($(subdir),soft-fp) +sysdep_routines += $(filter-out sqrtsf2,$(gcc-single-routines)) \ + $(filter-out sqrtdf2,$(gcc-double-routines)) +endif + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif + +ifeq ($(subdir),debug) +CFLAGS-backtrace.c += -funwind-tables +endif diff --git a/sysdeps/nios2/Subdirs b/sysdeps/nios2/Subdirs new file mode 100644 index 0000000000..87eadf3024 --- /dev/null +++ b/sysdeps/nios2/Subdirs @@ -0,0 +1 @@ +soft-fp diff --git a/sysdeps/nios2/Versions b/sysdeps/nios2/Versions new file mode 100644 index 0000000000..48a23519d9 --- /dev/null +++ b/sysdeps/nios2/Versions @@ -0,0 +1,12 @@ +libc { + GLIBC_2.21 { + __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2; + __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi; + __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi; + __floatdidf; __floatdisf; __floatsidf; __floatsisf; + __floatundidf; __floatundisf; __floatunsidf; __floatunsisf; + __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2; + __muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2; + __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2; + } +} diff --git a/sysdeps/nios2/__longjmp.S b/sysdeps/nios2/__longjmp.S new file mode 100644 index 0000000000..c5b7e1969e --- /dev/null +++ b/sysdeps/nios2/__longjmp.S @@ -0,0 +1,80 @@ +/* longjmp for Nios II. + Copyright (C) 2015 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, see + . */ + +#include +#include + +/* __longjmp(jmpbuf, val) */ + +ENTRY (__longjmp) + mov r2, r5 + bne r5, zero, 1f + movi r2, 1 +1: +#ifdef PTR_DEMANGLE + PTR_MANGLE_GUARD (r3) + ldw r5, (JB_RA*4)(r4) + ldw r6, (JB_SP*4)(r4) + PTR_DEMANGLE (r5, r5, r3) + PTR_DEMANGLE (r6, r6, r3) +#endif + + cfi_def_cfa (r4, 0) + cfi_offset (r16, JB_R16*4) + cfi_offset (r17, JB_R17*4) + cfi_offset (r18, JB_R18*4) + cfi_offset (r19, JB_R19*4) + cfi_offset (r20, JB_R20*4) + cfi_offset (r21, JB_R21*4) + cfi_offset (r22, JB_R22*4) + cfi_offset (fp, JB_FP*4) +#ifdef PTR_DEMANGLE + cfi_register (ra, r5) + cfi_register (sp, r7) +#else + cfi_offset (ra, JB_RA*4) + cfi_offset (sp, JB_SP*4) +#endif + ldw r16, (JB_R16*4)(r4) + ldw r17, (JB_R17*4)(r4) + ldw r18, (JB_R18*4)(r4) + ldw r19, (JB_R19*4)(r4) + ldw r20, (JB_R20*4)(r4) + ldw r21, (JB_R21*4)(r4) + ldw r22, (JB_R22*4)(r4) + ldw fp, (JB_FP*4)(r4) +#ifdef PTR_DEMANGLE + mov ra, r5 + mov sp, r6 +#else + ldw ra, (JB_RA*4)(r4) + ldw sp, (JB_SP*4)(r4) +#endif + cfi_same_value (r16) + cfi_same_value (r17) + cfi_same_value (r18) + cfi_same_value (r19) + cfi_same_value (r20) + cfi_same_value (r21) + cfi_same_value (r22) + cfi_same_value (fp) + cfi_same_value (ra) + cfi_same_value (sp) + + ret +END (__longjmp) diff --git a/sysdeps/nios2/abort-instr.h b/sysdeps/nios2/abort-instr.h new file mode 100644 index 0000000000..17502e4a70 --- /dev/null +++ b/sysdeps/nios2/abort-instr.h @@ -0,0 +1,2 @@ +/* An instruction which should crash any program is an unused trap. */ +#define ABORT_INSTRUCTION asm ("trap 31") diff --git a/sysdeps/nios2/backtrace.c b/sysdeps/nios2/backtrace.c new file mode 100644 index 0000000000..27ce597b39 --- /dev/null +++ b/sysdeps/nios2/backtrace.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/nios2/bits/endian.h b/sysdeps/nios2/bits/endian.h new file mode 100644 index 0000000000..164f9e4d78 --- /dev/null +++ b/sysdeps/nios2/bits/endian.h @@ -0,0 +1,12 @@ +/* The Nios II architecture has selectable endianness. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#ifdef __nios2_big_endian__ +# define __BYTE_ORDER __BIG_ENDIAN +#endif +#ifdef __nios2_little_endian__ +# define __BYTE_ORDER __LITTLE_ENDIAN +#endif diff --git a/sysdeps/nios2/bits/fenv.h b/sysdeps/nios2/bits/fenv.h new file mode 100644 index 0000000000..1eca40dabe --- /dev/null +++ b/sysdeps/nios2/bits/fenv.h @@ -0,0 +1,44 @@ +/* Copyright (C) 2012-2015 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, see + . */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + +/* The Altera specified Nios II hardware FPU does not support exceptions, + nor does the software floating-point support. */ +#define FE_ALL_EXCEPT 0 + +/* Nios II supports only round-to-nearest. The software + floating-point support also acts this way. */ +enum + { + __FE_UNDEFINED = 0, + + FE_TONEAREST = +#define FE_TONEAREST 1 + 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) diff --git a/sysdeps/nios2/bits/link.h b/sysdeps/nios2/bits/link.h new file mode 100644 index 0000000000..cd44add2da --- /dev/null +++ b/sysdeps/nios2/bits/link.h @@ -0,0 +1,54 @@ +/* Machine-specific declarations for dynamic linker interface, Nios II version. + Copyright (C) 2009-2015 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, see + . */ + +#ifndef _LINK_H +# error "Never include directly; use instead." +#endif + +/* Registers for entry into PLT on Nios II. */ +typedef struct La_nios2_regs +{ + uint32_t lr_reg[4]; /* r4 through r7 */ + uint32_t lr_ra; + uint32_t lr_sp; +} La_nios2_regs; + +/* Return values for calls from PLT on Nios II. */ +typedef struct La_nios2_retval +{ + uint32_t lrv_r2; + uint32_t lrv_r3; +} La_nios2_retval; + +__BEGIN_DECLS + +extern Elf32_Addr la_nios2_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_nios2_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_nios2_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_nios2_regs *__inregs, + La_nios2_retval *__outregs, + const char *symname); + +__END_DECLS diff --git a/sysdeps/nios2/bits/setjmp.h b/sysdeps/nios2/bits/setjmp.h new file mode 100644 index 0000000000..d9abeb5ac3 --- /dev/null +++ b/sysdeps/nios2/bits/setjmp.h @@ -0,0 +1,30 @@ +/* Define the machine-dependent type `jmp_buf'. Nios II version. + Copyright (C) 1992-2015 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, see + . */ + +#ifndef _NIOS2_BITS_SETJMP_H +#define _NIOS2_BITS_SETJMP_H 1 + +#if !defined(_SETJMP_H) && !defined(_PTHREAD_H) +# error "Never include directly; use instead." +#endif + +/* Saves r16-r22 (callee-saved, including GOT pointer), fp (frame pointer), + ra (return address), and sp (stack pointer). */ +typedef int __jmp_buf[10]; + +#endif /* _NIOS2_BITS_SETJMP_H */ diff --git a/sysdeps/nios2/bsd-_setjmp.S b/sysdeps/nios2/bsd-_setjmp.S new file mode 100644 index 0000000000..4e6a2da560 --- /dev/null +++ b/sysdeps/nios2/bsd-_setjmp.S @@ -0,0 +1 @@ +/* _setjmp is in setjmp.S */ diff --git a/sysdeps/nios2/bsd-setjmp.S b/sysdeps/nios2/bsd-setjmp.S new file mode 100644 index 0000000000..1da848d2f1 --- /dev/null +++ b/sysdeps/nios2/bsd-setjmp.S @@ -0,0 +1 @@ +/* setjmp is in setjmp.S */ diff --git a/sysdeps/nios2/configure b/sysdeps/nios2/configure new file mode 100644 index 0000000000..e820dc2509 --- /dev/null +++ b/sysdeps/nios2/configure @@ -0,0 +1,162 @@ +# This file is generated from configure.ac by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/nios2. + +# Nios II big endian is not yet supported. + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for big endian" >&5 +$as_echo_n "checking for big endian... " >&6; } +if ${libc_cv_nios2_be+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __nios2_big_endian__ + yes + #endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + libc_cv_nios2_be=yes +else + libc_cv_nios2_be=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_nios2_be" >&5 +$as_echo "$libc_cv_nios2_be" >&6; } +if test $libc_cv_nios2_be = yes; then + as_fn_error $? "Big endian not supported for Nios II" "$LINENO" 5 +fi diff --git a/sysdeps/nios2/configure.ac b/sysdeps/nios2/configure.ac new file mode 100644 index 0000000000..f05f43802b --- /dev/null +++ b/sysdeps/nios2/configure.ac @@ -0,0 +1,13 @@ +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/nios2. + +# Nios II big endian is not yet supported. +AC_CACHE_CHECK([for big endian], + [libc_cv_nios2_be], + [AC_EGREP_CPP(yes,[#ifdef __nios2_big_endian__ + yes + #endif + ], libc_cv_nios2_be=yes, libc_cv_nios2_be=no)]) +if test $libc_cv_nios2_be = yes; then + AC_MSG_ERROR([Big endian not supported for Nios II]) +fi diff --git a/sysdeps/nios2/crti.S b/sysdeps/nios2/crti.S new file mode 100644 index 0000000000..022d991786 --- /dev/null +++ b/sysdeps/nios2/crti.S @@ -0,0 +1,96 @@ +/* Special .init and .fini section support for Nios II. + Copyright (C) 2012-2015 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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, see + . */ + +/* crti.S puts a function prologue at the beginning of the .init and + .fini sections and defines global symbols for those addresses, so + they can be called as functions. The symbols _init and _fini are + magic and cause the linker to emit DT_INIT and DT_FINI. */ + +#include + +#ifndef PREINIT_FUNCTION +# define PREINIT_FUNCTION __gmon_start__ +#endif + +#ifndef PREINIT_FUNCTION_WEAK +# define PREINIT_FUNCTION_WEAK 1 +#endif + +#if PREINIT_FUNCTION_WEAK + weak_extern (PREINIT_FUNCTION) +#else + .hidden PREINIT_FUNCTION +#endif + + .section .init,"ax",@progbits + .align 2 + .global _init + .type _init, @function +_init: + addi sp, sp, -8 + stw r22, 0(sp) + nextpc r22 + 1: + movhi r8, %hiadj(_gp_got - 1b) + addi r8, r8, %lo(_gp_got - 1b) + add r22, r22, r8 + stw ra, 4(sp) +#if PREINIT_FUNCTION_WEAK + movhi r2, %got_hiadj(PREINIT_FUNCTION) + addi r2, r2, %got_lo(PREINIT_FUNCTION) + add r2, r2, r22 + ldw r2, 0(r2) + beq r2, zero, .L5 +#endif + movhi r2, %call_hiadj(PREINIT_FUNCTION) + addi r2, r2, %call_lo(PREINIT_FUNCTION) + add r2, r2, r22 + ldw r2, 0(r2) + callr r2 +.L5: + + .section .fini,"ax",@progbits + .align 2 + .global _fini + .type _fini, @function +_fini: + addi sp, sp, -8 + stw r22, 0(sp) + nextpc r22 + 1: + movhi r8, %hiadj(_gp_got - 1b) + addi r8, r8, %lo(_gp_got - 1b) + stw ra, 4(sp) + add r22, r22, r8 diff --git a/sysdeps/nios2/crtn.S b/sysdeps/nios2/crtn.S new file mode 100644 index 0000000000..d348f21867 --- /dev/null +++ b/sysdeps/nios2/crtn.S @@ -0,0 +1,49 @@ +/* Special .init and .fini section support for Nios II. + Copyright (C) 2012-2015 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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, see + . */ + +/* crtn.S puts function epilogues in the .init and .fini sections + corresponding to the prologues in crti.S. */ + + .section .init,"ax",@progbits + ldw ra, 4(sp) + ldw r22, 0(sp) + addi sp, sp, 8 + ret + + .section .fini,"ax",@progbits + ldw ra, 4(sp) + ldw r22, 0(sp) + addi sp, sp, 8 + ret diff --git a/sysdeps/nios2/dl-init.c b/sysdeps/nios2/dl-init.c new file mode 100644 index 0000000000..1dae3621a3 --- /dev/null +++ b/sysdeps/nios2/dl-init.c @@ -0,0 +1,30 @@ +/* Nios II specific procedures for initializing code. + Copyright (C) 2008-2015 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, see + . */ + +#include + +unsigned int +internal_function +_dl_nios2_get_gp_value (struct link_map *main_map) +{ + ElfW(Dyn) *dyn = main_map->l_ld; + for (dyn = main_map->l_ld; dyn->d_tag != DT_NULL; ++dyn) + if (dyn->d_tag == DT_NIOS2_GP) + return (unsigned int)(dyn->d_un.d_ptr); + return 0; +} diff --git a/sysdeps/nios2/dl-machine.h b/sysdeps/nios2/dl-machine.h new file mode 100644 index 0000000000..3efb0d7325 --- /dev/null +++ b/sysdeps/nios2/dl-machine.h @@ -0,0 +1,335 @@ +/* Machine-dependent ELF dynamic relocation inline functions. Nios II version. + Copyright (C) 1995-2015 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, see + . */ + +#ifndef dl_machine_h +#define dl_machine_h + +#define ELF_MACHINE_NAME "nios2" + +#include +#include +#include + +/* Return nonzero iff ELF header is compatible with the running host. */ +static inline int +elf_machine_matches_host (const Elf32_Ehdr *ehdr) +{ + return ehdr->e_machine == EM_ALTERA_NIOS2; +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. */ +static inline Elf32_Addr +elf_machine_dynamic (void) +{ + Elf32_Addr *dynamic; + int tmp; + asm ("nextpc\t%0\n\t" + "1: movhi\t%1, %%hiadj(_GLOBAL_OFFSET_TABLE_ - 1b)\n\t" + "addi\t%1, %1, %%lo(_GLOBAL_OFFSET_TABLE_ - 1b)\n\t" + "add\t%0, %0, %1\n" + : "=r" (dynamic), "=r" (tmp)); + return *dynamic; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr +elf_machine_load_address (void) +{ + Elf32_Addr result; + int tmp; + asm ("nextpc\t%0\n\t" + "1: movhi\t%1, %%hiadj(1b)\n\t" + "addi\t%1, %1, %%lo(1b)\n\t" + "sub\t%0, %0, %1\n" + : "=r" (result), "=r" (tmp)); + return result; +} + +/* 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__ ((always_inline)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + extern void _dl_runtime_resolve (Elf32_Word); + + 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 load r15 with + an offset into the .got section, load r14 with + _GLOBAL_OFFSET_TABLE_[1], and then jump to _GLOBAL_OFFSET_TABLE[2]. + */ + Elf32_Addr *got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* 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; +} + +/* 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 ("\ +.text\n\ +.globl _start\n\ +.type _start, %function\n\ +_start:\n\ + /* At start time, all the args are on the stack. */\n\ + mov r4, sp\n\ +\n\ + /* Start the calculation of the GOT pointer. */\n\ + nextpc r22\n\ +1: movhi r8, %hiadj(_gp_got - 1b)\n\ + addi r8, r8, %lo(_gp_got - 1b)\n\ +\n\ + /* Figure out where _dl_start will need to return to. */\n\ + movhi ra, %hiadj(2f - 1b)\n\ + addi ra, ra, %lo(2f - 1b)\n\ + add ra, ra, r22\n\ +\n\ + /* Finish the calculation of the GOT pointer. */\n\ + add r22, r22, r8\n\ +\n\ + br _dl_start\n\ +\n\ + /* Save the returned user entry point. */\n\ +2: mov r16, r2\n\ +\n\ + /* Initialize gp. */\n\ + ldw r4, %got(_rtld_local)(r22)\n\ + ldw r4, 0(r4)\n\ + ldw r8, %call(_dl_nios2_get_gp_value)(r22)\n\ + callr r8\n\ + mov gp, r2\n\ +\n\ + /* Find the number of arguments to skip. */\n\ + ldw r8, %got(_dl_skip_args)(r22)\n\ + ldw r8, 0(r8)\n\ +\n\ + /* Find the main_map from the GOT. */\n\ + ldw r4, %got(_rtld_local)(r22)\n\ + ldw r4, 0(r4)\n\ +\n\ + /* Find argc. */\n\ + ldw r5, 0(sp)\n\ + sub r5, r5, r8\n\ + stw r5, 0(sp)\n\ +\n\ + /* Find the first unskipped argument. */\n\ + slli r8, r8, 2\n\ + addi r6, sp, 4\n\ + add r9, r6, r8\n\ + mov r10, r6\n\ +\n\ + /* Shuffle argv down. */\n\ +3: ldw r11, 0(r9)\n\ + stw r11, 0(r10)\n\ + addi r9, r9, 4\n\ + addi r10, r10, 4\n\ + bne r11, zero, 3b\n\ +\n\ + /* Shuffle envp down. */\n\ + mov r7, r10\n\ +4: ldw r11, 0(r9)\n\ + stw r11, 0(r10)\n\ + addi r9, r9, 4\n\ + addi r10, r10, 4\n\ + bne r11, zero, 4b\n\ +\n\ + /* Shuffle auxv down. */\n\ +5: ldw r11, 4(r9)\n\ + stw r11, 4(r10)\n\ + ldw r11, 0(r9)\n\ + stw r11, 0(r10)\n\ + addi r9, r9, 8\n\ + addi r10, r10, 8\n\ + bne r11, zero, 5b\n\ +\n\ + /* Update _dl_argv. */\n\ + ldw r2, %got(_dl_argv)(r22)\n\ + stw r6, 0(r2)\n\ +\n\ + /* Call _dl_init through the PLT. */\n\ + ldw r8, %call(_dl_init)(r22)\n\ + callr r8\n\ +\n\ + /* Find the finalization function. */\n\ + ldw r4, %got(_dl_fini)(r22)\n\ +\n\ + /* Jump to the user's entry point. */\n\ + jmp r16\n\ +"); + +/* 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_NIOS2_JUMP_SLOT \ + || (type) == R_NIOS2_TLS_DTPMOD \ + || (type) == R_NIOS2_TLS_DTPREL \ + || (type) == R_NIOS2_TLS_TPREL) * ELF_RTYPE_CLASS_PLT) \ + | (((type) == R_NIOS2_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_NIOS2_JUMP_SLOT + +/* The Nios II never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 +#define ELF_MACHINE_NO_RELA 0 + +/* Fixup a PLT entry to bounce directly to the function at VALUE. */ + +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; +} + +/* Names of the architecture-specific auditing callback functions. */ +#define ARCH_LA_PLTENTER nios2_gnu_pltenter +#define ARCH_LA_PLTEXIT nios2_gnu_pltexit + +#endif /* dl_machine_h */ + +#ifdef RESOLVE_MAP + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + LOADADDR is the load address of the object; INFO is an array indexed + by DT_* of the .dynamic section info. */ + +auto inline void __attribute__ ((always_inline)) +elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc, + const ElfW(Sym) *sym, const struct r_found_version *version, + void *const reloc_addr_arg, int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + + if (__glibc_unlikely (r_type == R_NIOS2_RELATIVE)) + *reloc_addr = map->l_addr + reloc->r_addend; + else if (__glibc_unlikely (r_type == R_NIOS2_NONE)) + return; + else + { + const Elf32_Sym *const refsym = sym; + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; + + switch (r_type) + { + case R_NIOS2_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 + || (sym->st_size < refsym->st_size && GLRO(dl_verbose))) + { + 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", + rtld_progname ?: "", + strtab + refsym->st_name); + } + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); + break; + case R_NIOS2_GLOB_DAT: + case R_NIOS2_JUMP_SLOT: +# ifdef RTLD_BOOTSTRAP + /* Fix weak undefined references. */ + if (sym != NULL && sym->st_value == 0) + *reloc_addr = 0; + else +# endif + *reloc_addr = value; + break; +#ifndef RTLD_BOOTSTRAP + case R_NIOS2_TLS_DTPMOD: + /* Get the information from the link map returned by the + resolv function. */ + if (sym_map != NULL) + *reloc_addr = sym_map->l_tls_modid; + break; + + case R_NIOS2_TLS_DTPREL: + *reloc_addr = reloc->r_addend + TLS_DTPREL_VALUE(sym); + break; + + case R_NIOS2_TLS_TPREL: + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = reloc->r_addend + TLS_TPREL_VALUE(sym_map, sym); + } + break; +#endif + case R_NIOS2_BFD_RELOC_32: + *reloc_addr = value + reloc->r_addend; + break; + + default: + _dl_reloc_bad_type (map, r_type, 0); + break; + } + } +} + +auto inline void __attribute__((always_inline)) +elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc, + void *const reloc_addr_arg) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + *reloc_addr = l_addr + reloc->r_addend; +} + +auto inline void __attribute__((always_inline)) +elf_machine_lazy_rel (struct link_map *map, + ElfW(Addr) l_addr, const ElfW(Rela) *reloc, + int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + if (ELF32_R_TYPE (reloc->r_info) == R_NIOS2_JUMP_SLOT) + *reloc_addr += l_addr; + else + _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); +} + +#endif /* RESOLVE_MAP */ diff --git a/sysdeps/nios2/dl-sysdep.h b/sysdeps/nios2/dl-sysdep.h new file mode 100644 index 0000000000..4f49c2d2ff --- /dev/null +++ b/sysdeps/nios2/dl-sysdep.h @@ -0,0 +1,23 @@ +/* System-specific settings for dynamic linker code. Nios II version. + Copyright (C) 2009-2015 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, see + . */ + +#include_next + +/* _dl_argv cannot be attribute_relro, because _dl_start_user + might write into it after _dl_start returns. */ +#define DL_ARGV_NOT_RELRO 1 diff --git a/sysdeps/nios2/dl-tls.h b/sysdeps/nios2/dl-tls.h new file mode 100644 index 0000000000..541e4b012e --- /dev/null +++ b/sysdeps/nios2/dl-tls.h @@ -0,0 +1,48 @@ +/* Thread-local storage handling in the ELF dynamic linker. Nios II version. + Copyright (C) 2012-2015 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, see + . */ + + +/* Type used for the representation of TLS information in the GOT. */ +typedef struct +{ + unsigned long int ti_module; + unsigned long int ti_offset; +} tls_index; + +/* The thread pointer points 0x7000 past the first static TLS block. */ +#define TLS_TP_OFFSET 0x7000 + +/* Dynamic thread vector pointers point 0x8000 past the start of each + TLS block. */ +#define TLS_DTV_OFFSET 0x8000 + +/* Compute the value for a GOTTPREL reloc. */ +#define TLS_TPREL_VALUE(sym_map, sym) \ + ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET) + +/* Compute the value for a DTPREL reloc. */ +#define TLS_DTPREL_VALUE(sym) \ + ((sym)->st_value - TLS_DTV_OFFSET) + +extern void *__tls_get_addr (tls_index *ti); + +# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET) +# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET) + +/* Value used for dtv entries for which the allocation is delayed. */ +#define TLS_DTV_UNALLOCATED ((void *) -1l) diff --git a/sysdeps/nios2/dl-trampoline.S b/sysdeps/nios2/dl-trampoline.S new file mode 100644 index 0000000000..e4a3f7060f --- /dev/null +++ b/sysdeps/nios2/dl-trampoline.S @@ -0,0 +1,79 @@ +/* PLT trampolines. Nios II version. + Copyright (C) 2005-2015 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, see + . */ + +#include +#include + + .text + .globl _dl_runtime_resolve + cfi_startproc +_dl_runtime_resolve: +/* The runtime resolver receives the original function arguments in r4 + through r7, the shared library identifier from GOT[1]? in r14, and the + relocation index times four in r15. It updates the corresponding PLT GOT + entry so that the PLT entry will transfer control directly to the target + in the future, and then transfers control to the target. */ + /* Save arguments and return address. */ + subi sp, sp, 28 + cfi_adjust_cfa_offset (28) + stw r22, 24(sp) + cfi_rel_offset (r22, 24) + stw r8, 20(sp) /* save r8, because this might be a call to mcount */ + cfi_rel_offset (r8, 20) + stw r7, 16(sp) + cfi_rel_offset (r7, 16) + stw r6, 12(sp) + cfi_rel_offset (r6, 12) + stw r5, 8(sp) + cfi_rel_offset (r5, 8) + stw r4, 4(sp) + cfi_rel_offset (r4, 4) + stw ra, 0(sp) + cfi_rel_offset (ra, 0) + + /* Get pointer to linker struct. */ + mov r4, r14 + + /* Get the relocation offset. We're given a multiple of 4 and + need a multiple of 12, so multiply by 3. */ + slli r5, r15, 1 + add r5, r5, r15 + + /* Call the fixup routine. */ + nextpc r22 +1: movhi r2, %hiadj(_gp_got - 1b) + addi r2, r2, %lo(_gp_got - 1b) + add r22, r22, r2 + ldw r2, %call(_dl_fixup)(r22) + callr r2 + + /* Restore the arguments and return address. */ + ldw ra, 0(sp) + ldw r4, 4(sp) + ldw r5, 8(sp) + ldw r6, 12(sp) + ldw r7, 16(sp) + ldw r8, 20(sp) + ldw r22, 24(sp) + addi sp, sp, 28 + cfi_adjust_cfa_offset (-28) + + /* Jump to the newly found address. */ + jmp r2 + + cfi_endproc diff --git a/sysdeps/nios2/gccframe.h b/sysdeps/nios2/gccframe.h new file mode 100644 index 0000000000..731a269e3b --- /dev/null +++ b/sysdeps/nios2/gccframe.h @@ -0,0 +1,21 @@ +/* Definition of object in frame unwind info. Nios II version. + Copyright (C) 2015 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, see + . */ + +#define FIRST_PSEUDO_REGISTER 40 + +#include diff --git a/sysdeps/nios2/gmp-mparam.h b/sysdeps/nios2/gmp-mparam.h new file mode 100644 index 0000000000..67d25d342c --- /dev/null +++ b/sysdeps/nios2/gmp-mparam.h @@ -0,0 +1,23 @@ +/* gmp-mparam.h -- Compiler/machine parameter header file. + +Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB. If not, see +. */ + +#include + +#define IEEE_DOUBLE_BIG_ENDIAN 0 diff --git a/sysdeps/nios2/jmpbuf-offsets.h b/sysdeps/nios2/jmpbuf-offsets.h new file mode 100644 index 0000000000..7bbdcb6db8 --- /dev/null +++ b/sysdeps/nios2/jmpbuf-offsets.h @@ -0,0 +1,48 @@ +/* Private macros for accessing __jmp_buf contents. Nios II version. + Copyright (C) 2006-2015 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, see + . */ + +/* Save offsets within __jmp_buf. */ +#define JB_R16 0 +#define JB_R17 1 +#define JB_R18 2 +#define JB_R19 3 +#define JB_R20 4 +#define JB_R21 5 +#define JB_R22 6 +#define JB_FP 7 +#define JB_RA 8 +#define JB_SP 9 + +#ifndef __ASSEMBLER__ +#include +#include +#include + +static inline uintptr_t __attribute__ ((unused)) +_jmpbuf_sp (__jmp_buf jmpbuf) +{ + uintptr_t sp = jmpbuf[JB_SP]; +#ifdef PTR_DEMANGLE + PTR_DEMANGLE (sp); +#endif + return sp; +} +#endif + +/* Helper for generic ____longjmp_chk(). */ +#define JB_FRAME_ADDRESS(buf) ((void *) _jmpbuf_sp (buf)) diff --git a/sysdeps/nios2/jmpbuf-unwind.h b/sysdeps/nios2/jmpbuf-unwind.h new file mode 100644 index 0000000000..bf7a22be3b --- /dev/null +++ b/sysdeps/nios2/jmpbuf-unwind.h @@ -0,0 +1,37 @@ +/* Examine __jmp_buf for unwinding frames. Nios II version. + Copyright (C) 2005-2015 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, see + . */ + +#include +#include +#include +#include + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ + +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \ + ((void *) (address) < (void *) demangle (jmpbuf[JB_SP])) + +#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \ + _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj) + +#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \ + ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf_sp (_jmpbuf) - (_adj))) + +/* We use the normal longjmp for unwinding. */ +#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val) diff --git a/sysdeps/nios2/ldsodefs.h b/sysdeps/nios2/ldsodefs.h new file mode 100644 index 0000000000..629dbb64de --- /dev/null +++ b/sysdeps/nios2/ldsodefs.h @@ -0,0 +1,43 @@ +/* Run-time dynamic linker data structures for loaded ELF shared objects. + Copyright (C) 2000-2015 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 t