about summary refs log tree commit diff
path: root/REORG.TODO/sysdeps/microblaze
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/microblaze')
-rw-r--r--REORG.TODO/sysdeps/microblaze/Implies4
-rw-r--r--REORG.TODO/sysdeps/microblaze/Makefile11
-rw-r--r--REORG.TODO/sysdeps/microblaze/__longjmp.S55
-rw-r--r--REORG.TODO/sysdeps/microblaze/_mcount.S91
-rw-r--r--REORG.TODO/sysdeps/microblaze/abort-instr.h2
-rw-r--r--REORG.TODO/sysdeps/microblaze/asm-syntax.h24
-rw-r--r--REORG.TODO/sysdeps/microblaze/atomic-machine.h269
-rw-r--r--REORG.TODO/sysdeps/microblaze/backtrace.c142
-rw-r--r--REORG.TODO/sysdeps/microblaze/backtrace_linux.c59
-rw-r--r--REORG.TODO/sysdeps/microblaze/bits/endian.h30
-rw-r--r--REORG.TODO/sysdeps/microblaze/bits/fenv.h50
-rw-r--r--REORG.TODO/sysdeps/microblaze/bits/link.h57
-rw-r--r--REORG.TODO/sysdeps/microblaze/bits/setjmp.h37
-rw-r--r--REORG.TODO/sysdeps/microblaze/bsd-_setjmp.S22
-rw-r--r--REORG.TODO/sysdeps/microblaze/bsd-setjmp.S22
-rw-r--r--REORG.TODO/sysdeps/microblaze/crti.S88
-rw-r--r--REORG.TODO/sysdeps/microblaze/crtn.S51
-rw-r--r--REORG.TODO/sysdeps/microblaze/dl-machine.h299
-rw-r--r--REORG.TODO/sysdeps/microblaze/dl-tls.h26
-rw-r--r--REORG.TODO/sysdeps/microblaze/dl-trampoline.S109
-rw-r--r--REORG.TODO/sysdeps/microblaze/gccframe.h21
-rw-r--r--REORG.TODO/sysdeps/microblaze/jmpbuf-unwind.h46
-rw-r--r--REORG.TODO/sysdeps/microblaze/ldsodefs.h45
-rw-r--r--REORG.TODO/sysdeps/microblaze/libc-tls.c32
-rw-r--r--REORG.TODO/sysdeps/microblaze/libm-test-ulps333
-rw-r--r--REORG.TODO/sysdeps/microblaze/libm-test-ulps-name1
-rw-r--r--REORG.TODO/sysdeps/microblaze/machine-gmon.h30
-rw-r--r--REORG.TODO/sysdeps/microblaze/math_private.h39
-rw-r--r--REORG.TODO/sysdeps/microblaze/memusage.h21
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/Makefile21
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h70
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/bits/semaphore.h32
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/pthreaddef.h35
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/tcb-offsets.sym10
-rw-r--r--REORG.TODO/sysdeps/microblaze/nptl/tls.h143
-rw-r--r--REORG.TODO/sysdeps/microblaze/preconfigure3
-rw-r--r--REORG.TODO/sysdeps/microblaze/s_fma.c1
-rw-r--r--REORG.TODO/sysdeps/microblaze/s_fmaf.c1
-rw-r--r--REORG.TODO/sysdeps/microblaze/setjmp.S75
-rw-r--r--REORG.TODO/sysdeps/microblaze/sfp-machine.h1
-rw-r--r--REORG.TODO/sysdeps/microblaze/sotruss-lib.c52
-rw-r--r--REORG.TODO/sysdeps/microblaze/stackinfo.h34
-rw-r--r--REORG.TODO/sysdeps/microblaze/start.S84
-rw-r--r--REORG.TODO/sysdeps/microblaze/sysdep.h85
-rw-r--r--REORG.TODO/sysdeps/microblaze/tls-macros.h46
-rw-r--r--REORG.TODO/sysdeps/microblaze/tst-audit.h25
46 files changed, 2734 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/microblaze/Implies b/REORG.TODO/sysdeps/microblaze/Implies
new file mode 100644
index 0000000000..73c766c52e
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/Implies
@@ -0,0 +1,4 @@
+wordsize-32
+# MicroBlaze uses IEEE 754 floating point.
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/REORG.TODO/sysdeps/microblaze/Makefile b/REORG.TODO/sysdeps/microblaze/Makefile
new file mode 100644
index 0000000000..f7c95ae115
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/Makefile
@@ -0,0 +1,11 @@
+ifeq ($(subdir),elf)
+CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
+endif
+
+ifeq ($(subdir),gmon)
+sysdep_routines += _mcount
+endif
+
+ifeq ($(subdir),resource)
+sysdep_routines += backtrace_linux
+endif
diff --git a/REORG.TODO/sysdeps/microblaze/__longjmp.S b/REORG.TODO/sysdeps/microblaze/__longjmp.S
new file mode 100644
index 0000000000..cefe6d35b0
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/__longjmp.S
@@ -0,0 +1,55 @@
+/* Copyright (C) 1997-2017 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>
+
+/* Jump to the position specified by ENV, causing the
+   setjmp call there to return VAL, or 1 if VAL is 0.  */
+
+/* void __longjmp (__jmp_buf env, int val) */
+
+ENTRY(__longjmp)
+    lwi   r1,r5,0
+    lwi   r2,r5,4
+    lwi   r13,r5,8
+    lwi   r14,r5,12
+    lwi   r15,r5,16
+    lwi   r16,r5,20
+    lwi   r17,r5,24
+    lwi   r18,r5,28
+    lwi   r19,r5,32
+    lwi   r20,r5,36
+    lwi   r21,r5,40
+    lwi   r22,r5,44
+    lwi   r23,r5,48
+    lwi   r24,r5,52
+    lwi   r25,r5,56
+    lwi   r26,r5,60
+    lwi   r27,r5,64
+    lwi   r28,r5,68
+    lwi   r29,r5,72
+    lwi   r30,r5,76
+    lwi   r31,r5,80
+    addk  r3,r6,r0
+    beqi  r3,L(return_1)
+    rtsd  r15,8
+    nop
+L(return_1):
+    rtsd  r15,8
+    addik r3,r0,1	/* delay slot.  */
+END(__longjmp)
diff --git a/REORG.TODO/sysdeps/microblaze/_mcount.S b/REORG.TODO/sysdeps/microblaze/_mcount.S
new file mode 100644
index 0000000000..502d966640
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/_mcount.S
@@ -0,0 +1,91 @@
+/* Copyright (C) 1997-2017 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/>.  */
+
+	.global	_mcount
+	.type	_mcount, @function
+_mcount:
+	# Save regs.
+	addik   r1, r1,-4 * 24
+	swi	r31, r1, 4 * 23
+	swi	r30, r1, 4 * 22
+	swi	r29, r1, 4 * 21
+	swi	r28, r1, 4 * 20
+	swi	r27, r1, 4 * 19
+	swi	r26, r1, 4 * 18
+	swi	r25, r1, 4 * 17
+	swi	r24, r1, 4 * 16
+	swi	r23, r1, 4 * 15
+	swi	r22, r1, 4 * 14
+	swi	r21, r1, 4 * 13
+	swi	r20, r1, 4 * 12
+	swi	r19, r1, 4 * 11
+	swi	r15, r1, 4 * 10
+	swi	r12, r1, 4 * 9
+	swi	r11, r1, 4 * 8
+	swi	r10, r1, 4 * 7
+	swi	r8, r1, 4 * 6
+	swi	r7, r1, 4 * 5
+	swi	r6, r1, 4 * 4
+	swi	r5, r1, 4 * 3
+	swi	r4, r1, 4 * 2
+	swi	r3, r1, 4 * 1
+	swi	r2, r1, 4 * 0
+
+#ifdef SHARED
+	mfs     r20,rpc
+	addik   r20,r20,_GLOBAL_OFFSET_TABLE_+8
+	addk	r6, r0, r15	# callee is in r15.
+	brlid	r15, __mcount_internal@PLT
+	lwi	r5, r1, 4 * 24	# caller is on the stack.
+#else
+	# Pass from/to in r5 and r6.
+	addk	r6, r0, r15	# callee is in r15.
+	bralid	r15, __mcount_internal
+	lwi	r5, r1, 4 * 24	# caller is on the stack.
+#endif
+
+	# Reload regs
+	lwi	r31, r1, 4 * 23
+	lwi	r30, r1, 4 * 22
+	lwi	r29, r1, 4 * 21
+	lwi	r28, r1, 4 * 20
+	lwi	r27, r1, 4 * 19
+	lwi	r26, r1, 4 * 18
+	lwi	r25, r1, 4 * 17
+	lwi	r24, r1, 4 * 16
+	lwi	r23, r1, 4 * 15
+	lwi	r22, r1, 4 * 14
+	lwi	r21, r1, 4 * 13
+	lwi	r20, r1, 4 * 12
+	lwi	r19, r1, 4 * 11
+	lwi	r15, r1, 4 * 10
+	lwi	r12, r1, 4 * 9
+	lwi	r11, r1, 4 * 8
+	lwi	r10, r1, 4 * 7
+	lwi	r8, r1, 4 * 6
+	lwi	r7, r1, 4 * 5
+	lwi	r6, r1, 4 * 4
+	lwi	r5, r1, 4 * 3
+	lwi	r4, r1, 4 * 2
+	lwi	r3, r1, 4 * 1
+	lwi	r2, r1, 4 * 0
+
+	rtsd	r15, 8
+	addik	r1, r1, 4 * 24
+
+	.size	_mcount, . - _mcount
diff --git a/REORG.TODO/sysdeps/microblaze/abort-instr.h b/REORG.TODO/sysdeps/microblaze/abort-instr.h
new file mode 100644
index 0000000000..38469d490a
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/abort-instr.h
@@ -0,0 +1,2 @@
+/* An instruction which should crash any program is `illegal'.  */
+#define ABORT_INSTRUCTION asm ("brki r0, -1")
diff --git a/REORG.TODO/sysdeps/microblaze/asm-syntax.h b/REORG.TODO/sysdeps/microblaze/asm-syntax.h
new file mode 100644
index 0000000000..be54a0962f
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/asm-syntax.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 1997-2017 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/>.  */
+
+#undef ALIGN
+#define ALIGN(log) .align 1<<log
+
+#define R_(r) %##r
+#define R(r) R_(r)
+#define L(label) .##label
diff --git a/REORG.TODO/sysdeps/microblaze/atomic-machine.h b/REORG.TODO/sysdeps/microblaze/atomic-machine.h
new file mode 100644
index 0000000000..d73c69d46b
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/atomic-machine.h
@@ -0,0 +1,269 @@
+/* Copyright (C) 2003-2017 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 <stdint.h>
+#include <sysdep.h>
+
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+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
+
+/* XXX Is this actually correct?  */
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+
+/* Microblaze does not have byte and halfword forms of load and reserve and
+   store conditional. So for microblaze we stub out the 8- and 16-bit forms.  */
+#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_val_32_acq(mem, newval, oldval)            \
+  ({                                                                           \
+      __typeof (*(mem)) __tmp;                                                 \
+      __typeof (mem)  __memp = (mem);                                          \
+      int test;                                                                \
+      __asm __volatile (                                                       \
+                "   addc    r0, r0, r0;"                                       \
+                "1: lwx     %0, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "   cmp     %1, %0, %4;"                                       \
+                "   bnei    %1, 2f;"                                           \
+                "   swx     %5, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "2:"                                                           \
+                    : "=&r" (__tmp),                                           \
+                    "=&r" (test),                                              \
+                    "=m" (*__memp)                                             \
+                    : "r" (__memp),                                            \
+                    "r" (oldval),                                              \
+                    "r" (newval)                                               \
+                    : "cc", "memory");                                         \
+      __tmp;                                                                   \
+  })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval)            \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval)               \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*mem) == 4)                                                    \
+      __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
+    else if (sizeof (*mem) == 8)                                               \
+      __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define atomic_compare_and_exchange_val_rel(mem, newval, oldval)               \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*mem) == 4)                                                    \
+      __result = __arch_compare_and_exchange_val_32_acq (mem, newval, oldval); \
+    else if (sizeof (*mem) == 8)                                               \
+      __result = __arch_compare_and_exchange_val_64_acq (mem, newval, oldval); \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define __arch_atomic_exchange_32_acq(mem, value)                              \
+  ({                                                                           \
+      __typeof (*(mem)) __tmp;                                                 \
+      __typeof (mem)  __memp = (mem);                                          \
+      int test;                                                                \
+      __asm __volatile (                                                       \
+                "   addc    r0, r0, r0;"                                       \
+                "1: lwx     %0, %4, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "   swx     %3, %4, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                    : "=&r" (__tmp),                                           \
+                    "=&r" (test),                                              \
+                    "=m" (*__memp)                                             \
+                    : "r" (value),                                             \
+                    "r" (__memp)                                               \
+                    : "cc", "memory");                                         \
+      __tmp;                                                                   \
+  })
+
+#define __arch_atomic_exchange_64_acq(mem, newval)                             \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_exchange_acq(mem, value)                                        \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*mem) == 4)                                                    \
+      __result = __arch_atomic_exchange_32_acq (mem, value);                   \
+    else if (sizeof (*mem) == 8)                                               \
+      __result = __arch_atomic_exchange_64_acq (mem, value);                   \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define atomic_exchange_rel(mem, value)                                        \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*mem) == 4)                                                    \
+      __result = __arch_atomic_exchange_32_acq (mem, value);                   \
+    else if (sizeof (*mem) == 8)                                               \
+      __result = __arch_atomic_exchange_64_acq (mem, value);                   \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define __arch_atomic_exchange_and_add_32(mem, value)                          \
+  ({                                                                           \
+    __typeof (*(mem)) __tmp;                                                   \
+      __typeof (mem)  __memp = (mem);                                          \
+    int test;                                                                  \
+    __asm __volatile (                                                         \
+                "   addc    r0, r0, r0;"                                       \
+                "1: lwx     %0, %4, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "   add     %1, %3, %0;"                                       \
+                "   swx     %1, %4, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                    : "=&r" (__tmp),                                           \
+                    "=&r" (test),                                              \
+                    "=m" (*__memp)                                             \
+                    : "r" (value),                                             \
+                    "r" (__memp)                                               \
+                    : "cc", "memory");                                         \
+    __tmp;                                                                     \
+  })
+
+#define __arch_atomic_exchange_and_add_64(mem, value)                          \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_exchange_and_add(mem, value)                                    \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*mem) == 4)                                                    \
+      __result = __arch_atomic_exchange_and_add_32 (mem, value);               \
+    else if (sizeof (*mem) == 8)                                               \
+      __result = __arch_atomic_exchange_and_add_64 (mem, value);               \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define __arch_atomic_increment_val_32(mem)                                    \
+  ({                                                                           \
+    __typeof (*(mem)) __val;                                                   \
+    int test;                                                                  \
+    __asm __volatile (                                                         \
+                "   addc    r0, r0, r0;"                                       \
+                "1: lwx     %0, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "   addi    %0, %0, 1;"                                        \
+                "   swx     %0, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                    : "=&r" (__val),                                           \
+                    "=&r" (test),                                              \
+                    "=m" (*mem)                                                \
+                    : "r" (mem),                                               \
+                    "m" (*mem)                                                 \
+                    : "cc", "memory");                                         \
+    __val;                                                                     \
+  })
+
+#define __arch_atomic_increment_val_64(mem)                                    \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_increment_val(mem)                                              \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*(mem)) == 4)                                                  \
+      __result = __arch_atomic_increment_val_32 (mem);                         \
+    else if (sizeof (*(mem)) == 8)                                             \
+      __result = __arch_atomic_increment_val_64 (mem);                         \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define atomic_increment(mem) ({ atomic_increment_val (mem); (void) 0; })
+
+#define __arch_atomic_decrement_val_32(mem)                                    \
+  ({                                                                           \
+    __typeof (*(mem)) __val;                                                   \
+    int test;                                                                  \
+    __asm __volatile (                                                         \
+                "   addc    r0, r0, r0;"                                       \
+                "1: lwx     %0, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                "   rsubi   %0, %0, 1;"                                        \
+                "   swx     %0, %3, r0;"                                       \
+                "   addic   %1, r0, 0;"                                        \
+                "   bnei    %1, 1b;"                                           \
+                    : "=&r" (__val),                                           \
+                    "=&r" (test),                                              \
+                    "=m" (*mem)                                                \
+                    : "r" (mem),                                               \
+                    "m" (*mem)                                                 \
+                    : "cc", "memory");                                         \
+    __val;                                                                     \
+  })
+
+#define __arch_atomic_decrement_val_64(mem)                                    \
+  (abort (), (__typeof (*mem)) 0)
+
+#define atomic_decrement_val(mem)                                              \
+  ({                                                                           \
+    __typeof (*(mem)) __result;                                                \
+    if (sizeof (*(mem)) == 4)                                                  \
+      __result = __arch_atomic_decrement_val_32 (mem);                         \
+    else if (sizeof (*(mem)) == 8)                                             \
+      __result = __arch_atomic_decrement_val_64 (mem);                         \
+    else                                                                       \
+       abort ();                                                               \
+    __result;                                                                  \
+  })
+
+#define atomic_decrement(mem) ({ atomic_decrement_val (mem); (void) 0; })
diff --git a/REORG.TODO/sysdeps/microblaze/backtrace.c b/REORG.TODO/sysdeps/microblaze/backtrace.c
new file mode 100644
index 0000000000..7cc28ff146
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/backtrace.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 2005-2017 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 <stdio.h>
+#include <string.h>
+#include <sysdep.h>
+#include <signal.h>
+#include <execinfo.h>
+
+extern int
+_identify_sighandler (unsigned long fp, unsigned long pc,
+                      unsigned long *pprev_fp, unsigned long *pprev_pc,
+                      unsigned long *retaddr);
+
+static inline long
+get_frame_size (unsigned long instr)
+{
+  return abs ((short signed) (instr & 0xFFFF));
+}
+
+static unsigned long *
+find_frame_creation (unsigned long *pc)
+{
+  int i;
+
+  /* NOTE: Distance to search is arbitrary.
+     250 works well for most things,
+     750 picks up things like tcp_recvmsg,
+     1000 needed for fat_fill_super.  */
+  for (i = 0; i < 1000; i++, pc--)
+    {
+      unsigned long instr;
+      unsigned long frame_size;
+
+      instr = *pc;
+
+      /* Is the instruction of the form
+         addik r1, r1, foo ? */
+      if ((instr & 0xFFFF0000) != 0x30210000)
+        continue;
+
+      frame_size = get_frame_size (instr);
+
+      if ((frame_size < 8) || (frame_size & 3))
+        return NULL;
+
+      return pc;
+    }
+  return NULL;
+}
+
+static int
+lookup_prev_stack_frame (unsigned long fp, unsigned long pc,
+                         unsigned long *pprev_fp, unsigned long *pprev_pc,
+                         unsigned long *retaddr)
+{
+  unsigned long *prologue = NULL;
+
+  int is_signalhandler = _identify_sighandler (fp, pc, pprev_fp,
+                                               pprev_pc, retaddr);
+
+  if (!is_signalhandler)
+    {
+      prologue = find_frame_creation ((unsigned long *) pc);
+
+      if (prologue)
+        {
+          long frame_size = get_frame_size (*prologue);
+          *pprev_fp = fp + frame_size;
+          if (*retaddr != 0)
+            *pprev_pc = *retaddr;
+          else
+            *pprev_pc = *(unsigned long *) fp;
+
+          *retaddr = 0;
+          if (!*pprev_pc || (*pprev_pc & 3))
+            prologue=0;
+        }
+      else
+        {
+          *pprev_pc = 0;
+          *pprev_fp = fp;
+          *retaddr = 0;
+        }
+    }
+    return (!*pprev_pc || (*pprev_pc & 3)) ? -1 : 0;
+}
+
+int
+__backtrace (void **array, int size)
+{
+  unsigned long pc, fp;
+  unsigned long ppc, pfp;
+  /* Return address(r15) is required in the signal handler case, since the
+     return address of the function which causes the signal may not be
+     recorded in the stack.  */
+  unsigned long retaddr;
+
+  int count;
+  int rc = 0;
+
+  if (size <= 0)
+    return 0;
+
+  __asm__ __volatile__ ("mfs %0, rpc"
+                        : "=r"(pc));
+
+  __asm__ __volatile__ ("add %0, r1, r0"
+                        : "=r"(fp));
+
+  array[0] = (void *) pc;
+  retaddr = 0;
+  for (count = 1; count < size; count++)
+    {
+      rc = lookup_prev_stack_frame (fp, pc, &pfp, &ppc, &retaddr);
+
+      fp = pfp;
+      pc = ppc;
+      array[count] = (void *) pc;
+      if (rc)
+        return count;
+    }
+  return count;
+}
+
+weak_alias (__backtrace, backtrace)
+libc_hidden_def (__backtrace)
diff --git a/REORG.TODO/sysdeps/microblaze/backtrace_linux.c b/REORG.TODO/sysdeps/microblaze/backtrace_linux.c
new file mode 100644
index 0000000000..2fe3c5cb30
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/backtrace_linux.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2005-2017 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 <stddef.h>
+#include <asm/sigcontext.h>
+#include <linux/signal.h>
+#include <asm-generic/ucontext.h>
+#include <asm/unistd.h>
+
+int
+_identify_sighandler (unsigned long fp, unsigned long pc,
+                      unsigned long *pprev_fp, unsigned long *pprev_pc,
+                      unsigned long *retaddr)
+{
+  unsigned long *tramp = 0;
+  struct ucontext *uc;
+
+  if (*retaddr == 0)
+    {
+      /* Kernel inserts the tramp between the signal handler frame and the
+         caller frame in signal handling.  */
+      tramp = (unsigned long *) pc;
+      tramp += 2;
+      if ((*tramp == (0x31800000 | __NR_rt_sigreturn))
+          && (*(tramp+1) == 0xb9cc0008))
+        {
+          /* Signal handler function argument are:
+             int sig_num, siginfo_t * info, void * ucontext
+             therefore ucontext is the 3rd argument.  */
+          unsigned long ucptr = ((unsigned long) tramp
+                                 - sizeof (struct ucontext));
+          uc = (struct ucontext *) ucptr;
+          *pprev_pc = uc->uc_mcontext.regs.pc;
+          /* Need to record the return address since the return address of the
+             function which causes this signal may not be recorded in the
+             stack.  */
+          *pprev_fp = uc->uc_mcontext.regs.r1;
+          *retaddr = uc->uc_mcontext.regs.r15;
+          /* It is a signal handler.  */
+          return 1;
+        }
+    }
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/microblaze/bits/endian.h b/REORG.TODO/sysdeps/microblaze/bits/endian.h
new file mode 100644
index 0000000000..fff19505b6
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bits/endian.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 1997-2017 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 _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+/* MicroBlaze can be either big or little endian.  */
+#ifdef _BIG_ENDIAN
+# define __BYTE_ORDER __BIG_ENDIAN
+# define __FLOAT_WORD_ORDER __BIG_ENDIAN
+#else
+# define __BYTE_ORDER __LITTLE_ENDIAN
+# define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/bits/fenv.h b/REORG.TODO/sysdeps/microblaze/bits/fenv.h
new file mode 100644
index 0000000000..7ee3251c1b
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bits/fenv.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 2011-2017 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
+
+/* MicroBlaze supports only round-to-nearest.  The software
+   floating-point support also acts this way.  */
+enum
+  {
+    __FE_UNDEFINED = 0,
+
+    FE_TONEAREST =
+#define FE_TONEAREST	0x1
+    FE_TONEAREST,
+  };
+
+#define FE_ALL_EXCEPT 0
+
+/* Type representing exception flags (if there were any).  */
+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 *) -1l)
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT)
+/* Type representing floating-point control modes.  */
+typedef unsigned int femode_t;
+
+/* Default floating-point control modes.  */
+# define FE_DFL_MODE	((const femode_t *) -1L)
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/bits/link.h b/REORG.TODO/sysdeps/microblaze/bits/link.h
new file mode 100644
index 0000000000..2e1f06b6b3
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bits/link.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2005-2017 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 Microblaze.  */
+typedef struct La_microblaze_regs
+{
+  uint32_t lr_r0;
+  uint32_t lr_r1;
+  uint32_t lr_sp;
+} La_microblaze_regs;
+
+/* Return values for calls from PLT on Microblaze.  */
+typedef struct La_microblaze_retval
+{
+  uint32_t lrv_r3;
+} La_microblaze_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf32_Addr la_microblaze_gnu_pltenter (Elf32_Sym *__sym,
+                                              unsigned int __ndx,
+                                              uintptr_t *__refcook,
+                                              uintptr_t *__defcook,
+                                              La_microblaze_regs *__regs,
+                                              unsigned int *__flags,
+                                              const char *__symname,
+                                              long int *__framesizep);
+
+extern unsigned int la_microblaze_gnu_pltexit (Elf32_Sym *__sym,
+                                               unsigned int __ndx,
+                                               uintptr_t *__refcook,
+                                               uintptr_t *__defcook,
+                                               const La_microblaze_regs *__inregs,
+                                               La_microblaze_retval *__outregs,
+                                               const char *__symname);
+
+__END_DECLS
diff --git a/REORG.TODO/sysdeps/microblaze/bits/setjmp.h b/REORG.TODO/sysdeps/microblaze/bits/setjmp.h
new file mode 100644
index 0000000000..fd175dac2b
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bits/setjmp.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 1997-2017 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 the machine-dependent type `jmp_buf'.  */
+
+#ifndef _BITS_SETJMP_H
+# define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+typedef struct __jmp_buf_internal_tag
+  {
+    /* There are 21 4-byte registers that should be saved:
+       r1, r2, r13-r31. Actually, there seems no need to save
+       r14, r16, r17, r18 (return addresses for interrupt/exception/trap).  */
+    int *__sp; /* dedicated name for r1.  */
+    long int __gregs[20];
+  } __jmp_buf[1];
+
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/bsd-_setjmp.S b/REORG.TODO/sysdeps/microblaze/bsd-_setjmp.S
new file mode 100644
index 0000000000..75dff29bfe
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bsd-_setjmp.S
@@ -0,0 +1,22 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.
+   Copyright (C) 1997-2017 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 setjmp_name _setjmp
+#define SAVEMASK 0
+
+#include <setjmp.S>
diff --git a/REORG.TODO/sysdeps/microblaze/bsd-setjmp.S b/REORG.TODO/sysdeps/microblaze/bsd-setjmp.S
new file mode 100644
index 0000000000..66456749cd
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/bsd-setjmp.S
@@ -0,0 +1,22 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.
+   Copyright (C) 1995-2017 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 setjmp_name setjmp
+#define SAVEMASK 1
+
+#include <setjmp.S>
diff --git a/REORG.TODO/sysdeps/microblaze/crti.S b/REORG.TODO/sysdeps/microblaze/crti.S
new file mode 100644
index 0000000000..2affed2aed
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/crti.S
@@ -0,0 +1,88 @@
+/* Special .init and .fini section support for MicroBlaze.
+   Copyright (C) 2012-2017 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>
+#include <sysdep.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
+	.globl	_init
+	.type	_init, @function
+_init:
+	addik	r1,r1,-32
+	swi	r20,r1,28
+	mfs	r20,rpc
+	addik	r20,r20,_GLOBAL_OFFSET_TABLE_+8
+	lwi	r3,r20,PREINIT_FUNCTION@GOT
+#if PREINIT_FUNCTION_WEAK
+	beqid   r3,$Lno_weak_fn:
+	swi     r15,r1,0
+	brlid	r15,PREINIT_FUNCTION@PLT
+$Lno_weak_fn:
+#else
+	swi     r15,r1,0
+	brald	r15,r3
+#endif
+	nop		# Unfilled delay slot
+
+	.section .fini,"ax",@progbits
+	.align	2
+	.globl	_fini
+	.type	_fini, @function
+_fini:
+	addik	r1,r1,-32
+	swi	r20,r1,28
+	swi	r15,r1,0
+	mfs	r20,rpc
+	addik	r20,r20,_GLOBAL_OFFSET_TABLE_+8
diff --git a/REORG.TODO/sysdeps/microblaze/crtn.S b/REORG.TODO/sysdeps/microblaze/crtn.S
new file mode 100644
index 0000000000..4f2766a32f
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/crtn.S
@@ -0,0 +1,51 @@
+/* Special .init and .fini section support for MicroBlaze.
+   Copyright (C) 1995-2017 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. */
+
+#include <sysdep.h>
+
+	.section .init,"ax",@progbits
+	lwi	r15,r1,0
+	lwi	r20,r1,28
+	rtsd	r15,8
+	addik	r1,r1,32
+
+	.section .fini,"ax",@progbits
+	lwi	r15,r1,0
+	lwi	r20,r1,28
+	rtsd	r15,8
+	addik	r1,r1,32
diff --git a/REORG.TODO/sysdeps/microblaze/dl-machine.h b/REORG.TODO/sysdeps/microblaze/dl-machine.h
new file mode 100644
index 0000000000..cc80b30868
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/dl-machine.h
@@ -0,0 +1,299 @@
+/* Copyright (C) 1995-2017 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 "microblaze"
+
+#include <sys/param.h>
+#include <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_MICROBLAZE);
+}
+
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+  /* This produces a GOTOFF reloc that resolves to zero at link time, so in
+     fact just loads from the GOT register directly.  By doing it without
+     an asm we can let the compiler choose any register.  */
+
+  Elf32_Addr got_entry_0;
+  __asm__ __volatile__(
+    "lwi %0,r20,0"
+    :"=r"(got_entry_0)
+    );
+  return got_entry_0;
+}
+
+/* Return the run-time load address of the shared object.  */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+  /* Compute the difference between the runtime address of _DYNAMIC as seen
+     by a GOTOFF reference, and the link-time address found in the special
+     unrelocated first GOT entry.  */
+
+  Elf32_Addr dyn;
+  __asm__ __volatile__ (
+    "addik %0,r20,_DYNAMIC@GOTOFF"
+    : "=r"(dyn)
+    );
+  return dyn - elf_machine_dynamic ();
+}
+
+/* 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);
+  extern void _dl_runtime_profile (Elf32_Word);
+
+  return lazy;
+}
+
+/* The PLT uses Elf32_Rela relocs.  */
+#define elf_machine_relplt elf_machine_rela
+
+/* Mask identifying addresses reserved for the user program,
+   where the dynamic linker should not map anything.  */
+#define ELF_MACHINE_USER_ADDRESS_MASK	0x80000000UL
+
+/* 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\
+	addk  r5,r0,r1\n\
+	addk  r3,r0,r0\n\
+1:\n\
+	addik r5,r5,4\n\
+	lw    r4,r5,r0\n\
+	bneid r4,1b\n\
+	addik r3,r3,1\n\
+	addik r3,r3,-1\n\
+	addk  r5,r0,r1\n\
+	sw    r3,r5,r0\n\
+	addik r1,r1,-24\n\
+	sw    r15,r1,r0\n\
+	brlid r15,_dl_start\n\
+	nop\n\
+	/* FALLTHRU.  */\n\
+\n\
+	.globl _dl_start_user\n\
+	.type _dl_start_user,@function\n\
+_dl_start_user:\n\
+	mfs   r20,rpc\n\
+	addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n\
+	lwi   r4,r20,_dl_skip_args@GOTOFF\n\
+	lwi   r5,r1,24\n\
+	rsubk r5,r4,r5\n\
+	addk  r4,r4,r4\n\
+	addk  r4,r4,r4\n\
+	addk  r1,r1,r4\n\
+	swi   r5,r1,24\n\
+	swi   r3,r1,20\n\
+	addk  r6,r5,r0\n\
+	addk  r5,r5,r5\n\
+	addk  r5,r5,r5\n\
+	addik r7,r1,28\n\
+	addk  r8,r7,r5\n\
+	addik r8,r8,4\n\
+	lwi   r5,r20,_rtld_local@GOTOFF\n\
+	brlid r15,_dl_init\n\
+	nop\n\
+	lwi   r5,r1,24\n\
+	lwi   r3,r1,20\n\
+	addk  r4,r5,r5\n\
+	addk  r4,r4,r4\n\
+	addik r6,r1,28\n\
+	addk  r7,r6,r4\n\
+	addik r7,r7,4\n\
+	addik r15,r20,_dl_fini@GOTOFF\n\
+	addik r15,r15,-8\n\
+	brad  r3\n\
+	addik r1,r1,24\n\
+	nop\n\
+	.size _dl_start_user, . - _dl_start_user\n\
+	.previous");
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+   TLS variable, so undefined references should not be allowed to
+   define the value.
+   ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
+   of the main executable's symbols, as for a COPY reloc.  */
+#ifndef RTLD_BOOTSTRAP
+# define elf_machine_type_class(type) \
+  (((type) == R_MICROBLAZE_JUMP_SLOT || \
+    (type) == R_MICROBLAZE_TLSDTPREL32 || \
+    (type) == R_MICROBLAZE_TLSDTPMOD32 || \
+    (type) == R_MICROBLAZE_TLSTPREL32) \
+    * ELF_RTYPE_CLASS_PLT \
+   | ((type) == R_MICROBLAZE_COPY) * ELF_RTYPE_CLASS_COPY)
+#else
+# define elf_machine_type_class(type) \
+  (((type) == R_MICROBLAZE_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT \
+   | ((type) == R_MICROBLAZE_COPY) * ELF_RTYPE_CLASS_COPY)
+#endif
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
+#define ELF_MACHINE_JMP_SLOT	R_MICROBLAZE_JUMP_SLOT
+
+/* The microblaze never uses Elf32_Rel relocations.  */
+#define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
+
+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. Ignore the addend.  */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+		       Elf32_Addr value)
+{
+  return value;
+}
+
+#endif /* !dl_machine_h.  */
+
+/* Names of the architecture-specific auditing callback functions.  */
+#define ARCH_LA_PLTENTER microblaze_gnu_pltenter
+#define ARCH_LA_PLTEXIT microblaze_gnu_pltexit
+
+#ifdef RESOLVE_MAP
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+   MAP is the object containing the reloc.  */
+
+/* Macro to put 32-bit relocation value into 2 words.  */
+#define PUT_REL_64(rel_addr,val) \
+  do { \
+    ((unsigned short *)(rel_addr))[1] = (val) >> 16; \
+    ((unsigned short *)(rel_addr))[3] = (val) & 0xffff; \
+  } while (0)
+
+auto inline void __attribute__ ((always_inline))
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+		  const Elf32_Sym *sym, const struct r_found_version *version,
+		  void *const reloc_addr_arg, int skip_ifunc)
+{
+  Elf32_Addr *const reloc_addr = reloc_addr_arg;
+  const int r_type = ELF32_R_TYPE (reloc->r_info);
+
+  if (__builtin_expect (r_type == R_MICROBLAZE_64_PCREL, 0))
+    PUT_REL_64 (reloc_addr, map->l_addr + reloc->r_addend);
+  else if (r_type == R_MICROBLAZE_REL)
+    *reloc_addr = map->l_addr + reloc->r_addend;
+  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;
+
+      value += reloc->r_addend;
+      if (r_type == R_MICROBLAZE_GLOB_DAT ||
+          r_type == R_MICROBLAZE_JUMP_SLOT ||
+          r_type == R_MICROBLAZE_32)
+	{
+	  *reloc_addr = value;
+	}
+      else if (r_type == R_MICROBLAZE_COPY)
+	{
+	  if (sym != NULL && (sym->st_size > refsym->st_size
+	      || (sym->st_size < refsym->st_size && GLRO (dl_verbose))) )
+	    {
+	      const char *strtab;
+
+	      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+	      _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+				RTLD_PROGNAME, strtab + refsym->st_name);
+	    }
+	  memcpy (reloc_addr_arg, (void *) value,
+		  MIN (sym->st_size, refsym->st_size));
+	}
+      else if (r_type == R_MICROBLAZE_NONE)
+	{
+	}
+#if !defined RTLD_BOOTSTRAP
+      else if (r_type == R_MICROBLAZE_TLSDTPMOD32)
+	{
+	  if (sym_map != NULL)
+	    *reloc_addr = sym_map->l_tls_modid;
+	}
+      else if (r_type == R_MICROBLAZE_TLSDTPREL32)
+	{
+	  if (sym != NULL)
+	    *reloc_addr = sym->st_value + reloc->r_addend;
+	}
+      else if (r_type == R_MICROBLAZE_TLSTPREL32)
+	{
+	  if (sym != NULL)
+	    {
+	      CHECK_STATIC_TLS (map, sym_map);
+	      *reloc_addr = sym->st_value + sym_map->l_tls_offset + reloc->r_addend;
+	    }
+	}
+#endif
+      else
+	{
+	  _dl_reloc_bad_type (map, r_type, 0);
+	}
+    }
+}
+
+auto inline void
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+			   void *const reloc_addr_arg)
+{
+  Elf32_Addr *const reloc_addr = reloc_addr_arg;
+  PUT_REL_64 (reloc_addr, l_addr + reloc->r_addend);
+}
+
+auto inline void
+elf_machine_lazy_rel (struct link_map *map,
+		      Elf32_Addr l_addr, const Elf32_Rela *reloc,
+		      int skip_ifunc)
+{
+  Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+  if (ELF32_R_TYPE (reloc->r_info) == R_MICROBLAZE_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/REORG.TODO/sysdeps/microblaze/dl-tls.h b/REORG.TODO/sysdeps/microblaze/dl-tls.h
new file mode 100644
index 0000000000..1ffe0abac2
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/dl-tls.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 2005-2017 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;
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/REORG.TODO/sysdeps/microblaze/dl-trampoline.S b/REORG.TODO/sysdeps/microblaze/dl-trampoline.S
new file mode 100644
index 0000000000..de3b4b79d3
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/dl-trampoline.S
@@ -0,0 +1,109 @@
+/* Copyright (C) 2005-2017 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>
+
+#ifndef PROF
+
+    .text
+    .globl  _dl_runtime_resolve
+    .type   _dl_runtime_resolve, @function
+    .align  4
+_dl_runtime_resolve:
+    addik r1,r1,-40
+    swi   r5,r1,12
+    swi   r6,r1,16
+    swi   r7,r1,20
+    swi   r8,r1,24
+    swi   r9,r1,28
+    swi   r10,r1,32
+    swi   r15,r1,0
+    addk r5,r0,r4
+    brlid r15, _dl_fixup
+    addk r6,r0,r3; /* delay slot.  */
+    lwi   r10,r1,32
+    lwi   r9,r1,28
+    lwi   r8,r1,24
+    lwi   r7,r1,20
+    lwi   r6,r1,16
+    lwi   r5,r1,12
+    lwi   r15,r1,0
+    brad  r3
+    addik r1,r1,40; /* delay slot.  */
+    .size _dl_runtime_resolve, . - _dl_runtime_resolve
+
+    .text
+    .globl  _dl_runtime_profile
+    .type   _dl_runtime_profile, @function
+    .align  4
+_dl_runtime_profile:
+    addik r1,r1,-40
+    swi   r5,r1,12
+    swi   r6,r1,16
+    swi   r7,r1,20
+    swi   r8,r1,24
+    swi   r9,r1,28
+    swi   r10,r1,32
+    swi   r15,r1,0
+    addk r5,r0,r4
+    brlid r15, _dl_profile_fixup
+    addk r6,r0,r3; /* delay slot.  */
+    lwi   r10,r1,32
+    lwi   r9,r1,28
+    lwi   r8,r1,24
+    lwi   r7,r1,20
+    lwi   r6,r1,16
+    lwi   r5,r1,12
+    lwi   r15,r1,0
+    brad  r3
+    addik r1,r1,40; /* delay slot.  */
+    .size _dl_runtime_profile, . - _dl_runtime_profile
+
+#else
+
+    .text
+    .globl  _dl_runtime_resolve
+    .type   _dl_runtime_resolve, @function
+    .align  4
+_dl_runtime_resolve:
+    addik r1,r1,-40
+    swi   r5,r1,12
+    swi   r6,r1,16
+    swi   r7,r1,20
+    swi   r8,r1,24
+    swi   r9,r1,28
+    swi   r10,r1,32
+    swi   r15,r1,0
+    addk r5,r0,r4
+    brlid r15, fixup
+    addk r6,r0,r3; /* delay slot.  */
+    lwi   r10,r1,32
+    lwi   r9,r1,28
+    lwi   r8,r1,24
+    lwi   r7,r1,20
+    lwi   r6,r1,16
+    lwi   r5,r1,12
+    lwi   r15,r1,0
+    brad  r3
+    addik r1,r1,40; /* delay slot.  */
+    .size _dl_runtime_resolve, . - _dl_runtime_resolve
+    .globl _dl_runtime_profile
+    .set _dl_runtime_profile, _dl_runtime_resolve
+
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/gccframe.h b/REORG.TODO/sysdeps/microblaze/gccframe.h
new file mode 100644
index 0000000000..35fd1cda56
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/gccframe.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 2005-2017 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 78
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/REORG.TODO/sysdeps/microblaze/jmpbuf-unwind.h b/REORG.TODO/sysdeps/microblaze/jmpbuf-unwind.h
new file mode 100644
index 0000000000..06dd83adce
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/jmpbuf-unwind.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2005-2017 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 <stdint.h>
+#include <unwind.h>
+#include <sysdep.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)[0].__sp))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+  _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+static inline uintptr_t __attribute__ ((unused))
+_jmpbuf_sp (__jmp_buf regs)
+{
+  void *sp = (void *) regs[0].__sp;
+#ifdef PTR_DEMANGLE
+  PTR_DEMANGLE (sp);
+#endif
+  return (uintptr_t) sp;
+}
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+  ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
+
+/* We use the normal longjmp for unwinding.  */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/REORG.TODO/sysdeps/microblaze/ldsodefs.h b/REORG.TODO/sysdeps/microblaze/ldsodefs.h
new file mode 100644
index 0000000000..6e01c197d0
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/ldsodefs.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 2005-2017 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 _MICROBLAZE_LDSODEFS_H
+#define _MICROBLAZE_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_microblaze_regs;
+struct La_microblaze_retval;
+
+#define ARCH_PLTENTER_MEMBERS                                                \
+  Elf32_Addr (*microblaze_gnu_pltenter) (Elf32_Sym *, unsigned int,          \
+                                         uintptr_t *,                        \
+                                         uintptr_t *,                        \
+                                         struct La_microblaze_regs *,        \
+                                         unsigned int *, const char *name,   \
+                                         long int *framesizep);
+
+#define ARCH_PLTEXIT_MEMBERS                                                 \
+  unsigned int (*microblaze_gnu_pltexit) (Elf32_Sym *, unsigned int,         \
+                                          uintptr_t *,                       \
+                                          uintptr_t *,                       \
+                                          const struct La_microblaze_regs *, \
+                                          struct La_microblaze_retval *,     \
+                                          const char *);
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/libc-tls.c b/REORG.TODO/sysdeps/microblaze/libc-tls.c
new file mode 100644
index 0000000000..a43d6692e2
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/libc-tls.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2005-2017 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 Microblaze, 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 + ti->ti_offset;
+}
diff --git a/REORG.TODO/sysdeps/microblaze/libm-test-ulps b/REORG.TODO/sysdeps/microblaze/libm-test-ulps
new file mode 100644
index 0000000000..0806905370
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/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/REORG.TODO/sysdeps/microblaze/libm-test-ulps-name b/REORG.TODO/sysdeps/microblaze/libm-test-ulps-name
new file mode 100644
index 0000000000..1edbaa8d98
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/libm-test-ulps-name
@@ -0,0 +1 @@
+MicroBlaze
diff --git a/REORG.TODO/sysdeps/microblaze/machine-gmon.h b/REORG.TODO/sysdeps/microblaze/machine-gmon.h
new file mode 100644
index 0000000000..a73d495e23
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/machine-gmon.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 2011-2017 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/>.  */
+
+/* We need a special version of the `mcount' function because it has
+   to preserve more registers than your usual function.  */
+
+void __mcount_internal (unsigned long frompc, unsigned long selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+void __mcount_internal (unsigned long frompc, unsigned long selfpc)
+
+
+/* Define MCOUNT as empty since we have the implementation in another
+   file.  */
+#define MCOUNT
diff --git a/REORG.TODO/sysdeps/microblaze/math_private.h b/REORG.TODO/sysdeps/microblaze/math_private.h
new file mode 100644
index 0000000000..d82e8bf820
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/math_private.h
@@ -0,0 +1,39 @@
+#ifndef MICROBLAZE_MATH_PRIVATE_H
+#define MICROBLAZE_MATH_PRIVATE_H 1
+
+/* Suppress use of exceptions here to avoid build errors if the FE_*
+   macros aren't definied. Only allow rounding modes implemented for
+   MicroBlaze.
+
+   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; })
+
+/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
+   when built without long double support. */
+#define LDBL_CLASSIFY_COMPAT 1
+
+#include_next <math_private.h>
+
+#define feraiseexcept(excepts)                 ({ 0; })
+#define __feraiseexcept(excepts)               ({ 0; })
+#define feclearexcept(exc)                     ({ 0; })
+
+#endif
diff --git a/REORG.TODO/sysdeps/microblaze/memusage.h b/REORG.TODO/sysdeps/microblaze/memusage.h
new file mode 100644
index 0000000000..644de0765e
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/memusage.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000-2017 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 ("r1"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/REORG.TODO/sysdeps/microblaze/nptl/Makefile b/REORG.TODO/sysdeps/microblaze/nptl/Makefile
new file mode 100644
index 0000000000..3627748ad8
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/Makefile
@@ -0,0 +1,21 @@
+# Copyright (C) 2005-2017 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/REORG.TODO/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h b/REORG.TODO/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
new file mode 100644
index 0000000000..d687e2c076
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 2002-2017 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_ARCH_H
+# define _BITS_PTHREADTYPES_ARCH_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
+
+/* Definitions for internal mutex struct.  */
+#define __PTHREAD_COMPAT_PADDING_MID
+#define __PTHREAD_COMPAT_PADDING_END
+#define __PTHREAD_MUTEX_LOCK_ELISION    0
+
+#define __LOCK_ALIGNMENT
+#define __ONCE_ALIGNMENT
+
+struct __pthread_rwlock_arch_t
+{
+  unsigned int __readers;
+  unsigned int __writers;
+  unsigned int __wrphase_futex;
+  unsigned int __writers_futex;
+  unsigned int __pad3;
+  unsigned int __pad4;
+#  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 __cur_writer;
+};
+
+# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
+#endif	/* bits/pthreadtypes.h.  */
diff --git a/REORG.TODO/sysdeps/microblaze/nptl/bits/semaphore.h b/REORG.TODO/sysdeps/microblaze/nptl/bits/semaphore.h
new file mode 100644
index 0000000000..f1d25cdfef
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/bits/semaphore.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2002-2017 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/REORG.TODO/sysdeps/microblaze/nptl/pthreaddef.h b/REORG.TODO/sysdeps/microblaze/nptl/pthreaddef.h
new file mode 100644
index 0000000000..7141fb414f
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/pthreaddef.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002-2017 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 <stdlib.h>
+#include <string.h>
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE  (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN         16
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK  2048
+
+/* Alignment requirement for TCB.  */
+#define TCB_ALIGNMENT       16
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
diff --git a/REORG.TODO/sysdeps/microblaze/nptl/tcb-offsets.sym b/REORG.TODO/sysdeps/microblaze/nptl/tcb-offsets.sym
new file mode 100644
index 0000000000..614f0dfed6
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/tcb-offsets.sym
@@ -0,0 +1,10 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+#define thread_offsetof(mem)	(long)(offsetof (struct pthread, mem) - sizeof (struct pthread))
+
+MULTIPLE_THREADS_OFFSET	thread_offsetof (header.multiple_threads)
+TID_OFFSET			thread_offsetof (tid)
diff --git a/REORG.TODO/sysdeps/microblaze/nptl/tls.h b/REORG.TODO/sysdeps/microblaze/nptl/tls.h
new file mode 100644
index 0000000000..9703484c0e
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/nptl/tls.h
@@ -0,0 +1,143 @@
+/* Copyright (C) 2005-2017 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>
+# include <dl-dtv.h>
+
+#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;
+  void *private;
+} tcbhead_t;
+
+#define READ_THREAD_POINTER() \
+  ({ register void *__microblaze_thread_area asm ("r21"); \
+     __microblaze_thread_area; })
+
+/* This is the size of the initial TCB.  */
+# define TLS_INIT_TCB_SIZE  sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB.  */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB.  */
+# define TLS_TCB_SIZE       sizeof (tcbhead_t)
+
+/* This is the size we need before TCB.  */
+# define TLS_PRE_TCB_SIZE   sizeof (struct pthread)
+
+/* Alignment requirements for the TCB.  */
+# define TLS_TCB_ALIGN      __alignof__ (struct pthread)
+
+/* 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))->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))->dtv)
+
+/* Code to initially initialize the thread pointer.
+   r21 is reserved for thread pointer.  */
+# define TLS_INIT_TP(tcbp) \
+  ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; })
+
+# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+
+/* Return the address of the dtv for the current thread.  */
+# define THREAD_DTV() \
+  (((tcbhead_t *) READ_THREAD_POINTER())->dtv)
+
+/* Return the thread descriptor for the current thread.  */
+# define THREAD_SELF \
+  (((struct pthread *) READ_THREAD_POINTER()) - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF \
+  CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Read member of the thread descriptor directly.  */
+# define THREAD_GETMEM(descr, member) (descr->member)
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant.  */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+  (descr->member[idx])
+
+/* Set member of the thread descriptor directly.  */
+# define THREAD_SETMEM(descr, member, value) \
+  (descr->member = (value))
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant.  */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+  (descr->member[idx] = (value))
+
+/* 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/REORG.TODO/sysdeps/microblaze/preconfigure b/REORG.TODO/sysdeps/microblaze/preconfigure
new file mode 100644
index 0000000000..90e2e631d9
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/preconfigure
@@ -0,0 +1,3 @@
+case "$machine" in
+microblaze*)	base_machine=microblaze machine=microblaze ;;
+esac
diff --git a/REORG.TODO/sysdeps/microblaze/s_fma.c b/REORG.TODO/sysdeps/microblaze/s_fma.c
new file mode 100644
index 0000000000..d9613fa67c
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/s_fma.c
@@ -0,0 +1 @@
+#include <soft-fp/fmadf4.c>
diff --git a/REORG.TODO/sysdeps/microblaze/s_fmaf.c b/REORG.TODO/sysdeps/microblaze/s_fmaf.c
new file mode 100644
index 0000000000..aa5c9b2d91
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/s_fmaf.c
@@ -0,0 +1 @@
+#include <soft-fp/fmasf4.c>
diff --git a/REORG.TODO/sysdeps/microblaze/setjmp.S b/REORG.TODO/sysdeps/microblaze/setjmp.S
new file mode 100644
index 0000000000..79b8aec490
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/setjmp.S
@@ -0,0 +1,75 @@
+/* Copyright (C) 1997-2017 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>
+
+/* This source produces 3 functions:
+   __sigsetjmp (jmpbuf,savemask)
+   setjmp (jmpbuf) - equivalent to __sigsetjump (jmpbuf, 1)
+   _setjmp (jmpbuf) - equivalent to __sigsetjump (jmpbuf, 0)
+*/
+
+#ifndef setjmp_name
+# define setjmp_name __sigsetjmp
+# define SET_MASK_ARG
+#else
+# define SET_MASK_ARG    addik r6,r0,SAVEMASK
+#endif
+
+ENTRY (setjmp_name)
+    swi   r1,r5,0
+    swi   r2,r5,4
+    swi   r13,r5,8
+    swi   r14,r5,12
+    swi   r15,r5,16
+    swi   r16,r5,20
+    swi   r17,r5,24
+    swi   r18,r5,28
+    swi   r19,r5,32
+    swi   r20,r5,36
+    swi   r21,r5,40
+    swi   r22,r5,44
+    swi   r23,r5,48
+    swi   r24,r5,52
+    swi   r25,r5,56
+    swi   r26,r5,60
+    swi   r27,r5,64
+    swi   r28,r5,68
+    swi   r29,r5,72
+    swi   r30,r5,76
+    swi   r31,r5,80
+
+    SET_MASK_ARG
+
+    /* Make a tail call to __sigjmp_save; it takes the same args.  */
+#ifdef	PIC
+    /* We cannot use the PLT, because it requires that r20 be set, but
+       we can't save and restore our caller's value.  Instead, we do an
+       indirect jump through the GOT, using the temporary register
+       %ecx, which is call-clobbered.  */
+    mfs   r12,rpc
+    addik r12,r12,_GLOBAL_OFFSET_TABLE_+8
+    lwi   r12,r12,__sigjmp_save@GOT
+    brad  r12
+#else
+    brid  __sigjmp_save
+#endif
+    nop
+END (setjmp_name)
+
+libc_hidden_def (setjmp_name)
diff --git a/REORG.TODO/sysdeps/microblaze/sfp-machine.h b/REORG.TODO/sysdeps/microblaze/sfp-machine.h
new file mode 100644
index 0000000000..e4ad79e6bd
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/sfp-machine.h
@@ -0,0 +1 @@
+#include <sysdeps/nios2/sfp-machine.h>
diff --git a/REORG.TODO/sysdeps/microblaze/sotruss-lib.c b/REORG.TODO/sysdeps/microblaze/sotruss-lib.c
new file mode 100644
index 0000000000..cbb7cd21bc
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/sotruss-lib.c
@@ -0,0 +1,52 @@
+/* Override generic sotruss-lib.c to define actual functions for MicroBlaze.
+   Copyright (C) 2012-2017 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_microblaze_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
+                            unsigned int ndx __attribute__ ((unused)),
+                            uintptr_t *refcook, uintptr_t *defcook,
+                            La_microblaze_regs *regs, unsigned int *flags,
+                            const char *symname, long int *framesizep)
+{
+  print_enter (refcook, defcook, symname,
+               regs->lr_r0, regs->lr_r1, regs->lr_sp,
+               *flags);
+
+  /* No need to copy anything, we will not need the parameters in any case.  */
+  *framesizep = 0;
+
+  return sym->st_value;
+}
+
+unsigned int
+la_microblaze_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx,
+                           uintptr_t *refcook,
+                           uintptr_t *defcook,
+                           const struct La_microblaze_regs *inregs,
+                           struct La_microblaze_retval *outregs,
+                           const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_r3);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/microblaze/stackinfo.h b/REORG.TODO/sysdeps/microblaze/stackinfo.h
new file mode 100644
index 0000000000..3062b1e69d
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/stackinfo.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2001-2017 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 MicroBlaze the stack grows down.  */
+# define _STACK_GROWS_DOWN	1
+
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+# define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
+#endif	/* stackinfo.h.  */
diff --git a/REORG.TODO/sysdeps/microblaze/start.S b/REORG.TODO/sysdeps/microblaze/start.S
new file mode 100644
index 0000000000..f94e816ee0
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/start.S
@@ -0,0 +1,84 @@
+/* Copyright (C) 1995-2017 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/>.  */
+
+    .text
+    .globl _start
+    .type _start,@function
+_start:
+    /* On entry the stack contains the following args:
+         r1+0 - argc
+         r1+4 - argv[0]
+         ...
+         r1+4*(argc-1) - argv[argc-1]
+         r1+4*argc - NULL
+         r1+4*argc + 4 - envp[0]
+         ...
+         NULL
+    */
+    addk    r3,r0,r0
+    addk    r5,r1,r0
+1:
+    addik   r5,r5,4
+    lw      r4,r5,r0
+    bneid   r4,1b
+    addik   r3,r3,1
+    addik   r6,r3,-1
+    sw      r6,r1,r0
+    addik   r7,r1,4
+    addik   r1,r1,-24
+#ifdef SHARED
+    /* Setup PIC.  */
+    mfs     r20,rpc
+    addik   r20,r20,_GLOBAL_OFFSET_TABLE_+8
+    lwi     r5,r20,main@GOT
+    lwi     r8,r20,__libc_csu_init@GOT
+    lwi     r9,r20,__libc_csu_fini@GOT
+    brid    __libc_start_main@PLT
+    addk    r10,r0,r0
+#else
+    addik   r5,r0,main
+    addik   r8,r0,__libc_csu_init
+    addik   r9,r0,__libc_csu_fini
+    brid    __libc_start_main
+    addk    r10,r0,r0
+#endif
+
+/* 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/REORG.TODO/sysdeps/microblaze/sysdep.h b/REORG.TODO/sysdeps/microblaze/sysdep.h
new file mode 100644
index 0000000000..1f1ca3709b
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/sysdep.h
@@ -0,0 +1,85 @@
+/* Copyright (C) 1997-2017 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 ALIGNARG(log2) log2
+# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* Define an entry point visible from C.  */
+# define ENTRY(name)                          \
+  .globl C_SYMBOL_NAME(name);                 \
+  .type C_SYMBOL_NAME(name),@function;        \
+  .align ALIGNARG(2);                         \
+  C_LABEL(name)                               \
+  CALL_MCOUNT
+
+# undef END
+# define END(name) ASM_SIZE_DIRECTIVE(name)
+
+
+/* If compiled for profiling, call `_mcount' at the start of each function.  */
+# ifdef  PROF
+/* The mcount code relies on a normal frame pointer being on the stack
+   to locate our caller, so push one just for its benefit.  */
+#  define CALL_MCOUNT                         \
+   addik r1,r1,-4;                            \
+   swi r15,r1,0;                              \
+   brlid r15,JUMPTARGET(mcount);              \
+   nop;                                       \
+   lwi r15,r1,0;                              \
+   addik r1,r1,4;
+# else
+#  define CALL_MCOUNT        /* Do nothing.  */
+# endif
+
+/* Since C identifiers are not normally prefixed with an underscore
+   on this system, the asm identifier `syscall_error' intrudes on the
+   C name space.  Make sure we use an innocuous name.  */
+# define syscall_error   __syscall_error
+# define mcount      _mcount
+
+# define PSEUDO(name, syscall_name, args)     \
+  .globl syscall_error;                       \
+  ENTRY (name)                                \
+    DO_CALL (syscall_name, args);
+
+# define ret                                  \
+  rtsd r15,8; nop;
+
+# undef PSEUDO_END
+# define PSEUDO_END(name)                     \
+  END (name)
+
+# undef JUMPTARGET
+# ifdef PIC
+#  define JUMPTARGET(name)   name##@PLTPC
+# else
+#  define JUMPTARGET(name)   name
+# endif
+
+/* Local label name for asm code.  */
+# ifndef L
+#  define L(name) $L##name
+# endif
+
+# endif  /* __ASSEMBLER__  */
diff --git a/REORG.TODO/sysdeps/microblaze/tls-macros.h b/REORG.TODO/sysdeps/microblaze/tls-macros.h
new file mode 100644
index 0000000000..a12df06e24
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/tls-macros.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2009-2017 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 TLS_LD(x)                                  \
+  ({                                               \
+    char *__result;                                \
+    int __offset;                                  \
+    extern void *__tls_get_addr (void *);          \
+    asm ("mfs r20,rpc \n"                          \
+         "addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n" \
+         "addik %0,r20," #x "@TLSLDM"              \
+         : "=r" (__result));                       \
+    __result = (char *) __tls_get_addr (__result); \
+    asm ("addik %0,r0,"#x"@TLSDTPREL"              \
+         : "=r" (__offset));                       \
+    (int *) (__result + __offset); })
+
+
+#define TLS_GD(x)                                  \
+  ({                                               \
+    int *__result;                                 \
+    extern void *__tls_get_addr (void *);          \
+    asm ("mfs  r20,rpc\n"                          \
+         "addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n" \
+         "addik %0,r20," #x "@TLSGD"               \
+         : "=r" (__result));                       \
+    (int *) __tls_get_addr (__result); })
+
+#define TLS_LE(x) TLS_LD(x)
+
+#define TLS_IE(x) TLS_GD(x)
diff --git a/REORG.TODO/sysdeps/microblaze/tst-audit.h b/REORG.TODO/sysdeps/microblaze/tst-audit.h
new file mode 100644
index 0000000000..e08811ccca
--- /dev/null
+++ b/REORG.TODO/sysdeps/microblaze/tst-audit.h
@@ -0,0 +1,25 @@
+/* Definitions for testing PLT entry/exit auditing.  MicroBlaze version.
+
+   Copyright (C) 2012-2017 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_microblaze_gnu_pltenter
+#define pltexit    la_microblaze_gnu_pltexit
+#define La_regs    La_microblaze_regs
+#define La_retval  La_microblaze_retval
+#define int_retval lrv_r3