summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2015-01-17 22:29:12 -0800
committerChung-Lin Tang <cltang@codesourcery.com>2015-01-17 22:29:12 -0800
commit522e6ee3b45808ea845ec0ac11d5fffcd737baba (patch)
tree3d107705431599279416406a487cd8a905a372af
parent026eb207eda8cc93f6f7f0980f0a8e51587d8011 (diff)
Commit nios2 port to master.
-rw-r--r--ChangeLog104
-rw-r--r--NEWS2
-rw-r--r--sysdeps/nios2/Implies3
-rw-r--r--sysdeps/nios2/Makefile35
-rw-r--r--sysdeps/nios2/Subdirs1
-rw-r--r--sysdeps/nios2/Versions12
-rw-r--r--sysdeps/nios2/__longjmp.S80
-rw-r--r--sysdeps/nios2/abort-instr.h2
-rw-r--r--sysdeps/nios2/backtrace.c1
-rw-r--r--sysdeps/nios2/bits/endian.h12
-rw-r--r--sysdeps/nios2/bits/fenv.h44
-rw-r--r--sysdeps/nios2/bits/link.h54
-rw-r--r--sysdeps/nios2/bits/setjmp.h30
-rw-r--r--sysdeps/nios2/bsd-_setjmp.S1
-rw-r--r--sysdeps/nios2/bsd-setjmp.S1
-rw-r--r--sysdeps/nios2/configure162
-rw-r--r--sysdeps/nios2/configure.ac13
-rw-r--r--sysdeps/nios2/crti.S96
-rw-r--r--sysdeps/nios2/crtn.S49
-rw-r--r--sysdeps/nios2/dl-init.c30
-rw-r--r--sysdeps/nios2/dl-machine.h335
-rw-r--r--sysdeps/nios2/dl-sysdep.h23
-rw-r--r--sysdeps/nios2/dl-tls.h48
-rw-r--r--sysdeps/nios2/dl-trampoline.S79
-rw-r--r--sysdeps/nios2/gccframe.h21
-rw-r--r--sysdeps/nios2/gmp-mparam.h23
-rw-r--r--sysdeps/nios2/jmpbuf-offsets.h48
-rw-r--r--sysdeps/nios2/jmpbuf-unwind.h37
-rw-r--r--sysdeps/nios2/ldsodefs.h43
-rw-r--r--sysdeps/nios2/libc-tls.c32
-rw-r--r--sysdeps/nios2/libm-test-ulps333
-rw-r--r--sysdeps/nios2/machine-gmon.h64
-rw-r--r--sysdeps/nios2/math-tests.h28
-rw-r--r--sysdeps/nios2/math_private.h33
-rw-r--r--sysdeps/nios2/memusage.h23
-rw-r--r--sysdeps/nios2/nptl/Makefile22
-rw-r--r--sysdeps/nios2/nptl/bits/pthreadtypes.h189
-rw-r--r--sysdeps/nios2/nptl/bits/semaphore.h32
-rw-r--r--sysdeps/nios2/nptl/pthread_spin_lock.c24
-rw-r--r--sysdeps/nios2/nptl/pthreaddef.h32
-rw-r--r--sysdeps/nios2/nptl/tcb-offsets.sym14
-rw-r--r--sysdeps/nios2/nptl/tls.h174
-rw-r--r--sysdeps/nios2/preconfigure6
-rw-r--r--sysdeps/nios2/s_fma.c1
-rw-r--r--sysdeps/nios2/s_fmaf.c1
-rw-r--r--sysdeps/nios2/setjmp.S73
-rw-r--r--sysdeps/nios2/sfp-machine.h51
-rw-r--r--sysdeps/nios2/sotruss-lib.c51
-rw-r--r--sysdeps/nios2/stackguard-macros.h6
-rw-r--r--sysdeps/nios2/stackinfo.h33
-rw-r--r--sysdeps/nios2/start.S146
-rw-r--r--sysdeps/nios2/sysdep.h65
-rw-r--r--sysdeps/nios2/tls-macros.h46
-rw-r--r--sysdeps/nios2/tst-audit.h23
-rw-r--r--sysdeps/unix/sysv/linux/nios2/Implies3
-rw-r--r--sysdeps/unix/sysv/linux/nios2/Makefile13
-rw-r--r--sysdeps/unix/sysv/linux/nios2/Versions6
-rw-r--r--sysdeps/unix/sysv/linux/nios2/arch-fork.h33
-rw-r--r--sysdeps/unix/sysv/linux/nios2/bits/atomic.h92
-rw-r--r--sysdeps/unix/sysv/linux/nios2/bits/mman.h42
-rw-r--r--sysdeps/unix/sysv/linux/nios2/c++-types.data67
-rw-r--r--sysdeps/unix/sysv/linux/nios2/cacheflush.c29
-rw-r--r--sysdeps/unix/sysv/linux/nios2/clone.S107
-rw-r--r--sysdeps/unix/sysv/linux/nios2/configure4
-rw-r--r--sysdeps/unix/sysv/linux/nios2/configure.ac4
-rw-r--r--sysdeps/unix/sysv/linux/nios2/getcontext.S66
-rw-r--r--sysdeps/unix/sysv/linux/nios2/kernel-features.h31
-rw-r--r--sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h26
-rw-r--r--sysdeps/unix/sysv/linux/nios2/ld.abilist12
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libanl.abilist6
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libc.abilist2123
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libcrypt.abilist9
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libdl.abilist11
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libm.abilist370
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libnsl.abilist123
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libpthread.abilist224
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libresolv.abilist93
-rw-r--r--sysdeps/unix/sysv/linux/nios2/librt.abilist37
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libthread_db.abilist42
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libutil.abilist8
-rw-r--r--sysdeps/unix/sysv/linux/nios2/localplt.data35
-rw-r--r--sysdeps/unix/sysv/linux/nios2/makecontext.c79
-rw-r--r--sysdeps/unix/sysv/linux/nios2/profil-counter.h2
-rw-r--r--sysdeps/unix/sysv/linux/nios2/setcontext.S103
-rw-r--r--sysdeps/unix/sysv/linux/nios2/shlib-versions2
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h35
-rw-r--r--sysdeps/unix/sysv/linux/nios2/swapcontext.S125
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sys/cachectl.h36
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sys/procfs.h123
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sys/ucontext.h48
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sys/user.h58
-rw-r--r--sysdeps/unix/sysv/linux/nios2/syscall.S36
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h141
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sysdep.S50
-rw-r--r--sysdeps/unix/sysv/linux/nios2/sysdep.h260
-rw-r--r--sysdeps/unix/sysv/linux/nios2/ucontext_i.sym29
-rw-r--r--sysdeps/unix/sysv/linux/nios2/vfork.S44
98 files changed, 7681 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d3b6b448ac..7392f2fb03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,107 @@
+2015-01-18 Chung-Lin Tang <cltang@codesourcery.com>
+ Sandra Loosemore <sandra@codesourcery.com>
+ Andrew Jenner <andrew@codesourcery.com>
+ Joseph Myers <joseph@codesourcery.com>
+ Nathan Sidwell <nathan@codesourcery.com>
+
+ * 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 <stli@linux.vnet.ibm.com>
[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
+# <http://www.gnu.org/licenses/>.
+
+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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <jmpbuf-offsets.h>
+
+/* __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 <sysdeps/x86_64/backtrace.c>
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 <bits/endian.h> directly; include <endian.h> 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NIOS2_BITS_SETJMP_H
+#define _NIOS2_BITS_SETJMP_H 1
+
+#if !defined(_SETJMP_H) && !defined(_PTHREAD_H)
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> 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
+ <http://www.gnu.org/licenses/>. */
+
+/* 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 <libc-symbols.h>
+
+#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
+ <http://www.gnu.org/licenses/>. */
+
+/* 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <elf/dl-init.c>
+
+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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "nios2"
+
+#include <string.h>
+#include <link.h>
+#include <dl-tls.h>
+
+/* 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 ?: "<program name unknown>",
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include_next <dl-sysdep.h>
+
+/* _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
+ <http://www.gnu.org/licenses/>. */
+
+
+/* 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <libc-symbols.h>
+
+ .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
+ <http://www.gnu.org/licenses/>. */
+
+#define FIRST_PSEUDO_REGISTER 40
+
+#include <sysdeps/generic/gccframe.h>
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
+<http://www.gnu.org/licenses/>. */
+
+#include <sysdeps/generic/gmp-mparam.h>
+
+#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
+ <http://www.gnu.org/licenses/>. */
+
+/* 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 <setjmp.h>
+#include <stdint.h>
+#include <sysdep.h>
+
+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
+ <http://www.gnu.org/licenses/>. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+#include <stdint.h>
+#include <unwind.h>
+
+/* 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 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NIOS2_LDSODEFS_H
+#define _NIOS2_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_nios2_regs;
+struct La_nios2_retval;
+
+#define ARCH_PLTENTER_MEMBERS \
+ ElfW(Addr) (*nios2_gnu_pltenter) (ElfW(Sym) *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_nios2_regs *, \
+ unsigned int *, const char *, \
+ long int *);
+
+#define ARCH_PLTEXIT_MEMBERS \
+ unsigned int (*nios2_gnu_pltexit) (ElfW(Sym) *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_nios2_regs *, \
+ struct La_nios2_retval *, \
+ const char *);
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/sysdeps/nios2/libc-tls.c b/sysdeps/nios2/libc-tls.c
new file mode 100644
index 0000000000..de2d0df13f
--- /dev/null
+++ b/sysdeps/nios2/libc-tls.c
@@ -0,0 +1,32 @@
+/* Thread-local storage handling in the ELF dynamic linker. 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+/* On Nios II, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET;
+}
diff --git a/sysdeps/nios2/libm-test-ulps b/sysdeps/nios2/libm-test-ulps
new file mode 100644
index 0000000000..0806905370
--- /dev/null
+++ b/sysdeps/nios2/libm-test-ulps
@@ -0,0 +1,333 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acosh":
+double: 1
+idouble: 1
+
+Function: "asinh":
+double: 1
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casinh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catan":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+float: 1
+ifloat: 1
+
+Function: "cbrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "clog":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog10":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cos":
+float: 1
+ifloat: 1
+
+Function: "cosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+float: 2
+ifloat: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "ctanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp10":
+double: 1
+idouble: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+double: 1
+idouble: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "pow":
+float: 1
+ifloat: 1
+
+Function: "pow10":
+double: 1
+idouble: 1
+
+Function: "sin":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+float: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/sysdeps/nios2/machine-gmon.h b/sysdeps/nios2/machine-gmon.h
new file mode 100644
index 0000000000..1f0ea8ff70
--- /dev/null
+++ b/sysdeps/nios2/machine-gmon.h
@@ -0,0 +1,64 @@
+/* Machine-dependent definitions for profiling support. Nios II version.
+ Copyright (C) 1996-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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+static void __attribute_used__ __mcount_internal (u_long frompc, u_long selfpc)
+
+/* This macro/func MUST save r4, r5, r6, r7 and r8 because the compiler inserts
+ blind calls to mcount(), ignoring the fact that mcount may clobber
+ registers; therefore, mcount may NOT clobber registers. */
+
+#if defined(__PIC__) || defined(PIC)
+#define NIOS2_MCOUNT_CALL \
+ "nextpc r3\n\t" \
+ "1: movhi r2, %hiadj(_gp_got - 1b)\n\t" \
+ "addi r2, r2, %lo(_gp_got - 1b)\n\t" \
+ "add r2, r2, r3\n\t" \
+ "ldw r2, %call(__mcount_internal)(r2)\n\t" \
+ "callr r2\n\t"
+#else
+#define NIOS2_MCOUNT_CALL \
+ "call\tmcount_internal\n\t"
+#endif
+
+#define MCOUNT \
+ asm (".globl _mcount\n\t" \
+ ".type _mcount,@function\n\t" \
+ "_mcount:\n\t" \
+ "subi sp, sp, 24\n\t" \
+ "stw ra, 20(sp)\n\t" \
+ "stw r8, 16(sp)\n\t" \
+ "stw r7, 12(sp)\n\t" \
+ "stw r6, 8(sp)\n\t" \
+ "stw r5, 4(sp)\n\t" \
+ "stw r4, 0(sp)\n\t" \
+ "mov r4, r8\n\t" \
+ "mov r5, ra\n\t" \
+ NIOS2_MCOUNT_CALL \
+ "ldw ra, 20(sp)\n\t" \
+ "ldw r8, 16(sp)\n\t" \
+ "ldw r7, 12(sp)\n\t" \
+ "ldw r6, 8(sp)\n\t" \
+ "ldw r5, 4(sp)\n\t" \
+ "ldw r4, 0(sp)\n\t" \
+ "addi sp, sp, 24\n\t" \
+ "ret\n\t" \
+ ".size _mcount, . - _mcount\n\t" \
+ );
diff --git a/sysdeps/nios2/math-tests.h b/sysdeps/nios2/math-tests.h
new file mode 100644
index 0000000000..5771140f87
--- /dev/null
+++ b/sysdeps/nios2/math-tests.h
@@ -0,0 +1,28 @@
+/* Configuration for math tests. 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
+ <http://www.gnu.org/licenses/>. */
+
+/* Current Nios II soft-float does not support exceptions or rounding
+ modes. */
+#define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST)
+#define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST)
+#define ROUNDING_TESTS_long_double(MODE) ((MODE) == FE_TONEAREST)
+#define EXCEPTION_TESTS_float 0
+#define EXCEPTION_TESTS_double 0
+#define EXCEPTION_TESTS_long_double 0
+
+#include_next <math-tests.h>
diff --git a/sysdeps/nios2/math_private.h b/sysdeps/nios2/math_private.h
new file mode 100644
index 0000000000..a89db448dd
--- /dev/null
+++ b/sysdeps/nios2/math_private.h
@@ -0,0 +1,33 @@
+#ifndef _MATH_PRIVATE_H
+
+/* Suppress use of exceptions here to avoid build errors if the FE_*
+ macros aren't defined. Only allow rounding modes implemented for Nios II.
+
+ This does mean that some code will silently fail to report exceptions,
+ set rounding mode as expected, etc., but it allows math code to compile
+ that otherwise wouldn't (such as math/s_fma.c) and so is valuable.
+
+ We intentionally ignore the "exception" arguments of functions that
+ take an exception, since we can't even evaluate the argument
+ without causing a build failure. The extra level of statement
+ expression wrapping avoids "statement with no effect" warnings.
+ Since the callers don't check for errors anyway, we just claim
+ success in every case.
+
+ The overrides for libc_ functions must happen before we include
+ the generic math_private.h, and the overrides for regular
+ <fenv.h> functions must happen afterwards, to avoid clashing with
+ the declarations of those functions. */
+
+#define libc_fesetround(rnd) ({ 0; })
+#define libc_fetestexcept(exc) ({ 0; })
+#define libc_feholdexcept_setround(env, exc) ({ (void) (env); 0; })
+#define libc_feupdateenv_test(env, exc) ({ (void) (env); 0; })
+
+#include_next <math_private.h>
+
+#define feraiseexcept(excepts) ({ 0; })
+#define __feraiseexcept(excepts) ({ 0; })
+#define feclearexcept(exc) ({ 0; })
+
+#endif
diff --git a/sysdeps/nios2/memusage.h b/sysdeps/nios2/memusage.h
new file mode 100644
index 0000000000..10fb7cd17e
--- /dev/null
+++ b/sysdeps/nios2/memusage.h
@@ -0,0 +1,23 @@
+/* Machine-specific definitions for memory usage profiling, Nios II version.
+ 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 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
+ <http://www.gnu.org/licenses/>. */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
+
+#define uatomic32_t unsigned int
+
+#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/nios2/nptl/Makefile b/sysdeps/nios2/nptl/Makefile
new file mode 100644
index 0000000000..6e0dd85232
--- /dev/null
+++ b/sysdeps/nios2/nptl/Makefile
@@ -0,0 +1,22 @@
+# NPTL makefile fragment for Nios II.
+# 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
+# <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/sysdeps/nios2/nptl/bits/pthreadtypes.h b/sysdeps/nios2/nptl/bits/pthreadtypes.h
new file mode 100644
index 0000000000..4a20803679
--- /dev/null
+++ b/sysdeps/nios2/nptl/bits/pthreadtypes.h
@@ -0,0 +1,189 @@
+/* Machine-specific pthread type layouts. 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+union pthread_attr_t
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+};
+#ifndef __have_pthread_attr_t
+typedef union pthread_attr_t pthread_attr_t;
+# define __have_pthread_attr_t 1
+#endif
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
+#define __PTHREAD_SPINS 0
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/sysdeps/nios2/nptl/bits/semaphore.h b/sysdeps/nios2/nptl/bits/semaphore.h
new file mode 100644
index 0000000000..aa9430ef5d
--- /dev/null
+++ b/sysdeps/nios2/nptl/bits/semaphore.h
@@ -0,0 +1,32 @@
+/* Machine-specific POSIX semaphore type layouts. Nios II version.
+ Copyright (C) 2002-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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#define __SIZEOF_SEM_T 16
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/sysdeps/nios2/nptl/pthread_spin_lock.c b/sysdeps/nios2/nptl/pthread_spin_lock.c
new file mode 100644
index 0000000000..76581ce1ab
--- /dev/null
+++ b/sysdeps/nios2/nptl/pthread_spin_lock.c
@@ -0,0 +1,24 @@
+/* pthread spin-lock implementation for Nios II.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#define SPIN_LOCK_READS_BETWEEN_CMPXCHG 1000
+
+/* We can't use the normal "#include <nptl/pthread_spin_lock.c>" because
+ it will resolve to this very file. Using "sysdeps/.." as reference to the
+ top level directory does the job. */
+#include <sysdeps/../nptl/pthread_spin_lock.c>
diff --git a/sysdeps/nios2/nptl/pthreaddef.h b/sysdeps/nios2/nptl/pthreaddef.h
new file mode 100644
index 0000000000..debfb984e3
--- /dev/null
+++ b/sysdeps/nios2/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, Nios II version.
+ Copyright (C) 2002-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
+ <http://www.gnu.org/licenses/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 4
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 4
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
diff --git a/sysdeps/nios2/nptl/tcb-offsets.sym b/sysdeps/nios2/nptl/tcb-offsets.sym
new file mode 100644
index 0000000000..d9ae952585
--- /dev/null
+++ b/sysdeps/nios2/nptl/tcb-offsets.sym
@@ -0,0 +1,14 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+# undef __thread_self
+# define __thread_self ((void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
+POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h
new file mode 100644
index 0000000000..465a4b9134
--- /dev/null
+++ b/sysdeps/nios2/nptl/tls.h
@@ -0,0 +1,174 @@
+/* Definition for thread-local data handling. NPTL/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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+# define TLS_TCB_AT_TP 0
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ uintptr_t pointer_guard;
+ unsigned spare[6];
+} tcbhead_t;
+
+register struct pthread *__thread_self __asm__("r23");
+
+#define READ_THREAD_POINTER() ((void *) __thread_self)
+
+/* This is the size of the initial TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB - actually, it includes the TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The thread pointer (in hardware register r23) points to the end of
+ the TCB + 0x7000, as for PowerPC and MIPS. */
+# define TLS_TCB_OFFSET 0x7000
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv)
+
+/* Code to initially initialize the thread pointer. */
+# define TLS_INIT_TP(tcbp) \
+ (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL)
+
+/* Value passed to 'clone' for initialization of the thread register. */
+# define TLS_DEFINE_INIT_TP(tp, pd) \
+ void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER (32, 32, 23 * 4, -TLS_PRE_TCB_SIZE - TLS_TCB_OFFSET)
+
+/* Access to data in the thread descriptor is easy. */
+# define THREAD_GETMEM(descr, member) \
+ descr->member
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+# define THREAD_GET_POINTER_GUARD() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET))[-1].pointer_guard)
+# define THREAD_SET_POINTER_GUARD(value) \
+ (THREAD_GET_POINTER_GUARD () = (value))
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ (((tcbhead_t *) ((void *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].pointer_guard \
+ = THREAD_GET_POINTER_GUARD())
+
+/* l_tls_offset == 0 is perfectly valid on Nios II, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/sysdeps/nios2/preconfigure b/sysdeps/nios2/preconfigure
new file mode 100644
index 0000000000..4b5bd49084
--- /dev/null
+++ b/sysdeps/nios2/preconfigure
@@ -0,0 +1,6 @@
+case "$machine" in
+nios2*)
+ base_machine=nios2
+ machine=nios2
+ ;;
+esac
diff --git a/sysdeps/nios2/s_fma.c b/sysdeps/nios2/s_fma.c
new file mode 100644
index 0000000000..d9613fa67c
--- /dev/null
+++ b/sysdeps/nios2/s_fma.c
@@ -0,0 +1 @@
+#include <soft-fp/fmadf4.c>
diff --git a/sysdeps/nios2/s_fmaf.c b/sysdeps/nios2/s_fmaf.c
new file mode 100644
index 0000000000..aa5c9b2d91
--- /dev/null
+++ b/sysdeps/nios2/s_fmaf.c
@@ -0,0 +1 @@
+#include <soft-fp/fmasf4.c>
diff --git a/sysdeps/nios2/setjmp.S b/sysdeps/nios2/setjmp.S
new file mode 100644
index 0000000000..2a63c071d5
--- /dev/null
+++ b/sysdeps/nios2/setjmp.S
@@ -0,0 +1,73 @@
+/* setjmp for Nios II.
+ Copyright (C) 1991-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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <jmpbuf-offsets.h>
+
+ .text
+ENTRY(setjmp)
+ movi r5, 1
+ br __sigsetjmp
+END(setjmp)
+
+ENTRY(_setjmp)
+ mov r5, zero
+ br __sigsetjmp
+END(_setjmp)
+libc_hidden_def (_setjmp)
+
+/* Save the current program position in ENV and return 0. */
+ENTRY(__sigsetjmp)
+#ifdef PTR_MANGLE
+ PTR_MANGLE_GUARD (r9)
+#endif
+ stw r16, (JB_R16*4)(r4)
+ stw r17, (JB_R17*4)(r4)
+ stw r18, (JB_R18*4)(r4)
+ stw r19, (JB_R19*4)(r4)
+ stw r20, (JB_R20*4)(r4)
+ stw r21, (JB_R21*4)(r4)
+ stw r22, (JB_R22*4)(r4)
+ stw fp, (JB_FP*4)(r4)
+#ifdef PTR_MANGLE
+ PTR_MANGLE (r6, ra, r9)
+ PTR_MANGLE (r7, sp, r9)
+ stw r6, (JB_RA*4)(r4)
+ stw r7, (JB_SP*4)(r4)
+#else
+ stw ra, (JB_RA*4)(r4)
+ stw sp, (JB_SP*4)(r4)
+#endif
+#if IS_IN (rtld)
+ /* In ld.so we never save the signal mask. */
+ mov r2, zero
+ ret
+#else
+ /* Save the signal mask if requested. */
+#if defined(__PIC__) || defined(PIC)
+ nextpc r2
+1: movhi r3, %hiadj(__sigjmp_save - 1b)
+ addi r3, r3, %lo(__sigjmp_save - 1b)
+ add r2, r2, r3
+ jmp r2
+#else
+ jmpi __sigjmp_save
+#endif
+#endif
+END (__sigsetjmp)
+libc_hidden_def (__sigsetjmp)
diff --git a/sysdeps/nios2/sfp-machine.h b/sysdeps/nios2/sfp-machine.h
new file mode 100644
index 0000000000..95eefc1874
--- /dev/null
+++ b/sysdeps/nios2/sfp-machine.h
@@ -0,0 +1,51 @@
+#define _FP_W_TYPE_SIZE 32
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
+
+#define _FP_MUL_MEAT_S(R,X,Y) \
+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y) \
+ _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y) \
+ _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_MUL_MEAT_DW_S(R,X,Y) \
+ _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_D(R,X,Y) \
+ _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_Q(R,X,Y) \
+ _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+/* This is arbitrarily taken from the PowerPC version. */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+ do { \
+ if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
+ && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
+ { \
+ R##_s = Y##_s; \
+ _FP_FRAC_COPY_##wc(R,Y); \
+ } \
+ else \
+ { \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R,X); \
+ } \
+ R##_c = FP_CLS_NAN; \
+ } while (0)
+
+#define _FP_TININESS_AFTER_ROUNDING 0
diff --git a/sysdeps/nios2/sotruss-lib.c b/sysdeps/nios2/sotruss-lib.c
new file mode 100644
index 0000000000..bdc6293f03
--- /dev/null
+++ b/sysdeps/nios2/sotruss-lib.c
@@ -0,0 +1,51 @@
+/* Override generic sotruss-lib.c to define actual functions 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
+ <http://www.gnu.org/licenses/>. */
+
+#define HAVE_ARCH_PLTENTER
+#define HAVE_ARCH_PLTEXIT
+
+#include <elf/sotruss-lib.c>
+
+ElfW(Addr)
+la_nios2_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
+ unsigned int ndx __attribute__ ((unused)),
+ uintptr_t *refcook, uintptr_t *defcook,
+ La_nios2_regs *regs, unsigned int *flags,
+ const char *symname, long int *framesizep)
+{
+ print_enter (refcook, defcook, symname,
+ regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
+ *flags);
+
+ /* No need to copy anything, we will not need the parameters in any case. */
+ *framesizep = 0;
+
+ return sym->st_value;
+}
+
+unsigned int
+la_nios2_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
+ uintptr_t *defcook,
+ const struct La_nios2_regs *inregs,
+ struct La_nios2_retval *outregs, const char *symname)
+{
+ print_exit (refcook, defcook, symname, outregs->lrv_r2);
+
+ return 0;
+}
diff --git a/sysdeps/nios2/stackguard-macros.h b/sysdeps/nios2/stackguard-macros.h
new file mode 100644
index 0000000000..55a5771b62
--- /dev/null
+++ b/sysdeps/nios2/stackguard-macros.h
@@ -0,0 +1,6 @@
+#include <stdint.h>
+
+extern uintptr_t __stack_chk_guard;
+#define STACK_CHK_GUARD __stack_chk_guard
+
+#define POINTER_CHK_GUARD THREAD_GET_POINTER_GUARD()
diff --git a/sysdeps/nios2/stackinfo.h b/sysdeps/nios2/stackinfo.h
new file mode 100644
index 0000000000..edd3377cfe
--- /dev/null
+++ b/sysdeps/nios2/stackinfo.h
@@ -0,0 +1,33 @@
+/* Stack environment definitions 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.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+#include <elf.h>
+
+/* On Nios II the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+/* Default to a non-executable stack. */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W)
+
+#endif /* stackinfo.h */
diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S
new file mode 100644
index 0000000000..96cec96e24
--- /dev/null
+++ b/sysdeps/nios2/start.S
@@ -0,0 +1,146 @@
+/* Startup code for Nios II
+ 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.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment.
+
+ Note that the code in the .init section has already been run.
+ This includes _init and _libc_init
+
+ The stack pointer, sp, will point to the argument count on the stack.
+ The initial state of the stack when a userspace process is started is:
+
+ Purpose Start Address Length
+ Unspecified High Addresses
+ Referenced strings, etc. Varies
+ Unspecified
+ Null auxilliary vector entry 4bytes
+ Auxilliary vector entries 8bytes each
+ NULL terminator for envp 4bytes
+ Environment pointers sp+8+4*argc 4bytes each
+ NULL terminator for argv sp+4+4*argc 4bytes
+ Argument pointers sp+4 4bytes each
+ Argument count sp 4bytes
+ Unspecified Low Addresses
+
+ If the application should register a destructor function with atexit,
+ the pointer will be placed in r4. Otherwise r4 will be zero.
+
+ The contents of all other registers are unspecified. User code should
+ set fp to zero to mark the end of the frame chain.
+
+ The auxilliary vector is a series of pairs of 32-bit tag and 32-bit
+ value, terminated by an AT_NULL tag.
+*/
+
+ .text
+ .globl _start
+ .type _start,%function
+_start:
+ /* Set up the global pointer. */
+ movhi gp, %hiadj(_gp)
+ addi gp, gp, %lo(_gp)
+
+ /* Save the stack pointer. */
+ mov r2, sp
+
+ /* Create room on the stack for the fini, rtld_fini and stack_end args
+ to __libc_start_main. */
+ subi sp, sp, 12
+
+ /* Push stack_end */
+ stw r2, 8(sp)
+
+ /* Push rtld_fini */
+ stw r4, 4(sp)
+
+ /* Set up the GOT pointer. */
+ nextpc r22
+1: movhi r2, %hiadj(_gp_got - 1b)
+ addi r2, r2, %lo(_gp_got - 1b)
+ add r22, r22, r2
+
+ /* Push fini */
+ movhi r8, %call_hiadj(__libc_csu_fini)
+ addi r8, r8, %call_lo(__libc_csu_fini)
+ add r8, r8, r22
+ ldw r8, 0(r8)
+ stw r8, 0(sp)
+
+ /* r7 == init */
+ movhi r7, %call_hiadj(__libc_csu_init)
+ addi r7, r7, %call_lo(__libc_csu_init)
+ add r7, r7, r22
+ ldw r7, 0(r7)
+
+ /* r6 == argv */
+ addi r6, sp, 16
+
+ /* r5 == argc */
+ ldw r5, 12(sp)
+
+ /* r4 == main */
+ movhi r4, %call_hiadj(main)
+ addi r4, r4, %call_lo(main)
+ add r4, r4, r22
+ ldw r4, 0(r4)
+
+ /* fp == 0 */
+ mov fp, zero
+
+ /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
+ stack_end) */
+
+ /* Let the libc call main and exit with its return code. */
+ movhi r2, %call_hiadj(__libc_start_main)
+ addi r2, r2, %call_lo(__libc_start_main)
+ add r2, r2, r22
+ ldw r2, 0(r2)
+ callr r2
+
+ /* should never get here....*/
+ movhi r2, %call_hiadj(abort)
+ addi r2, r2, %call_lo(abort)
+ add r2, r2, r22
+ ldw r2, 0(r2)
+ callr r2
+
+/* 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/nios2/sysdep.h b/sysdeps/nios2/sysdep.h
new file mode 100644
index 0000000000..6c597e5dee
--- /dev/null
+++ b/sysdeps/nios2/sysdep.h
@@ -0,0 +1,65 @@
+/* Assembler macros 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdeps/generic/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ .type C_SYMBOL_NAME(name),%function; \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT;
+
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(name)
+
+#ifdef PROF
+
+# ifdef __PIC__
+# define CALL_MCOUNT \
+ mov r8, ra; \
+ nextpc r2; \
+1: \
+ movhi r3, %hiadj(_gp_got - 1b); \
+ addi r3, r3, %lo(_gp_got - 1b); \
+ add r2, r2, r3; \
+ ldw r2, %call(_mcount)(r2); \
+ callr r2; \
+ mov ra, r8; \
+ ret;
+# else
+# define CALL_MCOUNT \
+ mov r8, ra; \
+ call _mount; \
+ mov ra, r8; \
+ ret;
+# endif
+
+#else
+# define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#endif /* __ASSEMBLER__ */
diff --git a/sysdeps/nios2/tls-macros.h b/sysdeps/nios2/tls-macros.h
new file mode 100644
index 0000000000..7029530e46
--- /dev/null
+++ b/sysdeps/nios2/tls-macros.h
@@ -0,0 +1,46 @@
+#define TLS_LE(x) \
+ ({ int *__result; \
+ asm ("addi %0, r23, %%tls_le(" #x ")" \
+ : "=r" (__result)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ int __tmp; \
+ asm ("nextpc %0 ; " \
+ "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
+ "addi %1, %1, %%lo(_gp_got - 1b) ; " \
+ "add %0, %0, %1 ; " \
+ "ldw %1, %%tls_ie(" #x ")(%0) ; " \
+ "add %1, r23, %1" \
+ : "=&r" (__tmp), "=&r" (__result)); \
+ __result; })
+
+#define TLS_LD(x) \
+ ({ char *__result; \
+ char *__result2; \
+ int *__result3; \
+ int __tmp; \
+ extern void *__tls_get_addr (void *); \
+ asm ("nextpc %0 ; " \
+ "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
+ "addi %1, %1, %%lo(_gp_got - 1b) ; " \
+ "add %0, %0, %1 ; " \
+ "addi %0, %0, %%tls_ldm(" #x ")" \
+ : "=r" (__result), "=r" (__tmp)); \
+ __result2 = (char *)__tls_get_addr (__result); \
+ asm ("addi %0, %1, %%tls_ldo(" #x ")" \
+ : "=r" (__result3) : "r" (__result2)); \
+ __result3; })
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ int __tmp; \
+ extern void *__tls_get_addr (void *); \
+ asm ("nextpc %0 ; " \
+ "1: movhi %1, %%hiadj(_gp_got - 1b) ; " \
+ "addi %1, %1, %%lo(_gp_got - 1b) ; " \
+ "add %0, %0, %1 ; " \
+ "addi %0, %0, %%tls_gd(" #x ")" \
+ : "=r" (__result), "=r" (__tmp)); \
+ (int *)__tls_get_addr (__result); })
diff --git a/sysdeps/nios2/tst-audit.h b/sysdeps/nios2/tst-audit.h
new file mode 100644
index 0000000000..ab427a8600
--- /dev/null
+++ b/sysdeps/nios2/tst-audit.h
@@ -0,0 +1,23 @@
+/* Definitions for testing PLT entry/exit auditing. 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
+ <http://www.gnu.org/licenses/>. */
+
+#define pltenter la_nios2_gnu_pltenter
+#define pltexit la_nios2_gnu_pltexit
+#define La_regs La_nios2_regs
+#define La_retval La_nios2_retval
+#define int_retval lrv_r2
diff --git a/sysdeps/unix/sysv/linux/nios2/Implies b/sysdeps/unix/sysv/linux/nios2/Implies
new file mode 100644
index 0000000000..4d0478bf8f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/Implies
@@ -0,0 +1,3 @@
+nios2/nptl
+unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
diff --git a/sysdeps/unix/sysv/linux/nios2/Makefile b/sysdeps/unix/sysv/linux/nios2/Makefile
new file mode 100644
index 0000000000..d0af9ec559
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/Makefile
@@ -0,0 +1,13 @@
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext_i.sym
+endif
+
+ifeq ($(subdir),misc)
+# MIPS/Tile-style cacheflush routine
+sysdep_headers += sys/cachectl.h
+sysdep_routines += cacheflush
+endif
+
+ifeq ($(subdir),nptl)
+libpthread-routines := $(filter-out pt-vfork,$(libpthread-routines))
+endif
diff --git a/sysdeps/unix/sysv/linux/nios2/Versions b/sysdeps/unix/sysv/linux/nios2/Versions
new file mode 100644
index 0000000000..e42c85f575
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/Versions
@@ -0,0 +1,6 @@
+libc {
+ GLIBC_2.21 {
+ _flush_cache;
+ cacheflush;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/nios2/arch-fork.h b/sysdeps/unix/sysv/linux/nios2/arch-fork.h
new file mode 100644
index 0000000000..23d497e5c9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/arch-fork.h
@@ -0,0 +1,33 @@
+/* ARCH_FORK definition for Linux fork implementation. 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+/* Argument 1 - Clone flags.
+ 2 - Child stack pointer.
+ 3 - Parent tid pointer.
+ 4 - Child tid pointer.
+ 5 - New TLS area pointer. */
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, &THREAD_SELF->tid, NULL)
diff --git a/sysdeps/unix/sysv/linux/nios2/bits/atomic.h b/sysdeps/unix/sysv/linux/nios2/bits/atomic.h
new file mode 100644
index 0000000000..2329f7463d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/bits/atomic.h
@@ -0,0 +1,92 @@
+/* Low-level functions for atomic operations. 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _NIOS2_BITS_ATOMIC_H
+#define _NIOS2_BITS_ATOMIC_H 1
+
+#include <stdint.h>
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define __HAVE_64B_ATOMICS 0
+#define USE_ATOMIC_COMPILER_BUILTINS 0
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
+ (abort (), 0)
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
+ (abort (), 0)
+#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ \
+ register int r2 asm ("r2"); \
+ register int* r4 asm ("r4") = (int*)(mem); \
+ register int r5 asm ("r5"); \
+ register int r6 asm ("r6") = (int)(newval); \
+ int retval, orig_oldval = (int)(oldval); \
+ long kernel_cmpxchg = 0x1004; \
+ while (1) \
+ { \
+ r5 = *r4; \
+ if (r5 != orig_oldval) \
+ { \
+ retval = r5; \
+ break; \
+ } \
+ asm volatile ("callr %1\n" \
+ : "=r" (r2) \
+ : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
+ : "ra", "memory"); \
+ if (!r2) { retval = orig_oldval; break; } \
+ } \
+ (__typeof (*(mem))) retval; \
+ })
+
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
+ ({ \
+ register int r2 asm ("r2"); \
+ register int *r4 asm ("r4") = (int*)(mem); \
+ register int r5 asm ("r5") = (int)(oldval); \
+ register int r6 asm ("r6") = (int)(newval); \
+ long kernel_cmpxchg = 0x1004; \
+ asm volatile ("callr %1\n" \
+ : "=r" (r2) \
+ : "r" (kernel_cmpxchg), "r" (r4), "r" (r5), "r" (r6) \
+ : "ra", "memory"); \
+ r2; \
+ })
+
+#define atomic_full_barrier() ({ asm volatile ("sync"); })
+
+#endif /* _NIOS2_BITS_ATOMIC_H */
diff --git a/sysdeps/unix/sysv/linux/nios2/bits/mman.h b/sysdeps/unix/sysv/linux/nios2/bits/mman.h
new file mode 100644
index 0000000000..23e92abd71
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/bits/mman.h
@@ -0,0 +1,42 @@
+/* Definitions for POSIX memory map interface. Linux/Nios II version.
+
+ Copyright (C) 1997-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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
+#endif
+
+/* Include generic Linux declarations. */
+#include <bits/mman-linux.h>
diff --git a/sysdeps/unix/sysv/linux/nios2/c++-types.data b/sysdeps/unix/sysv/linux/nios2/c++-types.data
new file mode 100644
index 0000000000..303f4570c8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/c++-types.data
@@ -0,0 +1,67 @@
+blkcnt64_t:x
+blkcnt_t:l
+blksize_t:i
+caddr_t:Pc
+clockid_t:i
+clock_t:l
+daddr_t:i
+dev_t:y
+fd_mask:l
+fsblkcnt64_t:y
+fsblkcnt_t:m
+fsfilcnt64_t:y
+fsfilcnt_t:m
+fsid_t:8__fsid_t
+gid_t:j
+id_t:j
+ino64_t:y
+ino_t:m
+int16_t:s
+int32_t:i
+int64_t:x
+int8_t:a
+intptr_t:i
+key_t:i
+loff_t:x
+mode_t:j
+nlink_t:j
+off64_t:x
+off_t:l
+pid_t:i
+pthread_attr_t:14pthread_attr_t
+pthread_barrier_t:17pthread_barrier_t
+pthread_barrierattr_t:21pthread_barrierattr_t
+pthread_cond_t:14pthread_cond_t
+pthread_condattr_t:18pthread_condattr_t
+pthread_key_t:j
+pthread_mutex_t:15pthread_mutex_t
+pthread_mutexattr_t:19pthread_mutexattr_t
+pthread_once_t:i
+pthread_rwlock_t:16pthread_rwlock_t
+pthread_rwlockattr_t:20pthread_rwlockattr_t
+pthread_spinlock_t:i
+pthread_t:m
+quad_t:x
+register_t:i
+rlim64_t:y
+rlim_t:m
+sigset_t:10__sigset_t
+size_t:j
+socklen_t:j
+ssize_t:i
+suseconds_t:l
+time_t:l
+u_char:h
+uid_t:j
+uint:j
+u_int:j
+u_int16_t:t
+u_int32_t:j
+u_int64_t:y
+u_int8_t:h
+ulong:m
+u_long:m
+u_quad_t:y
+useconds_t:j
+ushort:t
+u_short:t
diff --git a/sysdeps/unix/sysv/linux/nios2/cacheflush.c b/sysdeps/unix/sysv/linux/nios2/cacheflush.c
new file mode 100644
index 0000000000..b2f989d530
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/cacheflush.c
@@ -0,0 +1,29 @@
+/* cacheflush system call for Nios II Linux.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* Flush cache(s). */
+int
+_flush_cache (char *addr, const int nbytes, const int op)
+{
+ return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
+}
+weak_alias (_flush_cache, cacheflush)
diff --git a/sysdeps/unix/sysv/linux/nios2/clone.S b/sysdeps/unix/sysv/linux/nios2/clone.S
new file mode 100644
index 0000000000..9fab461803
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/clone.S
@@ -0,0 +1,107 @@
+/* clone() implementation for Nios II.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andrew Jenner <andrew@codesourcery.com>, 2008.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <tcb-offsets.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ void *parent_tidptr, void *tls, void *child_tidptr) */
+
+ .text
+ENTRY(__clone)
+ /* Sanity check arguments. */
+ movi r2, EINVAL
+ /* No NULL function pointers. */
+ beq r4, zero, SYSCALL_ERROR_LABEL
+ /* No NULL stack pointers. */
+ beq r5, zero, SYSCALL_ERROR_LABEL
+
+ subi r5, r5, 8 /* Reserve argument save space. */
+ stw r4, 4(r5) /* Save function pointer. */
+ stw r7, 0(r5) /* Save argument pointer. */
+
+ /* Load arguments. */
+ mov r4, r6
+ ldw r6, 0(sp)
+ ldw r7, 8(sp)
+ ldw r8, 4(sp)
+
+ /* Do the system call. */
+ movi r2, SYS_ify (clone)
+
+ /* End FDE now, because in the child the unwind info will be
+ wrong. */
+ cfi_endproc
+ trap
+
+ /* Check for errors. */
+ bne r7, zero, SYSCALL_ERROR_LABEL
+ /* See if we're on the newly created thread. */
+ beq r2, zero, thread_start
+ /* Successful return from the parent */
+ ret
+
+thread_start:
+ cfi_startproc
+ cfi_undefined (ra)
+
+ /* We expect the argument registers to be preserved across system
+ calls and across task cloning, so flags should be in r4 here. */
+ andhi r2, r4, %hi(CLONE_THREAD)
+ bne r2, zero, 2f
+ andi r3, r4, CLONE_VM
+ movi r2, -1
+ bne r3, zero, 3f
+ DO_CALL (getpid, 0)
+3:
+ stw r2, PID_OFFSET(r23)
+ stw r2, TID_OFFSET(r23)
+2:
+ ldw r5, 4(sp) /* Function pointer. */
+ ldw r4, 0(sp) /* Argument pointer. */
+ addi sp, sp, 8
+
+ /* Call the user's function. */
+ callr r5
+
+ /* _exit with the result. */
+ mov r4, r2
+#ifdef PIC
+ nextpc r22
+1: movhi r8, %hiadj(_gp_got - 1b)
+ addi r8, r8, %lo(_gp_got - 1b)
+ add r22, r22, r8
+ ldw r8, %call(HIDDEN_JUMPTARGET(_exit))(r22)
+ jmp r8
+#else
+ jmpi _exit
+#endif
+ cfi_endproc
+
+ cfi_startproc
+PSEUDO_END (__clone)
+weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/nios2/configure b/sysdeps/unix/sysv/linux/nios2/configure
new file mode 100644
index 0000000000..d5d117b3d2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/nios2.
+
+arch_minimum_kernel=3.19.0
diff --git a/sysdeps/unix/sysv/linux/nios2/configure.ac b/sysdeps/unix/sysv/linux/nios2/configure.ac
new file mode 100644
index 0000000000..a8ccc17ffe
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/configure.ac
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/nios2.
+
+arch_minimum_kernel=3.19.0
diff --git a/sysdeps/unix/sysv/linux/nios2/getcontext.S b/sysdeps/unix/sysv/linux/nios2/getcontext.S
new file mode 100644
index 0000000000..ffbd91f72a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/getcontext.S
@@ -0,0 +1,66 @@
+/* Save current context.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int getcontext (ucontext_t *ucp)
+
+ Returns 0 on success -1 and errno on failure.
+ */
+ .text
+ENTRY(__getcontext)
+ stw r16, (UCONTEXT_MCONTEXT + 16*4)(r4)
+ stw r17, (UCONTEXT_MCONTEXT + 17*4)(r4)
+ stw r18, (UCONTEXT_MCONTEXT + 18*4)(r4)
+ stw r19, (UCONTEXT_MCONTEXT + 19*4)(r4)
+ stw r20, (UCONTEXT_MCONTEXT + 20*4)(r4)
+ stw r21, (UCONTEXT_MCONTEXT + 21*4)(r4)
+ stw r22, (UCONTEXT_MCONTEXT + 22*4)(r4)
+ stw ra, (UCONTEXT_MCONTEXT + 24*4)(r4)
+ stw fp, (UCONTEXT_MCONTEXT + 25*4)(r4)
+ stw gp, (UCONTEXT_MCONTEXT + 26*4)(r4)
+ /* Store return address at place for EA. */
+ stw ra, (UCONTEXT_MCONTEXT + 28*4)(r4)
+ stw sp, (UCONTEXT_MCONTEXT + 29*4)(r4)
+ /* Store zero for return success. */
+ stw zero, (UCONTEXT_MCONTEXT + 2*4)(r4)
+
+ /* Store value "1" at uc_flags to recognize as getcontext created. */
+ movi r2, 1
+ stw r2, UCONTEXT_FLAGS(r4)
+
+ /* Store MCONTEXT_VERSION at first word of mcontext_t. */
+ movi r2, MCONTEXT_VERSION
+ stw r2, UCONTEXT_MCONTEXT(r4)
+
+ /* Get signal mask. */
+ /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ movi r7, _NSIG8
+ addi r6, r4, UCONTEXT_SIGMASK
+ mov r5, zero
+ movi r4, SIG_BLOCK
+ movi r2, SYS_ify (rt_sigprocmask)
+ trap
+ bne r7, zero, SYSCALL_ERROR_LABEL
+
+ mov r2, zero
+ ret
+
+PSEUDO_END(__getcontext)
+weak_alias(__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/nios2/kernel-features.h b/sysdeps/unix/sysv/linux/nios2/kernel-features.h
new file mode 100644
index 0000000000..f4e96a0e27
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/kernel-features.h
@@ -0,0 +1,31 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <linux/version.h>
+
+/* The minimum supported kernel version for Nios II is 3.19.0,
+ guaranteeing many kernel features. */
+
+#define __ASSUME_ACCEPT4_SYSCALL 1
+#define __ASSUME_RECVMMSG_SYSCALL 1
+#define __ASSUME_SENDMMSG_SYSCALL 1
+
+#include_next <kernel-features.h>
diff --git a/sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h b/sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h
new file mode 100644
index 0000000000..189edad792
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/kernel_rt_sigframe.h
@@ -0,0 +1,26 @@
+/* Linux kernel struct rt_sigframe declaration 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
+ <http://www.gnu.org/licenses/>. */
+
+/* This structure must have the same shape as the Linux kernel
+ equivalent. */
+
+struct kernel_rt_sigframe
+{
+ siginfo_t info;
+ struct ucontext uc;
+};
diff --git a/sysdeps/unix/sysv/linux/nios2/ld.abilist b/sysdeps/unix/sysv/linux/nios2/ld.abilist
new file mode 100644
index 0000000000..b8d80dc101
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/ld.abilist
@@ -0,0 +1,12 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ __libc_memalign F
+ __libc_stack_end D 0x4
+ __stack_chk_guard D 0x4
+ __tls_get_addr F
+ _dl_mcount F
+ _r_debug D 0x14
+ calloc F
+ free F
+ malloc F
+ realloc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist b/sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist
new file mode 100644
index 0000000000..0a63b27f53
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libBrokenLocale.abilist
@@ -0,0 +1,3 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ __ctype_get_mb_cur_max F
diff --git a/sysdeps/unix/sysv/linux/nios2/libanl.abilist b/sysdeps/unix/sysv/linux/nios2/libanl.abilist
new file mode 100644
index 0000000000..589be5e2db
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libanl.abilist
@@ -0,0 +1,6 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ gai_cancel F
+ gai_error F
+ gai_suspend F
+ getaddrinfo_a F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
new file mode 100644
index 0000000000..0703418082
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -0,0 +1,2123 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ _Exit F
+ _IO_2_1_stderr_ D 0x98
+ _IO_2_1_stdin_ D 0x98
+ _IO_2_1_stdout_ D 0x98
+ _IO_adjust_column F
+ _IO_adjust_wcolumn F
+ _IO_default_doallocate F
+ _IO_default_finish F
+ _IO_default_pbackfail F
+ _IO_default_uflow F
+ _IO_default_xsgetn F
+ _IO_default_xsputn F
+ _IO_do_write F
+ _IO_doallocbuf F
+ _IO_fclose F
+ _IO_fdopen F
+ _IO_feof F
+ _IO_ferror F
+ _IO_fflush F
+ _IO_fgetpos F
+ _IO_fgetpos64 F
+ _IO_fgets F
+ _IO_file_attach F
+ _IO_file_close F
+ _IO_file_close_it F
+ _IO_file_doallocate F
+ _IO_file_finish F
+ _IO_file_fopen F
+ _IO_file_init F
+ _IO_file_jumps D 0x54
+ _IO_file_open F
+ _IO_file_overflow F
+ _IO_file_read F
+ _IO_file_seek F
+ _IO_file_seekoff F
+ _IO_file_setbuf F
+ _IO_file_stat F
+ _IO_file_sync F
+ _IO_file_underflow F
+ _IO_file_write F
+ _IO_file_xsputn F
+ _IO_flockfile F
+ _IO_flush_all F
+ _IO_flush_all_linebuffered F
+ _IO_fopen F
+ _IO_fprintf F
+ _IO_fputs F
+ _IO_fread F
+ _IO_free_backup_area F
+ _IO_free_wbackup_area F
+ _IO_fsetpos F
+ _IO_fsetpos64 F
+ _IO_ftell F
+ _IO_ftrylockfile F
+ _IO_funlockfile F
+ _IO_fwrite F
+ _IO_getc F
+ _IO_getline F
+ _IO_getline_info F
+ _IO_gets F
+ _IO_init F
+ _IO_init_marker F
+ _IO_init_wmarker F
+ _IO_iter_begin F
+ _IO_iter_end F
+ _IO_iter_file F
+ _IO_iter_next F
+ _IO_least_wmarker F
+ _IO_link_in F
+ _IO_list_all D 0x4
+ _IO_list_lock F
+ _IO_list_resetlock F
+ _IO_list_unlock F
+ _IO_marker_delta F
+ _IO_marker_difference F
+ _IO_padn F
+ _IO_peekc_locked F
+ _IO_popen F
+ _IO_printf F
+ _IO_proc_close F
+ _IO_proc_open F
+ _IO_putc F
+ _IO_puts F
+ _IO_remove_marker F
+ _IO_seekmark F
+ _IO_seekoff F
+ _IO_seekpos F
+ _IO_seekwmark F
+ _IO_setb F
+ _IO_setbuffer F
+ _IO_setvbuf F
+ _IO_sgetn F
+ _IO_sprintf F
+ _IO_sputbackc F
+ _IO_sputbackwc F
+ _IO_sscanf F
+ _IO_str_init_readonly F
+ _IO_str_init_static F
+ _IO_str_overflow F
+ _IO_str_pbackfail F
+ _IO_str_seekoff F
+ _IO_str_underflow F
+ _IO_sungetc F
+ _IO_sungetwc F
+ _IO_switch_to_get_mode F
+ _IO_switch_to_main_wget_area F
+ _IO_switch_to_wbackup_area F
+ _IO_switch_to_wget_mode F
+ _IO_un_link F
+ _IO_ungetc F
+ _IO_unsave_markers F
+ _IO_unsave_wmarkers F
+ _IO_vfprintf F
+ _IO_vfscanf F
+ _IO_vsprintf F
+ _IO_wdefault_doallocate F
+ _IO_wdefault_finish F
+ _IO_wdefault_pbackfail F
+ _IO_wdefault_uflow F
+ _IO_wdefault_xsgetn F
+ _IO_wdefault_xsputn F
+ _IO_wdo_write F
+ _IO_wdoallocbuf F
+ _IO_wfile_jumps D 0x54
+ _IO_wfile_overflow F
+ _IO_wfile_seekoff F
+ _IO_wfile_sync F
+ _IO_wfile_underflow F
+ _IO_wfile_xsputn F
+ _IO_wmarker_delta F
+ _IO_wsetb F
+ ___brk_addr D 0x4
+ __adddf3 F
+ __addsf3 F
+ __adjtimex F
+ __after_morecore_hook D 0x4
+ __argz_count F
+ __argz_next F
+ __argz_stringify F
+ __asprintf F
+ __asprintf_chk F
+ __assert F
+ __assert_fail F
+ __assert_perror_fail F
+ __backtrace F
+ __backtrace_symbols F
+ __backtrace_symbols_fd F
+ __bsd_getpgrp F
+ __bzero F
+ __check_rhosts_file D 0x4
+ __chk_fail F
+ __clone F
+ __close F
+ __cmsg_nxthdr F
+ __confstr_chk F
+ __connect F
+ __ctype_b_loc F
+ __ctype_get_mb_cur_max F
+ __ctype_tolower_loc F
+ __ctype_toupper_loc F
+ __curbrk D 0x4
+ __cxa_at_quick_exit F
+ __cxa_atexit F
+ __cxa_finalize F
+ __cxa_thread_atexit_impl F
+ __cyg_profile_func_enter F
+ __cyg_profile_func_exit F
+ __daylight D 0x4
+ __dcgettext F
+ __default_morecore F
+ __dgettext F
+ __divdf3 F
+ __divsf3 F
+ __dprintf_chk F
+ __dup2 F
+ __duplocale F
+ __endmntent F
+ __environ D 0x4
+ __eqdf2 F
+ __eqsf2 F
+ __errno_location F
+ __extendsfdf2 F
+ __fbufsize F
+ __fcntl F
+ __fdelt_chk F
+ __fdelt_warn F
+ __ffs F
+ __fgets_chk F
+ __fgets_unlocked_chk F
+ __fgetws_chk F
+ __fgetws_unlocked_chk F
+ __finite F
+ __finitef F
+ __finitel F
+ __fixdfdi F
+ __fixdfsi F
+ __fixsfdi F
+ __fixsfsi F
+ __fixunsdfdi F
+ __fixunsdfsi F
+ __fixunssfdi F
+ __fixunssfsi F
+ __flbf F
+ __floatdidf F
+ __floatdisf F
+ __floatsidf F
+ __floatsisf F
+ __floatundidf F
+ __floatundisf F
+ __floatunsidf F
+ __floatunsisf F
+ __fork F
+ __fpending F
+ __fprintf_chk F
+ __fpu_control D 0x4
+ __fpurge F
+ __fread_chk F
+ __fread_unlocked_chk F
+ __freadable F
+ __freading F
+ __free_hook D 0x4
+ __freelocale F
+ __fsetlocking F
+ __fwprintf_chk F
+ __fwritable F
+ __fwriting F
+ __fxstat F
+ __fxstat64 F
+ __fxstatat F
+ __fxstatat64 F
+ __gedf2 F
+ __gesf2 F
+ __getauxval F
+ __getcwd_chk F
+ __getdelim F
+ __getdomainname_chk F
+ __getgroups_chk F
+ __gethostname_chk F
+ __getlogin_r_chk F
+ __getmntent_r F
+ __getpagesize F
+ __getpgid F
+ __getpid F
+ __gets_chk F
+ __gettimeofday F
+ __getwd_chk F
+ __gmtime_r F
+ __gtdf2 F
+ __gtsf2 F
+ __h_errno_location F
+ __isalnum_l F
+ __isalpha_l F
+ __isascii_l F
+ __isblank_l F
+ __iscntrl_l F
+ __isctype F
+ __isdigit_l F
+ __isgraph_l F
+ __isinf F
+ __isinff F
+ __isinfl F
+ __islower_l F
+ __isnan F
+ __isnanf F
+ __isnanl F
+ __isoc99_fscanf F
+ __isoc99_fwscanf F
+ __isoc99_scanf F
+ __isoc99_sscanf F
+ __isoc99_swscanf F
+ __isoc99_vfscanf F
+ __isoc99_vfwscanf F
+ __isoc99_vscanf F
+ __isoc99_vsscanf F
+ __isoc99_vswscanf F
+ __isoc99_vwscanf F
+ __isoc99_wscanf F
+ __isprint_l F
+ __ispunct_l F
+ __isspace_l F
+ __isupper_l F
+ __iswalnum_l F
+ __iswalpha_l F
+ __iswblank_l F
+ __iswcntrl_l F
+ __iswctype F
+ __iswctype_l F
+ __iswdigit_l F
+ __iswgraph_l F
+ __iswlower_l F
+ __iswprint_l F
+ __iswpunct_l F
+ __iswspace_l F
+ __iswupper_l F
+ __iswxdigit_l F
+ __isxdigit_l F
+ __ivaliduser F
+ __key_decryptsession_pk_LOCAL D 0x4
+ __key_encryptsession_pk_LOCAL D 0x4
+ __key_gendes_LOCAL D 0x4
+ __ledf2 F
+ __lesf2 F
+ __libc_allocate_rtsig F
+ __libc_calloc F
+ __libc_current_sigrtmax F
+ __libc_current_sigrtmin F
+ __libc_free F
+ __libc_freeres F
+ __libc_init_first F
+ __libc_mallinfo F
+ __libc_malloc F
+ __libc_mallopt F
+ __libc_memalign F
+ __libc_pvalloc F
+ __libc_realloc F
+ __libc_sa_len F
+ __libc_start_main F
+ __libc_valloc F
+ __longjmp_chk F
+ __lseek F
+ __ltdf2 F
+ __ltsf2 F
+ __lxstat F
+ __lxstat64 F
+ __malloc_hook D 0x4
+ __malloc_initialize_hook D 0x4
+ __mbrlen F
+ __mbrtowc F
+ __mbsnrtowcs_chk F
+ __mbsrtowcs_chk F
+ __mbstowcs_chk F
+ __memalign_hook D 0x4
+ __memcpy_chk F
+ __memmove_chk F
+ __mempcpy F
+ __mempcpy_chk F
+ __mempcpy_small F
+ __memset_chk F
+ __monstartup F
+ __morecore D 0x4
+ __muldf3 F
+ __mulsf3 F
+ __nanosleep F
+ __nedf2 F
+ __negdf2 F
+ __negsf2 F
+ __nesf2 F
+ __newlocale F
+ __nl_langinfo_l F
+ __nss_configure_lookup F
+ __nss_database_lookup F
+ __nss_group_lookup F
+ __nss_hostname_digits_dots F
+ __nss_hosts_lookup F
+ __nss_next F
+ __nss_passwd_lookup F
+ __obstack_printf_chk F
+ __obstack_vprintf_chk F
+ __open F
+ __open64 F
+ __open64_2 F
+ __open_2 F
+ __openat64_2 F
+ __openat_2 F
+ __overflow F
+ __pipe F
+ __poll F
+ __poll_chk F
+ __posix_getopt F
+ __ppoll_chk F
+ __pread64 F
+ __pread64_chk F
+ __pread_chk F
+ __printf_chk F
+ __printf_fp F
+ __profile_frequency F
+ __progname D 0x4
+ __progname_full D 0x4
+ __ptsname_r_chk F
+ __pwrite64 F
+ __rawmemchr F
+ __rcmd_errstr D 0x4
+ __read F
+ __read_chk F
+ __readlink_chk F
+ __readlinkat_chk F
+ __realloc_hook D 0x4
+ __realpath_chk F
+ __recv_chk F
+ __recvfrom_chk F
+ __register_atfork F
+ __res_init F
+ __res_nclose F
+ __res_ninit F
+ __res_randomid F
+ __res_state F
+ __rpc_thread_createerr F
+ __rpc_thread_svc_fdset F
+ __rpc_thread_svc_max_pollfd F
+ __rpc_thread_svc_pollfd F
+ __sbrk F
+ __sched_cpualloc F
+ __sched_cpucount F
+ __sched_cpufree F
+ __sched_get_priority_max F
+ __sched_get_priority_min F
+ __sched_getparam F
+ __sched_getscheduler F
+ __sched_setscheduler F
+ __sched_yield F
+ __select F
+ __setmntent F
+ __setpgid F
+ __sigaction F
+ __sigaddset F
+ __sigdelset F
+ __sigismember F
+ __signbit F
+ __signbitf F
+ __sigpause F
+ __sigsetjmp F
+ __sigsuspend F
+ __snprintf_chk F
+ __sprintf_chk F
+ __stack_chk_fail F
+ __statfs F
+ __stpcpy F
+ __stpcpy_chk F
+ __stpcpy_small F
+ __stpncpy F
+ __stpncpy_chk F
+ __strcasecmp F
+ __strcasecmp_l F
+ __strcasestr F
+ __strcat_chk F
+ __strcoll_l F
+ __strcpy_chk F
+ __strcpy_small F
+ __strcspn_c1 F
+ __strcspn_c2 F
+ __strcspn_c3 F
+ __strdup F
+ __strerror_r F
+ __strfmon_l F
+ __strftime_l F
+ __strncasecmp_l F
+ __strncat_chk F
+ __strncpy_chk F
+ __strndup F
+ __strpbrk_c2 F
+ __strpbrk_c3 F
+ __strsep_1c F
+ __strsep_2c F
+ __strsep_3c F
+ __strsep_g F
+ __strspn_c1 F
+ __strspn_c2 F
+ __strspn_c3 F
+ __strtod_internal F
+ __strtod_l F
+ __strtof_internal F
+ __strtof_l F
+ __strtok_r F
+ __strtok_r_1c F
+ __strtol_internal F
+ __strtol_l F
+ __strtold_internal F
+ __strtold_l F
+ __strtoll_internal F
+ __strtoll_l F
+ __strtoul_internal F
+ __strtoul_l F
+ __strtoull_internal F
+ __strtoull_l F
+ __strverscmp F
+ __strxfrm_l F
+ __subdf3 F
+ __subsf3 F
+ __swprintf_chk F
+ __sysconf F
+ __syslog_chk F
+ __sysv_signal F
+ __timezone D 0x4
+ __toascii_l F
+ __tolower_l F
+ __toupper_l F
+ __towctrans F
+ __towctrans_l F
+ __towlower_l F
+ __towupper_l F
+ __truncdfsf2 F
+ __ttyname_r_chk F
+ __tzname D 0x8
+ __uflow F
+ __underflow F
+ __unorddf2 F
+ __unordsf2 F
+ __uselocale F
+ __vasprintf_chk F
+ __vdprintf_chk F
+ __vfork F
+ __vfprintf_chk F
+ __vfscanf F
+ __vfwprintf_chk F
+ __vprintf_chk F
+ __vsnprintf F
+ __vsnprintf_chk F
+ __vsprintf_chk F
+ __vsscanf F
+ __vswprintf_chk F
+ __vsyslog_chk F
+ __vwprintf_chk F
+ __wait F
+ __waitpid F
+ __wcpcpy_chk F
+ __wcpncpy_chk F
+ __wcrtomb_chk F
+ __wcscasecmp_l F
+ __wcscat_chk F
+ __wcscoll_l F
+ __wcscpy_chk F
+ __wcsftime_l F
+ __wcsncasecmp_l F
+ __wcsncat_chk F
+ __wcsncpy_chk F
+ __wcsnrtombs_chk F
+ __wcsrtombs_chk F
+ __wcstod_internal F
+ __wcstod_l F
+ __wcstof_internal F
+ __wcstof_l F
+ __wcstol_internal F
+ __wcstol_l F
+ __wcstold_internal F
+ __wcstold_l F
+ __wcstoll_internal F
+ __wcstoll_l F
+ __wcstombs_chk F
+ __wcstoul_internal F
+ __wcstoul_l F
+ __wcstoull_internal F
+ __wcstoull_l F
+ __wcsxfrm_l F
+ __wctomb_chk F
+ __wctrans_l F
+ __wctype_l F
+ __wmemcpy_chk F
+ __wmemmove_chk F
+ __wmempcpy_chk F
+ __wmemset_chk F
+ __woverflow F
+ __wprintf_chk F
+ __write F
+ __wuflow F
+ __wunderflow F
+ __xmknod F
+ __xmknodat F
+ __xpg_basename F
+ __xpg_sigpause F
+ __xpg_strerror_r F
+ __xstat F
+ __xstat64 F
+ _authenticate F
+ _dl_mcount_wrapper F
+ _dl_mcount_wrapper_check F
+ _environ D 0x4
+ _exit F
+ _flush_cache F
+ _flushlbf F
+ _libc_intl_domainname D 0x5
+ _longjmp F
+ _mcleanup F
+ _mcount F
+ _nl_default_dirname D 0x12
+ _nl_domain_bindings D 0x4
+ _nl_msg_cat_cntr D 0x4
+ _null_auth D 0xc
+ _obstack_allocated_p F
+ _obstack_begin F
+ _obstack_begin_1 F
+ _obstack_free F
+ _obstack_memory_used F
+ _obstack_newchunk F
+ _res D 0x200
+ _res_hconf D 0x30
+ _rpc_dtablesize F
+ _seterr_reply F
+ _setjmp F
+ _sys_errlist D 0x21c
+ _sys_nerr D 0x4
+ _sys_siglist D 0x104
+ _tolower F
+ _toupper F
+ a64l F
+ abort F
+ abs F
+ accept F
+ accept4 F
+ access F
+ acct F
+ addmntent F
+ addseverity F
+ adjtime F
+ adjtimex F
+ advance F
+ alarm F
+ aligned_alloc F
+ alphasort F
+ alphasort64 F
+ argp_err_exit_status D 0x4
+ argp_error F
+ argp_failure F
+ argp_help F
+ argp_parse F
+ argp_program_bug_address D 0x4
+ argp_program_version D 0x4
+ argp_program_version_hook D 0x4
+ argp_state_help F
+ argp_usage F
+ argz_add F
+ argz_add_sep F
+ argz_append F
+ argz_count F
+ argz_create F
+ argz_create_sep F
+ argz_delete F
+ argz_extract F
+ argz_insert F
+ argz_next F
+ argz_replace F
+ argz_stringify F
+ asctime F
+ asctime_r F
+ asprintf F
+ atof F
+ atoi F
+ atol F
+ atoll F
+ authdes_create F
+ authdes_getucred F
+ authdes_pk_create F
+ authnone_create F
+ authunix_create F
+ authunix_create_default F
+ backtrace F
+ backtrace_symbols F
+ backtrace_symbols_fd F
+ basename F
+ bcmp F
+ bcopy F
+ bdflush F
+ bind F
+ bind_textdomain_codeset F
+ bindresvport F
+ bindtextdomain F
+ brk F
+ bsd_signal F
+ bsearch F
+ btowc F
+ bzero F
+ c16rtomb F
+ c32rtomb F
+ cacheflush F
+ calloc F
+ callrpc F
+ canonicalize_file_name F
+ capget F
+ capset F
+ catclose F
+ catgets F
+ catopen F
+ cbc_crypt F
+ cfgetispeed F
+ cfgetospeed F
+ cfmakeraw F
+ cfree F
+ cfsetispeed F
+ cfsetospeed F
+ cfsetspeed F
+ chdir F
+ chflags F
+ chmod F
+ chown F
+ chroot F
+ clearenv F
+ clearerr F
+ clearerr_unlocked F
+ clnt_broadcast F
+ clnt_create F
+ clnt_pcreateerror F
+ clnt_perrno F
+ clnt_perror F
+ clnt_spcreateerror F
+ clnt_sperrno F
+ clnt_sperror F
+ clntraw_create F
+ clnttcp_create F
+ clntudp_bufcreate F
+ clntudp_create F
+ clntunix_create F
+ clock F
+ clock_adjtime F
+ clock_getcpuclockid F
+ clock_getres F
+ clock_gettime F
+ clock_nanosleep F
+ clock_settime F
+ clone F
+ close F
+ closedir F
+ closelog F
+ confstr F
+ connect F
+ copysign F
+ copysignf F
+ copysignl F
+ creat F
+ creat64 F
+ create_module F
+ ctermid F
+ ctime F
+ ctime_r F
+ cuserid F
+ daemon F
+ daylight D 0x4
+ dcgettext F
+ dcngettext F
+ delete_module F
+ des_setparity F
+ dgettext F
+ difftime F
+ dirfd F
+ dirname F
+ div F
+ dl_iterate_phdr F
+ dngettext F
+ dprintf F
+ drand48 F
+ drand48_r F
+ dup F
+ dup2 F
+ dup3 F
+ duplocale F
+ dysize F
+ eaccess F
+ ecb_crypt F
+ ecvt F
+ ecvt_r F
+ endaliasent F
+ endfsent F
+ endgrent F
+ endhostent F
+ endmntent F
+ endnetent F
+ endnetgrent F
+ endprotoent F
+ endpwent F
+ endrpcent F
+ endservent F
+ endsgent F
+ endspent F
+ endttyent F
+ endusershell F
+ endutent F
+ endutxent F
+ environ D 0x4
+ envz_add F
+ envz_entry F
+ envz_get F
+ envz_merge F
+ envz_remove F
+ envz_strip F
+ epoll_create F
+ epoll_create1 F
+ epoll_ctl F
+ epoll_pwait F
+ epoll_wait F
+ erand48 F
+ erand48_r F
+ err F
+ error F
+ error_at_line F
+ error_message_count D 0x4
+ error_one_per_line D 0x4
+ error_print_progname D 0x4
+ errx F
+ ether_aton F
+ ether_aton_r F
+ ether_hostton F
+ ether_line F
+ ether_ntoa F
+ ether_ntoa_r F
+ ether_ntohost F
+ euidaccess F
+ eventfd F
+ eventfd_read F
+ eventfd_write F
+ execl F
+ execle F
+ execlp F
+ execv F
+ execve F
+ execvp F
+ execvpe F
+ exit F
+ faccessat F
+ fallocate F
+ fallocate64 F
+ fanotify_init F
+ fanotify_mark F
+ fattach F
+ fchdir F
+ fchflags F
+ fchmod F
+ fchmodat F
+ fchown F
+ fchownat F
+ fclose F
+ fcloseall F
+ fcntl F
+ fcvt F
+ fcvt_r F
+ fdatasync F
+ fdetach F
+ fdopen F
+ fdopendir F
+ feof F
+ feof_unlocked F
+ ferror F
+ ferror_unlocked F
+ fexecve F
+ fflush F
+ fflush_unlocked F
+ ffs F
+ ffsl F
+ ffsll F
+ fgetc F
+ fgetc_unlocked F
+ fgetgrent F
+ fgetgrent_r F
+ fgetpos F
+ fgetpos64 F
+ fgetpwent F
+ fgetpwent_r F
+ fgets F
+ fgets_unlocked F
+ fgetsgent F
+ fgetsgent_r F
+ fgetspent F
+ fgetspent_r F
+ fgetwc F
+ fgetwc_unlocked F
+ fgetws F
+ fgetws_unlocked F
+ fgetxattr F
+ fileno F
+ fileno_unlocked F
+ finite F
+ finitef F
+ finitel F
+ flistxattr F
+ flock F
+ flockfile F
+ fmemopen F
+ fmtmsg F
+ fnmatch F
+ fopen F
+ fopen64 F
+ fopencookie F
+ fork F
+ fpathconf F
+ fprintf F
+ fputc F
+ fputc_unlocked F
+ fputs F
+ fputs_unlocked F
+ fputwc F
+ fputwc_unlocked F
+ fputws F
+ fputws_unlocked F
+ fread F
+ fread_unlocked F
+ free F
+ freeaddrinfo F
+ freeifaddrs F
+ freelocale F
+ fremovexattr F
+ freopen F
+ freopen64 F
+ frexp F
+ frexpf F
+ frexpl F
+ fscanf F
+ fseek F
+ fseeko F
+ fseeko64 F
+ fsetpos F
+ fsetpos64 F
+ fsetxattr F
+ fstatfs F
+ fstatfs64 F
+ fstatvfs F
+ fstatvfs64 F
+ fsync F
+ ftell F
+ ftello F
+ ftello64 F
+ ftime F
+ ftok F
+ ftruncate F
+ ftruncate64 F
+ ftrylockfile F
+ fts_children F
+ fts_close F
+ fts_open F
+ fts_read F
+ fts_set F
+ ftw F
+ ftw64 F
+ funlockfile F
+ futimens F
+ futimes F
+ futimesat F
+ fwide F
+ fwprintf F
+ fwrite F
+ fwrite_unlocked F
+ fwscanf F
+ gai_strerror F
+ gcvt F
+ get_avphys_pages F
+ get_current_dir_name F
+ get_kernel_syms F
+ get_myaddress F
+ get_nprocs F
+ get_nprocs_conf F
+ get_phys_pages F
+ getaddrinfo F
+ getaliasbyname F
+ getaliasbyname_r F
+ getaliasent F
+ getaliasent_r F
+ getauxval F
+ getc F
+ getc_unlocked F
+ getchar F
+ getchar_unlocked F
+ getcontext F
+ getcwd F
+ getdate F
+ getdate_err D 0x4
+ getdate_r F
+ getdelim F
+ getdirentries F
+ getdirentries64 F
+ getdomainname F
+ getdtablesize F
+ getegid F
+ getenv F
+ geteuid F
+ getfsent F
+ getfsfile F
+ getfsspec F
+ getgid F
+ getgrent F
+ getgrent_r F
+ getgrgid F
+ getgrgid_r F
+ getgrnam F
+ getgrnam_r F
+ getgrouplist F
+ getgroups F
+ gethostbyaddr F
+ gethostbyaddr_r F
+ gethostbyname F
+ gethostbyname2 F
+ gethostbyname2_r F
+ gethostbyname_r F
+ gethostent F
+ gethostent_r F
+ gethostid F
+ gethostname F
+ getifaddrs F
+ getipv4sourcefilter F
+ getitimer F
+ getline F
+ getloadavg F
+ getlogin F
+ getlogin_r F
+ getmntent F
+ getmntent_r F
+ getmsg F
+ getnameinfo F
+ getnetbyaddr F
+ getnetbyaddr_r F
+ getnetbyname F
+ getnetbyname_r F
+ getnetent F
+ getnetent_r F
+ getnetgrent F
+ getnetgrent_r F
+ getnetname F
+ getopt F
+ getopt_long F
+ getopt_long_only F
+ getpagesize F
+ getpass F
+ getpeername F
+ getpgid F
+ getpgrp F
+ getpid F
+ getpmsg F
+ getppid F
+ getpriority F
+ getprotobyname F
+ getprotobyname_r F
+ getprotobynumber F
+ getprotobynumber_r F
+ getprotoent F
+ getprotoent_r F
+ getpt F
+ getpublickey F
+ getpw F
+ getpwent F
+ getpwent_r F
+ getpwnam F
+ getpwnam_r F
+ getpwuid F
+ getpwuid_r F
+ getresgid F
+ getresuid F
+ getrlimit F
+ getrlimit64 F
+ getrpcbyname F
+ getrpcbyname_r F
+ getrpcbynumber F
+ getrpcbynumber_r F
+ getrpcent F
+ getrpcent_r F
+ getrpcport F
+ getrusage F
+ gets F
+ getsecretkey F
+ getservbyname F
+ getservbyname_r F
+ getservbyport F
+ getservbyport_r F
+ getservent F
+ getservent_r F
+ getsgent F
+ getsgent_r F
+ getsgnam F
+ getsgnam_r F
+ getsid F
+ getsockname F
+ getsockopt F
+ getsourcefilter F
+ getspent F
+ getspent_r F
+ getspnam F
+ getspnam_r F
+ getsubopt F
+ gettext F
+ gettimeofday F
+ getttyent F
+ getttynam F
+ getuid F
+ getusershell F
+ getutent F
+ getutent_r F
+ getutid F
+ getutid_r F
+ getutline F
+ getutline_r F
+ getutmp F
+ getutmpx F
+ getutxent F
+ getutxid F
+ getutxline F
+ getw F
+ getwc F
+ getwc_unlocked F
+ getwchar F
+ getwchar_unlocked F
+ getwd F
+ getxattr F
+ glob F
+ glob64 F
+ glob_pattern_p F
+ globfree F
+ globfree64 F
+ gmtime F
+ gmtime_r F
+ gnu_dev_major F
+ gnu_dev_makedev F
+ gnu_dev_minor F
+ gnu_get_libc_release F
+ gnu_get_libc_version F
+ grantpt F
+ group_member F
+ gsignal F
+ gtty F
+ h_errlist D 0x14
+ h_nerr D 0x4
+ hasmntopt F
+ hcreate F
+ hcreate_r F
+ hdestroy F
+ hdestroy_r F
+ herror F
+ host2netname F
+ hsearch F
+ hsearch_r F
+ hstrerror F
+ htonl F
+ htons F
+ iconv F
+ iconv_close F
+ iconv_open F
+ if_freenameindex F
+ if_indextoname F
+ if_nameindex F
+ if_nametoindex F
+ imaxabs F
+ imaxdiv F
+ in6addr_any D 0x10
+ in6addr_loopback D 0x10
+ index F
+ inet6_opt_append F
+ inet6_opt_find F
+ inet6_opt_finish F
+ inet6_opt_get_val F
+ inet6_opt_init F
+ inet6_opt_next F
+ inet6_opt_set_val F
+ inet6_option_alloc F
+ inet6_option_append F
+ inet6_option_find F
+ inet6_option_init F
+ inet6_option_next F
+ inet6_option_space F
+ inet6_rth_add F
+ inet6_rth_getaddr F
+ inet6_rth_init F
+ inet6_rth_reverse F
+ inet6_rth_segments F
+ inet6_rth_space F
+ inet_addr F
+ inet_aton F
+ inet_lnaof F
+ inet_makeaddr F
+ inet_netof F
+ inet_network F
+ inet_nsap_addr F
+ inet_nsap_ntoa F
+ inet_ntoa F
+ inet_ntop F
+ inet_pton F
+ init_module F
+ initgroups F
+ initstate F
+ initstate_r F
+ innetgr F
+ inotify_add_watch F
+ inotify_init F
+ inotify_init1 F
+ inotify_rm_watch F
+ insque F
+ ioctl F
+ iruserok F
+ iruserok_af F
+ isalnum F
+ isalnum_l F
+ isalpha F
+ isalpha_l F
+ isascii F
+ isastream F
+ isatty F
+ isblank F
+ isblank_l F
+ iscntrl F
+ iscntrl_l F
+ isctype F
+ isdigit F
+ isdigit_l F
+ isfdtype F
+ isgraph F
+ isgraph_l F
+ isinf F
+ isinff F
+ isinfl F
+ islower F
+ islower_l F
+ isnan F
+ isnanf F
+ isnanl F
+ isprint F
+ isprint_l F
+ ispunct F
+ ispunct_l F
+ isspace F
+ isspace_l F
+ isupper F
+ isupper_l F
+ iswalnum F
+ iswalnum_l F
+ iswalpha F
+ iswalpha_l F
+ iswblank F
+ iswblank_l F
+ iswcntrl F
+ iswcntrl_l F
+ iswctype F
+ iswctype_l F
+ iswdigit F
+ iswdigit_l F
+ iswgraph F
+ iswgraph_l F
+ iswlower F
+ iswlower_l F
+ iswprint F
+ iswprint_l F
+ iswpunct F
+ iswpunct_l F
+ iswspace F
+ iswspace_l F
+ iswupper F
+ iswupper_l F
+ iswxdigit F
+ iswxdigit_l F
+ isxdigit F
+ isxdigit_l F
+ jrand48 F
+ jrand48_r F
+ key_decryptsession F
+ key_decryptsession_pk F
+ key_encryptsession F
+ key_encryptsession_pk F
+ key_gendes F
+ key_get_conv F
+ key_secretkey_is_set F
+ key_setnet F
+ key_setsecret F
+ kill F
+ killpg F
+ klogctl F
+ l64a F
+ labs F
+ lchmod F
+ lchown F
+ lckpwdf F
+ lcong48 F
+ lcong48_r F
+ ldexp F
+ ldexpf F
+ ldexpl F
+ ldiv F
+ lfind F
+ lgetxattr F
+ link F
+ linkat F
+ listen F
+ listxattr F
+ llabs F
+ lldiv F
+ llistxattr F
+ llseek F
+ loc1 D 0x4
+ loc2 D 0x4
+ localeconv F
+ localtime F
+ localtime_r F
+ lockf F
+ lockf64 F
+ locs D 0x4
+ longjmp F
+ lrand48 F
+ lrand48_r F
+ lremovexattr F
+ lsearch F
+ lseek F
+ lseek64 F
+ lsetxattr F
+ lutimes F
+ madvise F
+ makecontext F
+ mallinfo F
+ malloc F
+ malloc_get_state F
+ malloc_info F
+ malloc_set_state F
+ malloc_stats F
+ malloc_trim F
+ malloc_usable_size F
+ mallopt F
+ mallwatch D 0x4
+ mblen F
+ mbrlen F
+ mbrtoc16 F
+ mbrtoc32 F
+ mbrtowc F
+ mbsinit F
+ mbsnrtowcs F
+ mbsrtowcs F
+ mbstowcs F
+ mbtowc F
+ mcheck F
+ mcheck_check_all F
+ mcheck_pedantic F
+ memalign F
+ memccpy F
+ memchr F
+ memcmp F
+ memcpy F
+ memfrob F
+ memmem F
+ memmove F
+ mempcpy F
+ memrchr F
+ memset F
+ mincore F
+ mkdir F
+ mkdirat F
+ mkdtemp F
+ mkfifo F
+ mkfifoat F
+ mkostemp F
+ mkostemp64 F
+ mkostemps F
+ mkostemps64 F
+ mkstemp F
+ mkstemp64 F
+ mkstemps F
+ mkstemps64 F
+ mktemp F
+ mktime F
+ mlock F
+ mlockall F
+ mmap F
+ mmap64 F
+ modf F
+ modff F
+ modfl F
+ moncontrol F
+ monstartup F
+ mount F
+ mprobe F
+ mprotect F
+ mrand48 F
+ mrand48_r F
+ mremap F
+ msgctl F
+ msgget F
+ msgrcv F
+ msgsnd F
+ msync F
+ mtrace F
+ munlock F
+ munlockall F
+ munmap F
+ muntrace F
+ name_to_handle_at F
+ nanosleep F
+ netname2host F
+ netname2user F
+ newlocale F
+ nfsservctl F
+ nftw F
+ nftw64 F
+ ngettext F
+ nice F
+ nl_langinfo F
+ nl_langinfo_l F
+ nrand48 F
+ nrand48_r F
+ ntohl F
+ ntohs F
+ ntp_adjtime F
+ ntp_gettime F
+ ntp_gettimex F
+ obstack_alloc_failed_handler D 0x4
+ obstack_exit_failure D 0x4
+ obstack_free F
+ obstack_printf F
+ obstack_vprintf F
+ on_exit F
+ open F
+ open64 F
+ open_by_handle_at F
+ open_memstream F
+ open_wmemstream F
+ openat F
+ openat64 F
+ opendir F
+ openlog F
+ optarg D 0x4
+ opterr D 0x4
+ optind D 0x4
+ optopt D 0x4
+ parse_printf_format F
+ passwd2des F
+ pathconf F
+ pause F
+ pclose F
+ perror F
+ personality F
+ pipe F
+ pipe2 F
+ pivot_root F
+ pmap_getmaps F
+ pmap_getport F
+ pmap_rmtcall F
+ pmap_set F
+ pmap_unset F
+ poll F
+ popen F
+ posix_fadvise F
+ posix_fadvise64 F
+ posix_fallocate F
+ posix_fallocate64 F
+ posix_madvise F
+ posix_memalign F
+ posix_openpt F
+ posix_spawn F
+ posix_spawn_file_actions_addclose F
+ posix_spawn_file_actions_adddup2 F
+ posix_spawn_file_actions_addopen F
+ posix_spawn_file_actions_destroy F
+ posix_spawn_file_actions_init F
+ posix_spawnattr_destroy F
+ posix_spawnattr_getflags F
+ posix_spawnattr_getpgroup F
+ posix_spawnattr_getschedparam F
+ posix_spawnattr_getschedpolicy F
+ posix_spawnattr_getsigdefault F
+ posix_spawnattr_getsigmask F
+ posix_spawnattr_init F
+ posix_spawnattr_setflags F
+ posix_spawnattr_setpgroup F
+ posix_spawnattr_setschedparam F
+ posix_spawnattr_setschedpolicy F
+ posix_spawnattr_setsigdefault F
+ posix_spawnattr_setsigmask F
+ posix_spawnp F
+ ppoll F
+ prctl F
+ pread F
+ pread64 F
+ preadv F
+ preadv64 F
+ printf F
+ printf_size F
+ printf_size_info F
+ prlimit F
+ prlimit64 F
+ process_vm_readv F
+ process_vm_writev F
+ profil F
+ program_invocation_name D 0x4
+ program_invocation_short_name D 0x4
+ pselect F
+ psiginfo F
+ psignal F
+ pthread_attr_destroy F
+ pthread_attr_getdetachstate F
+ pthread_attr_getinheritsched F
+ pthread_attr_getschedparam F
+ pthread_attr_getschedpolicy F
+ pthread_attr_getscope F
+ pthread_attr_init F
+ pthread_attr_setdetachstate F
+ pthread_attr_setinheritsched F
+ pthread_attr_setschedparam F
+ pthread_attr_setschedpolicy F
+ pthread_attr_setscope F
+ pthread_cond_broadcast F
+ pthread_cond_destroy F
+ pthread_cond_init F
+ pthread_cond_signal F
+ pthread_cond_timedwait F
+ pthread_cond_wait F
+ pthread_condattr_destroy F
+ pthread_condattr_init F
+ pthread_equal F
+ pthread_exit F
+ pthread_getschedparam F
+ pthread_mutex_destroy F
+ pthread_mutex_init F
+ pthread_mutex_lock F
+ pthread_mutex_unlock F
+ pthread_self F
+ pthread_setcancelstate F
+ pthread_setcanceltype F
+ pthread_setschedparam F
+ ptrace F
+ ptsname F
+ ptsname_r F
+ putc F
+ putc_unlocked F
+ putchar F
+ putchar_unlocked F
+ putenv F
+ putgrent F
+ putmsg F
+ putpmsg F
+ putpwent F
+ puts F
+ putsgent F
+ putspent F
+ pututline F
+ pututxline F
+ putw F
+ putwc F
+ putwc_unlocked F
+ putwchar F
+ putwchar_unlocked F
+ pvalloc F
+ pwrite F
+ pwrite64 F
+ pwritev F
+ pwritev64 F
+ qecvt F
+ qecvt_r F
+ qfcvt F
+ qfcvt_r F
+ qgcvt F
+ qsort F
+ qsort_r F
+ query_module F
+ quick_exit F
+ quotactl F
+ raise F
+ rand F
+ rand_r F
+ random F
+ random_r F
+ rawmemchr F
+ rcmd F
+ rcmd_af F
+ re_comp F
+ re_compile_fastmap F
+ re_compile_pattern F
+ re_exec F
+ re_match F
+ re_match_2 F
+ re_search F
+ re_search_2 F
+ re_set_registers F
+ re_set_syntax F
+ re_syntax_options D 0x4
+ read F
+ readahead F
+ readdir F
+ readdir64 F
+ readdir64_r F
+ readdir_r F
+ readlink F
+ readlinkat F
+ readv F
+ realloc F
+ realpath F
+ reboot F
+ recv F
+ recvfrom F
+ recvmmsg F
+ recvmsg F
+ regcomp F
+ regerror F
+ regexec F
+ regfree F
+ register_printf_function F
+ register_printf_modifier F
+ register_printf_specifier F
+ register_printf_type F
+ registerrpc F
+ remap_file_pages F
+ remove F
+ removexattr F
+ remque F
+ rename F
+ renameat F
+ revoke F
+ rewind F
+ rewinddir F
+ rexec F
+ rexec_af F
+ rexecoptions D 0x4
+ rindex F
+ rmdir F
+ rpc_createerr D 0x10
+ rpmatch F
+ rresvport F
+ rresvport_af F
+ rtime F
+ ruserok F
+ ruserok_af F
+ ruserpass F
+ sbrk F
+ scalbn F
+ scalbnf F
+ scalbnl F
+ scandir F
+ scandir64 F
+ scandirat F
+ scandirat64 F
+ scanf F
+ sched_get_priority_max F
+ sched_get_priority_min F
+ sched_getaffinity F
+ sched_getcpu F
+ sched_getparam F
+ sched_getscheduler F
+ sched_rr_get_interval F
+ sched_setaffinity F
+ sched_setparam F
+ sched_setscheduler F
+ sched_yield F
+ secure_getenv F
+ seed48 F
+ seed48_r F
+ seekdir F
+ select F
+ semctl F
+ semget F
+ semop F
+ semtimedop F
+ send F
+ sendfile F
+ sendfile64 F
+ sendmmsg F
+ sendmsg F
+ sendto F
+ setaliasent F
+ setbuf F
+ setbuffer F
+ setcontext F
+ setdomainname F
+ setegid F
+ setenv F
+ seteuid F
+ setfsent F
+ setfsgid F
+ setfsuid F
+ setgid F
+ setgrent F
+ setgroups F
+ sethostent F
+ sethostid F
+ sethostname F
+ setipv4sourcefilter F
+ setitimer F
+ setjmp F
+ setlinebuf F
+ setlocale F
+ setlogin F
+ setlogmask F
+ setmntent F
+ setnetent F
+ setnetgrent F
+ setns F
+ setpgid F
+ setpgrp F
+ setpriority F
+ setprotoent F
+ setpwent F
+ setregid F
+ setresgid F
+ setresuid F
+ setreuid F
+ setrlimit F
+ setrlimit64 F
+ setrpcent F
+ setservent F
+ setsgent F
+ setsid F
+ setsockopt F
+ setsourcefilter F
+ setspent F
+ setstate F
+ setstate_r F
+ settimeofday F
+ setttyent F
+ setuid F
+ setusershell F
+ setutent F
+ setutxent F
+ setvbuf F
+ setxattr F
+ sgetsgent F
+ sgetsgent_r F
+ sgetspent F
+ sgetspent_r F
+ shmat F
+ shmctl F
+ shmdt F
+ shmget F
+ shutdown F
+ sigaction F
+ sigaddset F
+ sigaltstack F
+ sigandset F
+ sigblock F
+ sigdelset F
+ sigemptyset F
+ sigfillset F
+ siggetmask F
+ sighold F
+ sigignore F
+ siginterrupt F
+ sigisemptyset F
+ sigismember F
+ siglongjmp F
+ signal F
+ signalfd F
+ sigorset F
+ sigpause F
+ sigpending F
+ sigprocmask F
+ sigqueue F
+ sigrelse F
+ sigreturn F
+ sigset F
+ sigsetmask F
+ sigstack F
+ sigsuspend F
+ sigtimedwait F
+ sigwait F
+ sigwaitinfo F
+ sleep F
+ snprintf F
+ sockatmark F
+ socket F
+ socketpair F
+ splice F
+ sprintf F
+ sprofil F
+ srand F
+ srand48 F
+ srand48_r F
+ srandom F
+ srandom_r F
+ sscanf F
+ ssignal F
+ sstk F
+ statfs F
+ statfs64 F
+ statvfs F
+ statvfs64 F
+ stderr D 0x4
+ stdin D 0x4
+ stdout D 0x4
+ step F
+ stime F
+ stpcpy F
+ stpncpy F
+ strcasecmp F
+ strcasecmp_l F
+ strcasestr F
+ strcat F
+ strchr F
+ strchrnul F
+ strcmp F
+ strcoll F
+ strcoll_l F
+ strcpy F
+ strcspn F
+ strdup F
+ strerror F
+ strerror_l F
+ strerror_r F
+ strfmon F
+ strfmon_l F
+ strfry F
+ strftime F
+ strftime_l F
+ strlen F
+ strncasecmp F
+ strncasecmp_l F
+ strncat F
+ strncmp F
+ strncpy F
+ strndup F
+ strnlen F
+ strpbrk F
+ strptime F
+ strptime_l F
+ strrchr F
+ strsep F
+ strsignal F
+ strspn F
+ strstr F
+ strtod F
+ strtod_l F
+ strtof F
+ strtof_l F
+ strtoimax F
+ strtok F
+ strtok_r F
+ strtol F
+ strtol_l F
+ strtold F
+ strtold_l F
+ strtoll F
+ strtoll_l F
+ strtoq F
+ strtoul F
+ strtoul_l F
+ strtoull F
+ strtoull_l F
+ strtoumax F
+ strtouq F
+ strverscmp F
+ strxfrm F
+ strxfrm_l F
+ stty F
+ svc_exit F
+ svc_fdset D 0x80
+ svc_getreq F
+ svc_getreq_common F
+ svc_getreq_poll F
+ svc_getreqset F
+ svc_max_pollfd D 0x4
+ svc_pollfd D 0x4
+ svc_register F
+ svc_run F
+ svc_sendreply F
+ svc_unregister F
+ svcauthdes_stats D 0xc
+ svcerr_auth F
+ svcerr_decode F
+ svcerr_noproc F
+ svcerr_noprog F
+ svcerr_progvers F
+ svcerr_systemerr F
+ svcerr_weakauth F
+ svcfd_create F
+ svcraw_create F
+ svctcp_create F
+ svcudp_bufcreate F
+ svcudp_create F
+ svcudp_enablecache F
+ svcunix_create F
+ svcunixfd_create F
+ swab F
+ swapcontext F
+ swapoff F
+ swapon F
+ swprintf F
+ swscanf F
+ symlink F
+ symlinkat F
+ sync F
+ sync_file_range F
+ syncfs F
+ sys_errlist D 0x21c
+ sys_nerr D 0x4
+ sys_sigabbrev D 0x104
+ sys_siglist D 0x104
+ syscall F
+ sysconf F
+ sysctl F
+ sysinfo F
+ syslog F
+ system F
+ sysv_signal F
+ tcdrain F
+ tcflow F
+ tcflush F
+ tcgetattr F
+ tcgetpgrp F
+ tcgetsid F
+ tcsendbreak F
+ tcsetattr F
+ tcsetpgrp F
+ tdelete F
+ tdestroy F
+ tee F
+ telldir F
+ tempnam F
+ textdomain F
+ tfind F
+ time F
+ timegm F
+ timelocal F
+ timerfd_create F
+ timerfd_gettime F
+ timerfd_settime F
+ times F
+ timespec_get F
+ timezone D 0x4
+ tmpfile F
+ tmpfile64 F
+ tmpnam F
+ tmpnam_r F
+ toascii F
+ tolower F
+ tolower_l F
+ toupper F
+ toupper_l F
+ towctrans F
+ towctrans_l F
+ towlower F
+ towlower_l F
+ towupper F
+ towupper_l F
+ tr_break F
+ truncate F
+ truncate64 F
+ tsearch F
+ ttyname F
+ ttyname_r F
+ ttyslot F
+ twalk F
+ tzname D 0x8
+ tzset F
+ ualarm F
+ ulckpwdf F
+ ulimit F
+ umask F
+ umount F
+ umount2 F
+ uname F
+ ungetc F
+ ungetwc F
+ unlink F
+ unlinkat F
+ unlockpt F
+ unsetenv F
+ unshare F
+ updwtmp F
+ updwtmpx F
+ uselib F
+ uselocale F
+ user2netname F
+ usleep F
+ ustat F
+ utime F
+ utimensat F
+ utimes F
+ utmpname F
+ utmpxname F
+ valloc F
+ vasprintf F
+ vdprintf F
+ verr F
+ verrx F
+ versionsort F
+ versionsort64 F
+ vfork F
+ vfprintf F
+ vfscanf F
+ vfwprintf F
+ vfwscanf F
+ vhangup F
+ vlimit F
+ vmsplice F
+ vprintf F
+ vscanf F
+ vsnprintf F
+ vsprintf F
+ vsscanf F
+ vswprintf F
+ vswscanf F
+ vsyslog F
+ vtimes F
+ vwarn F
+ vwarnx F
+ vwprintf F
+ vwscanf F
+ wait F
+ wait3 F
+ wait4 F
+ waitid F
+ waitpid F
+ warn F
+ warnx F
+ wcpcpy F
+ wcpncpy F
+ wcrtomb F
+ wcscasecmp F
+ wcscasecmp_l F
+ wcscat F
+ wcschr F
+ wcschrnul F
+ wcscmp F
+ wcscoll F
+ wcscoll_l F
+ wcscpy F
+ wcscspn F
+ wcsdup F
+ wcsftime F
+ wcsftime_l F
+ wcslen F
+ wcsncasecmp F
+ wcsncasecmp_l F
+ wcsncat F
+ wcsncmp F
+ wcsncpy F
+ wcsnlen F
+ wcsnrtombs F
+ wcspbrk F
+ wcsrchr F
+ wcsrtombs F
+ wcsspn F
+ wcsstr F
+ wcstod F
+ wcstod_l F
+ wcstof F
+ wcstof_l F
+ wcstoimax F
+ wcstok F
+ wcstol F
+ wcstol_l F
+ wcstold F
+ wcstold_l F
+ wcstoll F
+ wcstoll_l F
+ wcstombs F
+ wcstoq F
+ wcstoul F
+ wcstoul_l F
+ wcstoull F
+ wcstoull_l F
+ wcstoumax F
+ wcstouq F
+ wcswcs F
+ wcswidth F
+ wcsxfrm F
+ wcsxfrm_l F
+ wctob F
+ wctomb F
+ wctrans F
+ wctrans_l F
+ wctype F
+ wctype_l F
+ wcwidth F
+ wmemchr F
+ wmemcmp F
+ wmemcpy F
+ wmemmove F
+ wmempcpy F
+ wmemset F
+ wordexp F
+ wordfree F
+ wprintf F
+ write F
+ writev F
+ wscanf F
+ xdecrypt F
+ xdr_accepted_reply F
+ xdr_array F
+ xdr_authdes_cred F
+ xdr_authdes_verf F
+ xdr_authunix_parms F
+ xdr_bool F
+ xdr_bytes F
+ xdr_callhdr F
+ xdr_callmsg F
+ xdr_char F
+ xdr_cryptkeyarg F
+ xdr_cryptkeyarg2 F
+ xdr_cryptkeyres F
+ xdr_des_block F
+ xdr_double F
+ xdr_enum F
+ xdr_float F
+ xdr_free F
+ xdr_getcredres F
+ xdr_hyper F
+ xdr_int F
+ xdr_int16_t F
+ xdr_int32_t F
+ xdr_int64_t F
+ xdr_int8_t F
+ xdr_key_netstarg F
+ xdr_key_netstres F
+ xdr_keybuf F
+ xdr_keystatus F
+ xdr_long F
+ xdr_longlong_t F
+ xdr_netnamestr F
+ xdr_netobj F
+ xdr_opaque F
+ xdr_opaque_auth F
+ xdr_pmap F
+ xdr_pmaplist F
+ xdr_pointer F
+ xdr_quad_t F
+ xdr_reference F
+ xdr_rejected_reply F
+ xdr_replymsg F
+ xdr_rmtcall_args F
+ xdr_rmtcallres F
+ xdr_short F
+ xdr_sizeof F
+ xdr_string F
+ xdr_u_char F
+ xdr_u_hyper F
+ xdr_u_int F
+ xdr_u_long F
+ xdr_u_longlong_t F
+ xdr_u_quad_t F
+ xdr_u_short F
+ xdr_uint16_t F
+ xdr_uint32_t F
+ xdr_uint64_t F
+ xdr_uint8_t F
+ xdr_union F
+ xdr_unixcred F
+ xdr_vector F
+ xdr_void F
+ xdr_wrapstring F
+ xdrmem_create F
+ xdrrec_create F
+ xdrrec_endofrecord F
+ xdrrec_eof F
+ xdrrec_skiprecord F
+ xdrstdio_create F
+ xencrypt F
+ xprt_register F
+ xprt_unregister F
diff --git a/sysdeps/unix/sysv/linux/nios2/libcrypt.abilist b/sysdeps/unix/sysv/linux/nios2/libcrypt.abilist
new file mode 100644
index 0000000000..dd5a89c3e4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libcrypt.abilist
@@ -0,0 +1,9 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ crypt F
+ crypt_r F
+ encrypt F
+ encrypt_r F
+ fcrypt F
+ setkey F
+ setkey_r F
diff --git a/sysdeps/unix/sysv/linux/nios2/libdl.abilist b/sysdeps/unix/sysv/linux/nios2/libdl.abilist
new file mode 100644
index 0000000000..9220fec15c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libdl.abilist
@@ -0,0 +1,11 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ dladdr F
+ dladdr1 F
+ dlclose F
+ dlerror F
+ dlinfo F
+ dlmopen F
+ dlopen F
+ dlsym F
+ dlvsym F
diff --git a/sysdeps/unix/sysv/linux/nios2/libm.abilist b/sysdeps/unix/sysv/linux/nios2/libm.abilist
new file mode 100644
index 0000000000..3fcb2efc46
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libm.abilist
@@ -0,0 +1,370 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ _LIB_VERSION D 0x4
+ __acos_finite F
+ __acosf_finite F
+ __acosh_finite F
+ __acoshf_finite F
+ __asin_finite F
+ __asinf_finite F
+ __atan2_finite F
+ __atan2f_finite F
+ __atanh_finite F
+ __atanhf_finite F
+ __clog10 F
+ __clog10f F
+ __clog10l F
+ __cosh_finite F
+ __coshf_finite F
+ __exp10_finite F
+ __exp10f_finite F
+ __exp2_finite F
+ __exp2f_finite F
+ __exp_finite F
+ __expf_finite F
+ __finite F
+ __finitef F
+ __finitel F
+ __fmod_finite F
+ __fmodf_finite F
+ __fpclassify F
+ __fpclassifyf F
+ __gamma_r_finite F
+ __gammaf_r_finite F
+ __hypot_finite F
+ __hypotf_finite F
+ __issignaling F
+ __issignalingf F
+ __j0_finite F
+ __j0f_finite F
+ __j1_finite F
+ __j1f_finite F
+ __jn_finite F
+ __jnf_finite F
+ __lgamma_r_finite F
+ __lgammaf_r_finite F
+ __log10_finite F
+ __log10f_finite F
+ __log2_finite F
+ __log2f_finite F
+ __log_finite F
+ __logf_finite F
+ __pow_finite F
+ __powf_finite F
+ __remainder_finite F
+ __remainderf_finite F
+ __scalb_finite F
+ __scalbf_finite F
+ __signbit F
+ __signbitf F
+ __sinh_finite F
+ __sinhf_finite F
+ __sqrt_finite F
+ __sqrtf_finite F
+ __y0_finite F
+ __y0f_finite F
+ __y1_finite F
+ __y1f_finite F
+ __yn_finite F
+ __ynf_finite F
+ acos F
+ acosf F
+ acosh F
+ acoshf F
+ acoshl F
+ acosl F
+ asin F
+ asinf F
+ asinh F
+ asinhf F
+ asinhl F
+ asinl F
+ atan F
+ atan2 F
+ atan2f F
+ atan2l F
+ atanf F
+ atanh F
+ atanhf F
+ atanhl F
+ atanl F
+ cabs F
+ cabsf F
+ cabsl F
+ cacos F
+ cacosf F
+ cacosh F
+ cacoshf F
+ cacoshl F
+ cacosl F
+ carg F
+ cargf F
+ cargl F
+ casin F
+ casinf F
+ casinh F
+ casinhf F
+ casinhl F
+ casinl F
+ catan F
+ catanf F
+ catanh F
+ catanhf F
+ catanhl F
+ catanl F
+ cbrt F
+ cbrtf F
+ cbrtl F
+ ccos F
+ ccosf F
+ ccosh F
+ ccoshf F
+ ccoshl F
+ ccosl F
+ ceil F
+ ceilf F
+ ceill F
+ cexp F
+ cexpf F
+ cexpl F
+ cimag F
+ cimagf F
+ cimagl F
+ clog F
+ clog10 F
+ clog10f F
+ clog10l F
+ clogf F
+ clogl F
+ conj F
+ conjf F
+ conjl F
+ copysign F
+ copysignf F
+ copysignl F
+ cos F
+ cosf F
+ cosh F
+ coshf F
+ coshl F
+ cosl F
+ cpow F
+ cpowf F
+ cpowl F
+ cproj F
+ cprojf F
+ cprojl F
+ creal F
+ crealf F
+ creall F
+ csin F
+ csinf F
+ csinh F
+ csinhf F
+ csinhl F
+ csinl F
+ csqrt F
+ csqrtf F
+ csqrtl F
+ ctan F
+ ctanf F
+ ctanh F
+ ctanhf F
+ ctanhl F
+ ctanl F
+ drem F
+ dremf F
+ dreml F
+ erf F
+ erfc F
+ erfcf F
+ erfcl F
+ erff F
+ erfl F
+ exp F
+ exp10 F
+ exp10f F
+ exp10l F
+ exp2 F
+ exp2f F
+ exp2l F
+ expf F
+ expl F
+ expm1 F
+ expm1f F
+ expm1l F
+ fabs F
+ fabsf F
+ fabsl F
+ fdim F
+ fdimf F
+ fdiml F
+ feclearexcept F
+ fedisableexcept F
+ feenableexcept F
+ fegetenv F
+ fegetexcept F
+ fegetexceptflag F
+ fegetround F
+ feholdexcept F
+ feraiseexcept F
+ fesetenv F
+ fesetexceptflag F
+ fesetround F
+ fetestexcept F
+ feupdateenv F
+ finite F
+ finitef F
+ finitel F
+ floor F
+ floorf F
+ floorl F
+ fma F
+ fmaf F
+ fmal F
+ fmax F
+ fmaxf F
+ fmaxl F
+ fmin F
+ fminf F
+ fminl F
+ fmod F
+ fmodf F
+ fmodl F
+ frexp F
+ frexpf F
+ frexpl F
+ gamma F
+ gammaf F
+ gammal F
+ hypot F
+ hypotf F
+ hypotl F
+ ilogb F
+ ilogbf F
+ ilogbl F
+ j0 F
+ j0f F
+ j0l F
+ j1 F
+ j1f F
+ j1l F
+ jn F
+ jnf F
+ jnl F
+ ldexp F
+ ldexpf F
+ ldexpl F
+ lgamma F
+ lgamma_r F
+ lgammaf F
+ lgammaf_r F
+ lgammal F
+ lgammal_r F
+ llrint F
+ llrintf F
+ llrintl F
+ llround F
+ llroundf F
+ llroundl F
+ log F
+ log10 F
+ log10f F
+ log10l F
+ log1p F
+ log1pf F
+ log1pl F
+ log2 F
+ log2f F
+ log2l F
+ logb F
+ logbf F
+ logbl F
+ logf F
+ logl F
+ lrint F
+ lrintf F
+ lrintl F
+ lround F
+ lroundf F
+ lroundl F
+ matherr F
+ modf F
+ modff F
+ modfl F
+ nan F
+ nanf F
+ nanl F
+ nearbyint F
+ nearbyintf F
+ nearbyintl F
+ nextafter F
+ nextafterf F
+ nextafterl F
+ nexttoward F
+ nexttowardf F
+ nexttowardl F
+ pow F
+ pow10 F
+ pow10f F
+ pow10l F
+ powf F
+ powl F
+ remainder F
+ remainderf F
+ remainderl F
+ remquo F
+ remquof F
+ remquol F
+ rint F
+ rintf F
+ rintl F
+ round F
+ roundf F
+ roundl F
+ scalb F
+ scalbf F
+ scalbl F
+ scalbln F
+ scalblnf F
+ scalblnl F
+ scalbn F
+ scalbnf F
+ scalbnl F
+ signgam D 0x4
+ significand F
+ significandf F
+ significandl F
+ sin F
+ sincos F
+ sincosf F
+ sincosl F
+ sinf F
+ sinh F
+ sinhf F
+ sinhl F
+ sinl F
+ sqrt F
+ sqrtf F
+ sqrtl F
+ tan F
+ tanf F
+ tanh F
+ tanhf F
+ tanhl F
+ tanl F
+ tgamma F
+ tgammaf F
+ tgammal F
+ trunc F
+ truncf F
+ truncl F
+ y0 F
+ y0f F
+ y0l F
+ y1 F
+ y1f F
+ y1l F
+ yn F
+ ynf F
+ ynl F
diff --git a/sysdeps/unix/sysv/linux/nios2/libnsl.abilist b/sysdeps/unix/sysv/linux/nios2/libnsl.abilist
new file mode 100644
index 0000000000..7df8621637
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libnsl.abilist
@@ -0,0 +1,123 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ __free_fdresult F
+ __nis_default_access F
+ __nis_default_group F
+ __nis_default_owner F
+ __nis_default_ttl F
+ __nis_finddirectory F
+ __nis_hash F
+ __nisbind_connect F
+ __nisbind_create F
+ __nisbind_destroy F
+ __nisbind_next F
+ __yp_check F
+ nis_add F
+ nis_add_entry F
+ nis_addmember F
+ nis_checkpoint F
+ nis_clone_directory F
+ nis_clone_object F
+ nis_clone_result F
+ nis_creategroup F
+ nis_destroy_object F
+ nis_destroygroup F
+ nis_dir_cmp F
+ nis_domain_of F
+ nis_domain_of_r F
+ nis_first_entry F
+ nis_free_directory F
+ nis_free_object F
+ nis_free_request F
+ nis_freenames F
+ nis_freeresult F
+ nis_freeservlist F
+ nis_freetags F
+ nis_getnames F
+ nis_getservlist F
+ nis_ismember F
+ nis_leaf_of F
+ nis_leaf_of_r F
+ nis_lerror F
+ nis_list F
+ nis_local_directory F
+ nis_local_group F
+ nis_local_host F
+ nis_local_principal F
+ nis_lookup F
+ nis_mkdir F
+ nis_modify F
+ nis_modify_entry F
+ nis_name_of F
+ nis_name_of_r F
+ nis_next_entry F
+ nis_perror F
+ nis_ping F
+ nis_print_directory F
+ nis_print_entry F
+ nis_print_group F
+ nis_print_group_entry F
+ nis_print_link F
+ nis_print_object F
+ nis_print_result F
+ nis_print_rights F
+ nis_print_table F
+ nis_read_obj F
+ nis_remove F
+ nis_remove_entry F
+ nis_removemember F
+ nis_rmdir F
+ nis_servstate F
+ nis_sperrno F
+ nis_sperror F
+ nis_sperror_r F
+ nis_stats F
+ nis_verifygroup F
+ nis_write_obj F
+ readColdStartFile F
+ writeColdStartFile F
+ xdr_cback_data F
+ xdr_domainname F
+ xdr_keydat F
+ xdr_mapname F
+ xdr_obj_p F
+ xdr_peername F
+ xdr_valdat F
+ xdr_yp_buf F
+ xdr_ypall F
+ xdr_ypbind_binding F
+ xdr_ypbind_resp F
+ xdr_ypbind_resptype F
+ xdr_ypbind_setdom F
+ xdr_ypdelete_args F
+ xdr_ypmap_parms F
+ xdr_ypmaplist F
+ xdr_yppush_status F
+ xdr_yppushresp_xfr F
+ xdr_ypreq_key F
+ xdr_ypreq_nokey F
+ xdr_ypreq_xfr F
+ xdr_ypresp_all F
+ xdr_ypresp_key_val F
+ xdr_ypresp_maplist F
+ xdr_ypresp_master F
+ xdr_ypresp_order F
+ xdr_ypresp_val F
+ xdr_ypresp_xfr F
+ xdr_ypstat F
+ xdr_ypupdate_args F
+ xdr_ypxfrstat F
+ yp_all F
+ yp_bind F
+ yp_first F
+ yp_get_default_domain F
+ yp_maplist F
+ yp_master F
+ yp_match F
+ yp_next F
+ yp_order F
+ yp_unbind F
+ yp_update F
+ ypbinderr_string F
+ yperr_string F
+ ypprot_err F
diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
new file mode 100644
index 0000000000..ca203c7755
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
@@ -0,0 +1,224 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ _IO_flockfile F
+ _IO_ftrylockfile F
+ _IO_funlockfile F
+ __close F
+ __connect F
+ __errno_location F
+ __fcntl F
+ __fork F
+ __h_errno_location F
+ __libc_allocate_rtsig F
+ __libc_current_sigrtmax F
+ __libc_current_sigrtmin F
+ __lseek F
+ __nanosleep F
+ __open F
+ __open64 F
+ __pread64 F
+ __pthread_cleanup_routine F
+ __pthread_getspecific F
+ __pthread_key_create F
+ __pthread_mutex_destroy F
+ __pthread_mutex_init F
+ __pthread_mutex_lock F
+ __pthread_mutex_trylock F
+ __pthread_mutex_unlock F
+ __pthread_mutexattr_destroy F
+ __pthread_mutexattr_init F
+ __pthread_mutexattr_settype F
+ __pthread_once F
+ __pthread_register_cancel F
+ __pthread_register_cancel_defer F
+ __pthread_rwlock_destroy F
+ __pthread_rwlock_init F
+ __pthread_rwlock_rdlock F
+ __pthread_rwlock_tryrdlock F
+ __pthread_rwlock_trywrlock F
+ __pthread_rwlock_unlock F
+ __pthread_rwlock_wrlock F
+ __pthread_setspecific F
+ __pthread_unregister_cancel F
+ __pthread_unregister_cancel_restore F
+ __pthread_unwind_next F
+ __pwrite64 F
+ __read F
+ __res_state F
+ __send F
+ __sigaction F
+ __wait F
+ __write F
+ _pthread_cleanup_pop F
+ _pthread_cleanup_pop_restore F
+ _pthread_cleanup_push F
+ _pthread_cleanup_push_defer F
+ accept F
+ close F
+ connect F
+ fcntl F
+ flockfile F
+ fork F
+ fsync F
+ ftrylockfile F
+ funlockfile F
+ longjmp F
+ lseek F
+ lseek64 F
+ msync F
+ nanosleep F
+ open F
+ open64 F
+ pause F
+ pread F
+ pread64 F
+ pthread_attr_destroy F
+ pthread_attr_getaffinity_np F
+ pthread_attr_getdetachstate F
+ pthread_attr_getguardsize F
+ pthread_attr_getinheritsched F
+ pthread_attr_getschedparam F
+ pthread_attr_getschedpolicy F
+ pthread_attr_getscope F
+ pthread_attr_getstack F
+ pthread_attr_getstackaddr F
+ pthread_attr_getstacksize F
+ pthread_attr_init F
+ pthread_attr_setaffinity_np F
+ pthread_attr_setdetachstate F
+ pthread_attr_setguardsize F
+ pthread_attr_setinheritsched F
+ pthread_attr_setschedparam F
+ pthread_attr_setschedpolicy F
+ pthread_attr_setscope F
+ pthread_attr_setstack F
+ pthread_attr_setstackaddr F
+ pthread_attr_setstacksize F
+ pthread_barrier_destroy F
+ pthread_barrier_init F
+ pthread_barrier_wait F
+ pthread_barrierattr_destroy F
+ pthread_barrierattr_getpshared F
+ pthread_barrierattr_init F
+ pthread_barrierattr_setpshared F
+ pthread_cancel F
+ pthread_cond_broadcast F
+ pthread_cond_destroy F
+ pthread_cond_init F
+ pthread_cond_signal F
+ pthread_cond_timedwait F
+ pthread_cond_wait F
+ pthread_condattr_destroy F
+ pthread_condattr_getclock F
+ pthread_condattr_getpshared F
+ pthread_condattr_init F
+ pthread_condattr_setclock F
+ pthread_condattr_setpshared F
+ pthread_create F
+ pthread_detach F
+ pthread_equal F
+ pthread_exit F
+ pthread_getaffinity_np F
+ pthread_getattr_default_np F
+ pthread_getattr_np F
+ pthread_getconcurrency F
+ pthread_getcpuclockid F
+ pthread_getname_np F
+ pthread_getschedparam F
+ pthread_getspecific F
+ pthread_join F
+ pthread_key_create F
+ pthread_key_delete F
+ pthread_kill F
+ pthread_kill_other_threads_np F
+ pthread_mutex_consistent F
+ pthread_mutex_consistent_np F
+ pthread_mutex_destroy F
+ pthread_mutex_getprioceiling F
+ pthread_mutex_init F
+ pthread_mutex_lock F
+ pthread_mutex_setprioceiling F
+ pthread_mutex_timedlock F
+ pthread_mutex_trylock F
+ pthread_mutex_unlock F
+ pthread_mutexattr_destroy F
+ pthread_mutexattr_getkind_np F
+ pthread_mutexattr_getprioceiling F
+ pthread_mutexattr_getprotocol F
+ pthread_mutexattr_getpshared F
+ pthread_mutexattr_getrobust F
+ pthread_mutexattr_getrobust_np F
+ pthread_mutexattr_gettype F
+ pthread_mutexattr_init F
+ pthread_mutexattr_setkind_np F
+ pthread_mutexattr_setprioceiling F
+ pthread_mutexattr_setprotocol F
+ pthread_mutexattr_setpshared F
+ pthread_mutexattr_setrobust F
+ pthread_mutexattr_setrobust_np F
+ pthread_mutexattr_settype F
+ pthread_once F
+ pthread_rwlock_destroy F
+ pthread_rwlock_init F
+ pthread_rwlock_rdlock F
+ pthread_rwlock_timedrdlock F
+ pthread_rwlock_timedwrlock F
+ pthread_rwlock_tryrdlock F
+ pthread_rwlock_trywrlock F
+ pthread_rwlock_unlock F
+ pthread_rwlock_wrlock F
+ pthread_rwlockattr_destroy F
+ pthread_rwlockattr_getkind_np F
+ pthread_rwlockattr_getpshared F
+ pthread_rwlockattr_init F
+ pthread_rwlockattr_setkind_np F
+ pthread_rwlockattr_setpshared F
+ pthread_self F
+ pthread_setaffinity_np F
+ pthread_setattr_default_np F
+ pthread_setcancelstate F
+ pthread_setcanceltype F
+ pthread_setconcurrency F
+ pthread_setname_np F
+ pthread_setschedparam F
+ pthread_setschedprio F
+ pthread_setspecific F
+ pthread_sigmask F
+ pthread_sigqueue F
+ pthread_spin_destroy F
+ pthread_spin_init F
+ pthread_spin_lock F
+ pthread_spin_trylock F
+ pthread_spin_unlock F
+ pthread_testcancel F
+ pthread_timedjoin_np F
+ pthread_tryjoin_np F
+ pthread_yield F
+ pwrite F
+ pwrite64 F
+ raise F
+ read F
+ recv F
+ recvfrom F
+ recvmsg F
+ sem_close F
+ sem_destroy F
+ sem_getvalue F
+ sem_init F
+ sem_open F
+ sem_post F
+ sem_timedwait F
+ sem_trywait F
+ sem_unlink F
+ sem_wait F
+ send F
+ sendmsg F
+ sendto F
+ sigaction F
+ siglongjmp F
+ sigwait F
+ system F
+ tcdrain F
+ wait F
+ waitpid F
+ write F
diff --git a/sysdeps/unix/sysv/linux/nios2/libresolv.abilist b/sysdeps/unix/sysv/linux/nios2/libresolv.abilist
new file mode 100644
index 0000000000..6904fa3392
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libresolv.abilist
@@ -0,0 +1,93 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ __b64_ntop F
+ __b64_pton F
+ __dn_comp F
+ __dn_count_labels F
+ __dn_expand F
+ __dn_skipname F
+ __fp_nquery F
+ __fp_query F
+ __fp_resstat F
+ __hostalias F
+ __loc_aton F
+ __loc_ntoa F
+ __p_cdname F
+ __p_cdnname F
+ __p_class F
+ __p_class_syms D 0x54
+ __p_fqname F
+ __p_fqnname F
+ __p_option F
+ __p_query F
+ __p_rcode F
+ __p_secstodate F
+ __p_time F
+ __p_type F
+ __p_type_syms D 0x228
+ __putlong F
+ __putshort F
+ __res_close F
+ __res_dnok F
+ __res_hnok F
+ __res_hostalias F
+ __res_isourserver F
+ __res_mailok F
+ __res_mkquery F
+ __res_nameinquery F
+ __res_nmkquery F
+ __res_nquery F
+ __res_nquerydomain F
+ __res_nsearch F
+ __res_nsend F
+ __res_ownok F
+ __res_queriesmatch F
+ __res_query F
+ __res_querydomain F
+ __res_search F
+ __res_send F
+ __sym_ntop F
+ __sym_ntos F
+ __sym_ston F
+ _gethtbyaddr F
+ _gethtbyname F
+ _gethtbyname2 F
+ _gethtent F
+ _getlong F
+ _getshort F
+ _res_opcodes D 0x40
+ _sethtent F
+ inet_net_ntop F
+ inet_net_pton F
+ inet_neta F
+ ns_datetosecs F
+ ns_format_ttl F
+ ns_get16 F
+ ns_get32 F
+ ns_initparse F
+ ns_makecanon F
+ ns_msg_getflag F
+ ns_name_compress F
+ ns_name_ntol F
+ ns_name_ntop F
+ ns_name_pack F
+ ns_name_pton F
+ ns_name_rollback F
+ ns_name_skip F
+ ns_name_uncompress F
+ ns_name_unpack F
+ ns_parse_ttl F
+ ns_parserr F
+ ns_put16 F
+ ns_put32 F
+ ns_samedomain F
+ ns_samename F
+ ns_skiprr F
+ ns_sprintrr F
+ ns_sprintrrf F
+ ns_subdomain F
+ res_gethostbyaddr F
+ res_gethostbyname F
+ res_gethostbyname2 F
+ res_send_setqhook F
+ res_send_setrhook F
diff --git a/sysdeps/unix/sysv/linux/nios2/librt.abilist b/sysdeps/unix/sysv/linux/nios2/librt.abilist
new file mode 100644
index 0000000000..5a7bd8121e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/librt.abilist
@@ -0,0 +1,37 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ __mq_open_2 F
+ aio_cancel F
+ aio_cancel64 F
+ aio_error F
+ aio_error64 F
+ aio_fsync F
+ aio_fsync64 F
+ aio_init F
+ aio_read F
+ aio_read64 F
+ aio_return F
+ aio_return64 F
+ aio_suspend F
+ aio_suspend64 F
+ aio_write F
+ aio_write64 F
+ lio_listio F
+ lio_listio64 F
+ mq_close F
+ mq_getattr F
+ mq_notify F
+ mq_open F
+ mq_receive F
+ mq_send F
+ mq_setattr F
+ mq_timedreceive F
+ mq_timedsend F
+ mq_unlink F
+ shm_open F
+ shm_unlink F
+ timer_create F
+ timer_delete F
+ timer_getoverrun F
+ timer_gettime F
+ timer_settime F
diff --git a/sysdeps/unix/sysv/linux/nios2/libthread_db.abilist b/sysdeps/unix/sysv/linux/nios2/libthread_db.abilist
new file mode 100644
index 0000000000..c3b45edc52
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libthread_db.abilist
@@ -0,0 +1,42 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ td_init F
+ td_log F
+ td_symbol_list F
+ td_ta_clear_event F
+ td_ta_delete F
+ td_ta_enable_stats F
+ td_ta_event_addr F
+ td_ta_event_getmsg F
+ td_ta_get_nthreads F
+ td_ta_get_ph F
+ td_ta_get_stats F
+ td_ta_map_id2thr F
+ td_ta_map_lwp2thr F
+ td_ta_new F
+ td_ta_reset_stats F
+ td_ta_set_event F
+ td_ta_setconcurrency F
+ td_ta_thr_iter F
+ td_ta_tsd_iter F
+ td_thr_clear_event F
+ td_thr_dbresume F
+ td_thr_dbsuspend F
+ td_thr_event_enable F
+ td_thr_event_getmsg F
+ td_thr_get_info F
+ td_thr_getfpregs F
+ td_thr_getgregs F
+ td_thr_getxregs F
+ td_thr_getxregsize F
+ td_thr_set_event F
+ td_thr_setfpregs F
+ td_thr_setgregs F
+ td_thr_setprio F
+ td_thr_setsigpending F
+ td_thr_setxregs F
+ td_thr_sigsetmask F
+ td_thr_tls_get_addr F
+ td_thr_tlsbase F
+ td_thr_tsd F
+ td_thr_validate F
diff --git a/sysdeps/unix/sysv/linux/nios2/libutil.abilist b/sysdeps/unix/sysv/linux/nios2/libutil.abilist
new file mode 100644
index 0000000000..81848d602d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/libutil.abilist
@@ -0,0 +1,8 @@
+GLIBC_2.21
+ GLIBC_2.21 A
+ forkpty F
+ login F
+ login_tty F
+ logout F
+ logwtmp F
+ openpty F
diff --git a/sysdeps/unix/sysv/linux/nios2/localplt.data b/sysdeps/unix/sysv/linux/nios2/localplt.data
new file mode 100644
index 0000000000..ee2b94889b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/localplt.data
@@ -0,0 +1,35 @@
+libc.so: realloc
+libc.so: __eqsf2
+libc.so: __floatsisf
+libc.so: __ltdf2
+libc.so: __gedf2
+libc.so: malloc
+libc.so: __nesf2
+libc.so: memalign
+libc.so: __mulsf3
+libc.so: __floatunsisf
+libc.so: __addsf3
+libc.so: __fixsfsi
+libc.so: __subsf3
+libc.so: calloc
+libc.so: __muldf3
+libc.so: __signbit
+libc.so: free
+libc.so: __subdf3
+libc.so: __adddf3
+libc.so: __divdf3
+libc.so: __floatsidf
+libc.so: __divsf3
+libc.so: __nedf2
+libc.so: __eqdf2
+libm.so: __signbitf
+libm.so: __signbit
+libm.so: matherr
+# The dynamic loader uses __libc_memalign internally to allocate aligned
+# TLS storage. The other malloc family of functions are expected to allow
+# user symbol interposition.
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
diff --git a/sysdeps/unix/sysv/linux/nios2/makecontext.c b/sysdeps/unix/sysv/linux/nios2/makecontext.c
new file mode 100644
index 0000000000..5df951a4e6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/makecontext.c
@@ -0,0 +1,79 @@
+/* Create new context.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ucontext.h>
+
+/* makecontext sets up a stack and the registers for the
+ user context. The stack looks like this:
+
+ +-----------------------+
+ | padding as required |
+ +-----------------------+
+ sp -> | parameters 5 to n |
+ +-----------------------+
+
+ The registers are set up like this:
+ r4--r7 : parameter 1 to 4
+ r16 : uc_link
+ sp : stack pointer.
+*/
+
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
+{
+ extern void __startcontext (void);
+ unsigned long *sp;
+ va_list ap;
+ int i;
+
+ sp = (unsigned long *)
+ ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+
+ /* Allocate stack arguments. */
+ sp -= argc < 4 ? 0 : argc - 4;
+
+ /* Keep the stack aligned. */
+ sp = (unsigned long*) (((uintptr_t) sp) & -4L);
+
+ /* Init version field. */
+ ucp->uc_mcontext.version = 2;
+ /* Keep uc_link in r16. */
+ ucp->uc_mcontext.regs[15] = (uintptr_t) ucp->uc_link;
+ /* Return address points to __startcontext(). */
+ ucp->uc_mcontext.regs[23] = (uintptr_t) &__startcontext;
+ /* Frame pointer is null. */
+ ucp->uc_mcontext.regs[24] = (uintptr_t) 0;
+ /* Restart in user-space starting at 'func'. */
+ ucp->uc_mcontext.regs[27] = (uintptr_t) func;
+ /* Set stack pointer. */
+ ucp->uc_mcontext.regs[28] = (uintptr_t) sp;
+
+ va_start (ap, argc);
+ for (i = 0; i < argc; ++i)
+ if (i < 4)
+ ucp->uc_mcontext.regs[i + 3] = va_arg (ap, unsigned long);
+ else
+ sp[i - 4] = va_arg (ap, unsigned long);
+
+ va_end (ap);
+}
+
+weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/nios2/profil-counter.h b/sysdeps/unix/sysv/linux/nios2/profil-counter.h
new file mode 100644
index 0000000000..8a6a0bcf3d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/profil-counter.h
@@ -0,0 +1,2 @@
+/* We can use the ix86 version. */
+#include <sysdeps/unix/sysv/linux/i386/profil-counter.h>
diff --git a/sysdeps/unix/sysv/linux/nios2/setcontext.S b/sysdeps/unix/sysv/linux/nios2/setcontext.S
new file mode 100644
index 0000000000..9a8dd87b93
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/setcontext.S
@@ -0,0 +1,103 @@
+/* Set current context.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int setcontext (const ucontext_t *ucp) */
+ .text
+ENTRY(__setcontext)
+ ldw r5, UCONTEXT_FLAGS(r4)
+ movi r6, 1
+ bne r5, r6, .Lsigreturn
+
+ mov r10, r4
+
+ /* Restore signal mask. */
+ /* rt_sigprocmask (SIG_SETMASK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ movi r7, _NSIG8
+ addi r6, r4, UCONTEXT_SIGMASK
+ mov r5, zero
+ movi r4, SIG_SETMASK
+ movi r2, SYS_ify (rt_sigprocmask)
+ trap
+ bne r7, zero, SYSCALL_ERROR_LABEL
+
+ /* Restore argument registers, for the makecontext() case. */
+ ldw r4, (UCONTEXT_MCONTEXT + 4*4)(r10)
+ ldw r5, (UCONTEXT_MCONTEXT + 5*4)(r10)
+ ldw r6, (UCONTEXT_MCONTEXT + 6*4)(r10)
+ ldw r7, (UCONTEXT_MCONTEXT + 7*4)(r10)
+
+ ldw r16, (UCONTEXT_MCONTEXT + 16*4)(r10)
+ ldw r17, (UCONTEXT_MCONTEXT + 17*4)(r10)
+ ldw r18, (UCONTEXT_MCONTEXT + 18*4)(r10)
+ ldw r19, (UCONTEXT_MCONTEXT + 19*4)(r10)
+ ldw r20, (UCONTEXT_MCONTEXT + 20*4)(r10)
+ ldw r21, (UCONTEXT_MCONTEXT + 21*4)(r10)
+ ldw r22, (UCONTEXT_MCONTEXT + 22*4)(r10)
+ ldw ra, (UCONTEXT_MCONTEXT + 24*4)(r10)
+ ldw fp, (UCONTEXT_MCONTEXT + 25*4)(r10)
+ ldw gp, (UCONTEXT_MCONTEXT + 26*4)(r10)
+ /* Load address to continue execution. */
+ ldw r3, (UCONTEXT_MCONTEXT + 28*4)(r10)
+ ldw sp, (UCONTEXT_MCONTEXT + 29*4)(r10)
+
+ mov r2, zero
+ jmp r3
+
+.Lsigreturn:
+ addi sp, sp, -RT_SIGFRAME_SIZE
+ cfi_adjust_cfa_offset (RT_SIGFRAME_SIZE)
+
+ addi r2, sp, RT_SIGFRAME_UCONTEXT
+ movi r3, UCONTEXT_SIZE-4
+1:
+ add r6, r4, r3
+ ldw r5, 0(r6)
+ add r7, r2, r3
+ addi r3, r3, -4
+ stw r5, 0(r7)
+ bgt r3, zero, 1b
+
+ movi r2, SYS_ify (rt_sigreturn)
+ trap
+
+ addi sp, sp, RT_SIGFRAME_SIZE
+ cfi_adjust_cfa_offset (-RT_SIGFRAME_SIZE)
+ br SYSCALL_ERROR_LABEL
+
+PSEUDO_END (__setcontext)
+weak_alias (__setcontext, setcontext)
+
+ENTRY(__startcontext)
+ mov r4, r16
+ bne r4, zero, __setcontext
+
+ /* If uc_link == zero, call _exit. */
+#ifdef PIC
+ nextpc r22
+1: movhi r8, %hiadj(_gp_got - 1b)
+ addi r8, r8, %lo(_gp_got - 1b)
+ add r22, r22, r8
+ ldw r8, %call(HIDDEN_JUMPTARGET(_exit))(r22)
+ jmp r8
+#else
+ jmpi _exit
+#endif
+END(__startcontext)
diff --git a/sysdeps/unix/sysv/linux/nios2/shlib-versions b/sysdeps/unix/sysv/linux/nios2/shlib-versions
new file mode 100644
index 0000000000..443fd4df23
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/shlib-versions
@@ -0,0 +1,2 @@
+DEFAULT GLIBC_2.21
+ld=ld-linux-nios2.so.1
diff --git a/sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h b/sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h
new file mode 100644
index 0000000000..ef77d82b98
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h
@@ -0,0 +1,35 @@
+/* Nios II definitions for signal handling calling conventions.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/ucontext.h>
+#include "kernel-features.h"
+
+#define SIGCONTEXT siginfo_t *_si, struct ucontext *
+#define GET_PC(ctx) ((void *) (ctx)->uc_mcontext.regs[27])
+
+/* There is no reliable way to get the sigcontext unless we use a
+ three-argument signal handler. */
+#define __sigaction(sig, act, oact) ({ \
+ (act)->sa_flags |= SA_SIGINFO; \
+ (__sigaction) (sig, act, oact); \
+})
+
+#define sigaction(sig, act, oact) ({ \
+ (act)->sa_flags |= SA_SIGINFO; \
+ (sigaction) (sig, act, oact); \
+})
diff --git a/sysdeps/unix/sysv/linux/nios2/swapcontext.S b/sysdeps/unix/sysv/linux/nios2/swapcontext.S
new file mode 100644
index 0000000000..c2c321d96a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/swapcontext.S
@@ -0,0 +1,125 @@
+/* Modify saved context.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include "ucontext_i.h"
+
+/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
+ .text
+ENTRY(__swapcontext)
+
+ /* Same as getcontext(). */
+ stw r16, (UCONTEXT_MCONTEXT + 16*4)(r4)
+ stw r17, (UCONTEXT_MCONTEXT + 17*4)(r4)
+ stw r18, (UCONTEXT_MCONTEXT + 18*4)(r4)
+ stw r19, (UCONTEXT_MCONTEXT + 19*4)(r4)
+ stw r20, (UCONTEXT_MCONTEXT + 20*4)(r4)
+ stw r21, (UCONTEXT_MCONTEXT + 21*4)(r4)
+ stw r22, (UCONTEXT_MCONTEXT + 22*4)(r4)
+ stw ra, (UCONTEXT_MCONTEXT + 24*4)(r4)
+ stw fp, (UCONTEXT_MCONTEXT + 25*4)(r4)
+ stw gp, (UCONTEXT_MCONTEXT + 26*4)(r4)
+ /* Store return address at place for EA. */
+ stw ra, (UCONTEXT_MCONTEXT + 28*4)(r4)
+ stw sp, (UCONTEXT_MCONTEXT + 29*4)(r4)
+ /* Store zero for return success. */
+ stw zero, (UCONTEXT_MCONTEXT + 2*4)(r4)
+
+ /* Store value "1" at uc_flags to recognize as getcontext created. */
+ movi r2, 1
+ stw r2, UCONTEXT_FLAGS(r4)
+
+ /* Store MCONTEXT_VERSION at first word of mcontext_t. */
+ movi r2, MCONTEXT_VERSION
+ stw r2, UCONTEXT_MCONTEXT(r4)
+
+ /* Save ucp to non-argument syscall preserved register. */
+ mov r10, r5
+
+ /* Get signal mask. */
+ /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ movi r7, _NSIG8
+ addi r6, r4, UCONTEXT_SIGMASK
+ mov r5, zero
+ movi r4, SIG_BLOCK
+ movi r2, SYS_ify (rt_sigprocmask)
+ trap
+ bne r7, zero, SYSCALL_ERROR_LABEL
+
+
+ /* Same as setcontext(). */
+ ldw r5, UCONTEXT_FLAGS(r10)
+ movi r6, 1
+ bne r5, r6, .Lsigreturn
+
+ /* Restore signal mask. */
+ /* rt_sigprocmask (SIG_SETMASK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ movi r7, _NSIG8
+ addi r6, r10, UCONTEXT_SIGMASK
+ mov r5, zero
+ movi r4, SIG_SETMASK
+ movi r2, SYS_ify (rt_sigprocmask)
+ trap
+ bne r7, zero, SYSCALL_ERROR_LABEL
+
+ /* Restore argument registers, for the makecontext() case. */
+ ldw r4, (UCONTEXT_MCONTEXT + 4*4)(r10)
+ ldw r5, (UCONTEXT_MCONTEXT + 5*4)(r10)
+ ldw r6, (UCONTEXT_MCONTEXT + 6*4)(r10)
+ ldw r7, (UCONTEXT_MCONTEXT + 7*4)(r10)
+
+ ldw r16, (UCONTEXT_MCONTEXT + 16*4)(r10)
+ ldw r17, (UCONTEXT_MCONTEXT + 17*4)(r10)
+ ldw r18, (UCONTEXT_MCONTEXT + 18*4)(r10)
+ ldw r19, (UCONTEXT_MCONTEXT + 19*4)(r10)
+ ldw r20, (UCONTEXT_MCONTEXT + 20*4)(r10)
+ ldw r21, (UCONTEXT_MCONTEXT + 21*4)(r10)
+ ldw r22, (UCONTEXT_MCONTEXT + 22*4)(r10)
+ ldw ra, (UCONTEXT_MCONTEXT + 24*4)(r10)
+ ldw fp, (UCONTEXT_MCONTEXT + 25*4)(r10)
+ ldw gp, (UCONTEXT_MCONTEXT + 26*4)(r10)
+ /* Load address to continue execution. */
+ ldw r3, (UCONTEXT_MCONTEXT + 28*4)(r10)
+ ldw sp, (UCONTEXT_MCONTEXT + 29*4)(r10)
+
+ mov r2, zero
+ jmp r3
+
+.Lsigreturn:
+ addi sp, sp, -RT_SIGFRAME_SIZE
+ cfi_adjust_cfa_offset (RT_SIGFRAME_SIZE)
+
+ addi r2, sp, RT_SIGFRAME_UCONTEXT
+ movi r3, UCONTEXT_SIZE-4
+1:
+ add r6, r4, r3
+ ldw r5, 0(r6)
+ add r7, r2, r3
+ addi r3, r3, -4
+ stw r5, 0(r7)
+ bgt r3, zero, 1b
+
+ movi r2, SYS_ify (rt_sigreturn)
+ trap
+
+ addi sp, sp, RT_SIGFRAME_SIZE
+ cfi_adjust_cfa_offset (-RT_SIGFRAME_SIZE)
+ br SYSCALL_ERROR_LABEL
+
+PSEUDO_END (__swapcontext)
+weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h b/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h
new file mode 100644
index 0000000000..1f7db26af6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h
@@ -0,0 +1,36 @@
+/* cacheflush - flush contents of instruction and/or data cache.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+#include <features.h>
+
+/* Get the kernel definition for the op bits. */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+#ifdef __USE_MISC
+extern int cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
+#endif
+extern int _flush_cache (char *__addr, const int __nbytes, const int __op) __THROW;
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/procfs.h b/sysdeps/unix/sysv/linux/nios2/sys/procfs.h
new file mode 100644
index 0000000000..86237ff766
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sys/procfs.h
@@ -0,0 +1,123 @@
+/* Core image file related definitions, Nios II version.
+ Copyright (C) 1996-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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register. */
+typedef unsigned long elf_greg_t;
+
+/* And the whole bunch of them. We could have used `struct
+ user_regs' directly in the typedef, but tradition says that
+ the register set is an array, which does have some peculiar
+ semantics, so leave it that way. */
+#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Register set for the floating-point registers. */
+typedef struct user_fpregs elf_fpregset_t;
+
+/* Signal info. */
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h b/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
new file mode 100644
index 0000000000..36e54a07a6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
@@ -0,0 +1,48 @@
+/* struct ucontext definition, 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
+ <http://www.gnu.org/licenses/>. */
+
+/* System V/Nios II ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+/* These definitions must be in sync with the kernel. */
+
+#define MCONTEXT_VERSION 2
+
+/* Context to describe whole processor state. */
+typedef struct mcontext
+ {
+ int version;
+ unsigned long regs[32];
+ } mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/user.h b/sysdeps/unix/sysv/linux/nios2/sys/user.h
new file mode 100644
index 0000000000..f096d1b94f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sys/user.h
@@ -0,0 +1,58 @@
+/* ptrace register data format definitions.
+ Copyright (C) 1998-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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+/* The whole purpose of this file is for GDB and GDB only. Don't read
+ too much into it. Don't use it for anything other than GDB unless
+ you know what you are doing. */
+
+struct user_fpregs
+{
+};
+
+struct user_regs
+{
+ unsigned long int uregs[49];
+};
+
+struct user
+{
+ struct user_regs regs; /* General registers */
+ int u_fpvalid; /* True if math co-processor being used. */
+
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack. */
+
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ struct user_regs *u_ar0; /* help gdb to find the general registers. */
+
+ unsigned long magic; /* uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+ int u_debugreg[8];
+ struct user_fpregs u_fp; /* Floating point registers */
+ struct user_fpregs *u_fp0; /* help gdb to find the FP registers. */
+};
+
+#endif /* sys/user.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/syscall.S b/sysdeps/unix/sysv/linux/nios2/syscall.S
new file mode 100644
index 0000000000..718db61f03
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/syscall.S
@@ -0,0 +1,36 @@
+/* syscall - indirect system call.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* We don't need a special syscall to implement syscall(). It won't work
+ reliably with 64-bit arguments (but that is true on many modern platforms).
+*/
+
+ENTRY (syscall)
+ mov r2, r4
+ mov r4, r5
+ mov r5, r6
+ mov r6, r7
+ ldw r7, 0(sp)
+ ldw r8, 4(sp)
+ ldw r9, 8(sp)
+ trap
+ bne r7, zero, SYSCALL_ERROR_LABEL
+ ret
+PSEUDO_END (syscall)
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
new file mode 100644
index 0000000000..e2c70ba970
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
@@ -0,0 +1,141 @@
+/* Assembler macros with cancellation support, Nios II version.
+ Copyright (C) 2003-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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ cfi_startproc; \
+ DO_CALL (syscall_name, args); \
+ bne r7, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ cfi_endproc; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ SINGLE_THREAD_P(r2); \
+ bne r2, zero, pseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ bne r7, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ pseudo_cancel: \
+ SAVESTK_##args; /* save syscall args and adjust stack */ \
+ SAVEREG(ra, 0); /* save return address */ \
+ SAVEREG(r22, 4); /* save GOT pointer */ \
+ nextpc r22; \
+1: movhi r2, %hiadj(_gp_got - 1b); \
+ addi r2, r2, %lo(_gp_got - 1b); \
+ add r22, r22, r2; \
+ CENABLE; \
+ callr r3; \
+ stw r2, 8(sp); /* save mask */ \
+ LOADARGS_##args; \
+ movi r2, SYS_ify(syscall_name); \
+ trap; \
+ stw r2, 12(sp); /* save syscall result */ \
+ stw r7, 16(sp); /* save syscall error flag */ \
+ ldw r4, 8(sp); /* pass mask as argument 1 */ \
+ CDISABLE; \
+ callr r3; \
+ ldw r7, 16(sp); /* restore syscall error flag */ \
+ ldw r2, 12(sp); /* restore syscall result */ \
+ ldw ra, 0(sp); /* restore return address */ \
+ ldw r22, 4(sp); /* restore GOT pointer */ \
+ RESTORESTK_##args; \
+ bne r7, zero, SYSCALL_ERROR_LABEL;
+
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ SYSCALL_ERROR_HANDLER \
+ END (sym)
+
+#define SAVEREG(REG, LOC) stw REG, LOC(sp); cfi_rel_offset (REG, LOC)
+#define SAVESTK(X) subi sp, sp, X; cfi_adjust_cfa_offset(X)
+#define SAVESTK_0 SAVESTK(20)
+#define SAVEARG_1 SAVEREG(r4, 20)
+#define SAVESTK_1 SAVESTK(24); SAVEARG_1
+#define SAVEARG_2 SAVEREG(r5, 24); SAVEARG_1
+#define SAVESTK_2 SAVESTK(28); SAVEARG_2
+#define SAVEARG_3 SAVEREG(r6, 28); SAVEARG_2
+#define SAVESTK_3 SAVESTK(32); SAVEARG_3
+#define SAVEARG_4 SAVEREG(r7, 32); SAVEARG_3
+#define SAVESTK_4 SAVESTK(36); SAVEARG_4
+#define SAVESTK_5 SAVESTK_4
+#define SAVESTK_6 SAVESTK_5
+
+#define LOADARGS_0
+#define LOADARGS_1 ldw r4, 20(sp)
+#define LOADARGS_2 LOADARGS_1; ldw r5, 24(sp)
+#define LOADARGS_3 LOADARGS_2; ldw r6, 28(sp)
+#define LOADARGS_4 LOADARGS_3; ldw r7, 32(sp)
+#define LOADARGS_5 LOADARGS_4; ldw r8, 36(sp)
+#define LOADARGS_6 LOADARGS_5; ldw r9, 40(sp)
+
+#define RESTORESTK(X) addi sp, sp, X; cfi_adjust_cfa_offset(-X)
+#define RESTORESTK_0 RESTORESTK(20)
+#define RESTORESTK_1 RESTORESTK(24)
+#define RESTORESTK_2 RESTORESTK(28)
+#define RESTORESTK_3 RESTORESTK(32)
+#define RESTORESTK_4 RESTORESTK(36)
+#define RESTORESTK_5 RESTORESTK(36)
+#define RESTORESTK_6 RESTORESTK(36)
+
+# if IS_IN (libpthread)
+# define CENABLE ldw r3, %call(__pthread_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__pthread_disable_asynccancel)(r22)
+# elif IS_IN (librt)
+# define CENABLE ldw r3, %call(__librt_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__librt_disable_asynccancel)(r22)
+# elif IS_IN (libc)
+# define CENABLE ldw r3, %call(__libc_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__libc_disable_asynccancel)(r22)
+# else
+# error Unsupported library
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ ldw reg, MULTIPLE_THREADS_OFFSET(r23)
+#endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.S b/sysdeps/unix/sysv/linux/nios2/sysdep.S
new file mode 100644
index 0000000000..cb3b7f6e09
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.S
@@ -0,0 +1,50 @@
+/* Static library error handling code fragment 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* The following code is only used in the static library. In the shared
+ library, the error handling code is at the end of each function. */
+
+#ifndef PIC
+
+/* In the static library, the syscall stubs jump here when they detect
+ an error. */
+
+# undef CALL_MCOUNT
+# define CALL_MCOUNT /* Don't insert the profiling call, it clobbers r2. */
+
+# if IS_IN (libc)
+# define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+# define SYSCALL_ERROR_ERRNO errno
+# endif
+ .text
+ENTRY (__syscall_error)
+ nextpc r3
+1:
+ movhi r8, %hiadj(_gp_got - 1b)
+ addi r8, r8, %lo(_gp_got - 1b)
+ add r3, r3, r8
+ ldw r3, %tls_ie(SYSCALL_ERROR_ERRNO)(r3)
+ add r3, r23, r3
+ stw r2, 0(r3)
+ movi r2, -1
+ ret
+END (__syscall_error)
+#endif
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
new file mode 100644
index 0000000000..66a77f4716
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -0,0 +1,260 @@
+/* Assembler macros for Nios II.
+ 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 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_NIOS2_SYSDEP_H
+#define _LINUX_NIOS2_SYSDEP_H 1
+
+#include <asm/unistd.h>
+#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/nios2/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
+
+/* For RTLD_PRIVATE_ERRNO. */
+#include <dl-sysdep.h>
+
+#include <tls.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+#ifdef __ASSEMBLER__
+
+#define SYSCALL_ERROR_LABEL __local_syscall_error
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args) \
+ bne r7, zero, SYSCALL_ERROR_LABEL; \
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#undef ret_NOERRNO
+#define ret_NOERRNO ret
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ movi r2, SYS_ify(syscall_name); \
+ trap;
+
+#if defined(__PIC__) || defined(PIC)
+
+# if RTLD_PRIVATE_ERRNO
+
+# define SYSCALL_ERROR_HANDLER \
+ SYSCALL_ERROR_LABEL: \
+ nextpc r3; \
+1: \
+ movhi r8, %hiadj(rtld_errno - 1b); \
+ addi r8, r8, %lo(rtld_errno - 1b); \
+ add r3, r3, r8; \
+ stw r2, 0(r3); \
+ movi r2, -1; \
+ ret;
+
+# else
+
+# if IS_IN (libc)
+# define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+# define SYSCALL_ERROR_ERRNO errno
+# endif
+# define SYSCALL_ERROR_HANDLER \
+ SYSCALL_ERROR_LABEL: \
+ nextpc r3; \
+1: \
+ movhi r8, %hiadj(_gp_got - 1b); \
+ addi r8, r8, %lo(_gp_got - 1b); \
+ add r3, r3, r8; \
+ ldw r3, %tls_ie(SYSCALL_ERROR_ERRNO)(r3); \
+ add r3, r23, r3; \
+ stw r2, 0(r3); \
+ movi r2, -1; \
+ ret;
+
+# endif
+
+#else
+
+/* We can use a single error handler in the static library. */
+#define SYSCALL_ERROR_HANDLER \
+ SYSCALL_ERROR_LABEL: \
+ jmpi __syscall_error;
+
+#endif
+
+#define DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 ldw r8, 0(sp);
+#define DOARGS_6 ldw r9, 4(sp); ldw r8, 0(sp);
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#define ret_ERRVAL ret
+
+#else /* __ASSEMBLER__ */
+
+/* In order to get __set_errno() definition in INLINE_SYSCALL. */
+#include <errno.h>
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ INTERNAL_SYSCALL_DECL(err); \
+ unsigned int result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
+ result_var = -1L; \
+ } \
+ (int) result_var; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
+
+#undef INTERNAL_SYSCALL_RAW
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({ unsigned int _sys_result; \
+ { \
+ /* Load argument values in temporary variables
+ to perform side effects like function calls
+ before the call-used registers are set. */ \
+ LOAD_ARGS_##nr (args) \
+ LOAD_REGS_##nr \
+ register int _r2 asm ("r2") = (int)(name); \
+ register int _err asm ("r7"); \
+ asm volatile ("trap" \
+ : "+r" (_r2), "=r" (_err) \
+ : ASM_ARGS_##nr \
+ : __SYSCALL_CLOBBERS); \
+ _sys_result = _r2; \
+ err = _err; \
+ } \
+ (int) _sys_result; })
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(number, err, nr, args)
+
+#define LOAD_ARGS_0()
+#define LOAD_REGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ LOAD_ARGS_0 () \
+ int __arg1 = (int) (a1);
+#define LOAD_REGS_1 \
+ register int _r4 asm ("r4") = __arg1; \
+ LOAD_REGS_0
+#define ASM_ARGS_1 "r" (_r4)
+#define LOAD_ARGS_2(a1, a2) \
+ LOAD_ARGS_1 (a1) \
+ int __arg2 = (int) (a2);
+#define LOAD_REGS_2 \
+ register int _r5 asm ("r5") = __arg2; \
+ LOAD_REGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_r5)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ LOAD_ARGS_2 (a1, a2) \
+ int __arg3 = (int) (a3);
+#define LOAD_REGS_3 \
+ register int _r6 asm ("r6") = __arg3; \
+ LOAD_REGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_r6)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ int __arg4 = (int) (a4);
+#define LOAD_REGS_4 \
+ register int _r7 asm ("r7") = __arg4; \
+ LOAD_REGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_r7)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ int __arg5 = (int) (a5);
+#define LOAD_REGS_5 \
+ register int _r8 asm ("r8") = __arg5; \
+ LOAD_REGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_r8)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ int __arg6 = (int) (a6);
+#define LOAD_REGS_6 \
+ register int _r9 asm ("r9") = __arg6; \
+ LOAD_REGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_r9)
+
+#define __SYSCALL_CLOBBERS "memory"
+
+#endif /* __ASSEMBLER__ */
+
+/* Pointer mangling support. */
+#if IS_IN (rtld)
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE_GUARD(guard) ldw guard, POINTER_GUARD(r23)
+# define PTR_MANGLE(dst, src, guard) xor dst, src, guard
+# define PTR_DEMANGLE(dst, src, guard) PTR_MANGLE (dst, src, guard)
+# else
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
+
+#endif /* linux/nios2/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/ucontext_i.sym b/sysdeps/unix/sysv/linux/nios2/ucontext_i.sym
new file mode 100644
index 0000000000..a844c96796
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/ucontext_i.sym
@@ -0,0 +1,29 @@
+#include <inttypes.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/ucontext.h>
+
+#include "kernel_rt_sigframe.h"
+
+SIG_BLOCK
+SIG_SETMASK
+
+_NSIG8 (_NSIG / 8)
+
+MCONTEXT_VERSION
+
+-- Offsets of the fields in the kernel rt_sigframe_t structure.
+#define rt_sigframe(member) offsetof (struct kernel_rt_sigframe, member)
+
+RT_SIGFRAME_SIZE sizeof (struct kernel_rt_sigframe)
+RT_SIGFRAME_UCONTEXT rt_sigframe (uc)
+
+-- Offsets of the fields in the ucontext_t structure.
+#define ucontext(member) offsetof (ucontext_t, member)
+
+UCONTEXT_FLAGS ucontext (uc_flags)
+UCONTEXT_LINK ucontext (uc_link)
+UCONTEXT_STACK ucontext (uc_stack)
+UCONTEXT_MCONTEXT ucontext (uc_mcontext)
+UCONTEXT_SIGMASK ucontext (uc_sigmask)
+UCONTEXT_SIZE sizeof (ucontext_t)
diff --git a/sysdeps/unix/sysv/linux/nios2/vfork.S b/sysdeps/unix/sysv/linux/nios2/vfork.S
new file mode 100644
index 0000000000..67a06520d0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/nios2/vfork.S
@@ -0,0 +1,44 @@
+/* vfork for Nios II Linux.
+ 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
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tcb-offsets.h>
+
+ENTRY(__vfork)
+
+ ldw r6, PID_OFFSET(r23)
+ sub r7, zero, r6
+ bne r7, zero, 2f
+ movhi r7, %hi(0x80000000)
+2:
+ stw r7, PID_OFFSET(r23)
+
+ movi r4, 0x4111 /* (CLONE_VM | CLONE_VFORK | SIGCHLD) */
+ mov r5, zero
+ DO_CALL (clone, 2)
+
+ beq r2, zero, 1f
+ stw r6, PID_OFFSET(r23)
+1:
+ bne r7, zero, SYSCALL_ERROR_LABEL
+ ret
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)