about summary refs log tree commit diff
path: root/REORG.TODO/sysdeps/sh
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/sh')
-rw-r--r--REORG.TODO/sysdeps/sh/Implies4
-rw-r--r--REORG.TODO/sysdeps/sh/Makefile11
-rw-r--r--REORG.TODO/sysdeps/sh/____longjmp_chk.S78
-rw-r--r--REORG.TODO/sysdeps/sh/_mcount.S87
-rw-r--r--REORG.TODO/sysdeps/sh/abort-instr.h3
-rw-r--r--REORG.TODO/sysdeps/sh/backtrace.c1
-rw-r--r--REORG.TODO/sysdeps/sh/bits/endian.h13
-rw-r--r--REORG.TODO/sysdeps/sh/bits/fenv.h84
-rw-r--r--REORG.TODO/sysdeps/sh/bits/huge_val.h54
-rw-r--r--REORG.TODO/sysdeps/sh/bits/link.h69
-rw-r--r--REORG.TODO/sysdeps/sh/bits/setjmp.h46
-rw-r--r--REORG.TODO/sysdeps/sh/bsd-_setjmp.S51
-rw-r--r--REORG.TODO/sysdeps/sh/bsd-setjmp.S50
-rw-r--r--REORG.TODO/sysdeps/sh/configure5
-rw-r--r--REORG.TODO/sysdeps/sh/configure.ac6
-rw-r--r--REORG.TODO/sysdeps/sh/crti.S120
-rw-r--r--REORG.TODO/sysdeps/sh/crtn.S53
-rw-r--r--REORG.TODO/sysdeps/sh/dl-machine.h466
-rw-r--r--REORG.TODO/sysdeps/sh/dl-tls.h28
-rw-r--r--REORG.TODO/sysdeps/sh/dl-trampoline.S430
-rw-r--r--REORG.TODO/sysdeps/sh/fpu_control.h76
-rw-r--r--REORG.TODO/sysdeps/sh/gccframe.h21
-rw-r--r--REORG.TODO/sysdeps/sh/gmp-mparam.h29
-rw-r--r--REORG.TODO/sysdeps/sh/jmpbuf-offsets.h19
-rw-r--r--REORG.TODO/sysdeps/sh/jmpbuf-unwind.h46
-rw-r--r--REORG.TODO/sysdeps/sh/ldsodefs.h40
-rw-r--r--REORG.TODO/sysdeps/sh/libc-tls.c32
-rw-r--r--REORG.TODO/sysdeps/sh/libm-test-ulps417
-rw-r--r--REORG.TODO/sysdeps/sh/libm-test-ulps-name1
-rw-r--r--REORG.TODO/sysdeps/sh/linkmap.h5
-rw-r--r--REORG.TODO/sysdeps/sh/machine-gmon.h30
-rw-r--r--REORG.TODO/sysdeps/sh/math_private.h10
-rw-r--r--REORG.TODO/sysdeps/sh/memcpy.S198
-rw-r--r--REORG.TODO/sysdeps/sh/memset.S88
-rw-r--r--REORG.TODO/sysdeps/sh/memusage.h20
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/bits/pthreadtypes-arch.h69
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/bits/semaphore.h35
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/pthread_spin_init.c19
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/pthread_spin_lock.c33
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/pthread_spin_trylock.S31
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/pthread_spin_unlock.S29
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/pthreaddef.h34
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/tcb-offsets.sym15
-rw-r--r--REORG.TODO/sysdeps/sh/nptl/tls.h168
-rw-r--r--REORG.TODO/sysdeps/sh/preconfigure6
-rw-r--r--REORG.TODO/sysdeps/sh/s_fma.c5
-rw-r--r--REORG.TODO/sysdeps/sh/s_fmaf.c5
-rw-r--r--REORG.TODO/sysdeps/sh/sh3/__longjmp.S63
-rw-r--r--REORG.TODO/sysdeps/sh/sh3/setjmp.S81
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/Makefile3
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/Versions5
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/__longjmp.S73
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S4
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c42
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c39
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c34
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c27
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c35
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c44
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c36
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c45
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c41
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c75
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c39
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/setjmp.S90
-rw-r--r--REORG.TODO/sysdeps/sh/soft-fp/sfp-machine.h57
-rw-r--r--REORG.TODO/sysdeps/sh/sotruss-lib.c50
-rw-r--r--REORG.TODO/sysdeps/sh/stackguard-macros.h6
-rw-r--r--REORG.TODO/sysdeps/sh/stackinfo.h33
-rw-r--r--REORG.TODO/sysdeps/sh/start.S111
-rw-r--r--REORG.TODO/sysdeps/sh/strlen.S83
-rw-r--r--REORG.TODO/sysdeps/sh/sysdep.h75
-rw-r--r--REORG.TODO/sysdeps/sh/tininess.h1
-rw-r--r--REORG.TODO/sysdeps/sh/tls-macros.h143
-rw-r--r--REORG.TODO/sysdeps/sh/tst-audit.h25
81 files changed, 4710 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/sh/Implies b/REORG.TODO/sysdeps/sh/Implies
new file mode 100644
index 0000000000..1fdc53d034
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/Implies
@@ -0,0 +1,4 @@
+sh/soft-fp
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/REORG.TODO/sysdeps/sh/Makefile b/REORG.TODO/sysdeps/sh/Makefile
new file mode 100644
index 0000000000..0c6db9a9d4
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/Makefile
@@ -0,0 +1,11 @@
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
+
+ifeq ($(subdir),gmon)
+sysdep_routines += _mcount
+endif
+
+ifeq ($(subdir),debug)
+CFLAGS-backtrace.c += -funwind-tables
+endif
diff --git a/REORG.TODO/sysdeps/sh/____longjmp_chk.S b/REORG.TODO/sysdeps/sh/____longjmp_chk.S
new file mode 100644
index 0000000000..e49c08f027
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/____longjmp_chk.S
@@ -0,0 +1,78 @@
+/* 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/>.  */
+
+	.section .rodata.str1.1,"aMS",@progbits,1
+	.type	longjmp_msg,@object
+longjmp_msg:
+	.string "longjmp causes uninitialized stack frame"
+	.size	longjmp_msg, .-longjmp_msg
+	.text
+
+#define __longjmp ____longjmp_chk
+
+#ifdef PIC
+# define CALL_FAIL \
+	mov.l	.Lfail, r1;				\
+	mov.l	.Lstr, r4;				\
+	mov.l	r12, @-r15;				\
+	cfi_remember_state;				\
+	cfi_adjust_cfa_offset (4);			\
+	cfi_rel_offset (r12, 0);			\
+	mova	.Lgot, r0;				\
+	mov.l	.Lgot, r12;				\
+	add	r0, r12;				\
+	sts.l	pr, @-r15;				\
+	cfi_adjust_cfa_offset (4);			\
+	cfi_rel_offset (pr, 0);				\
+	bsrf	r1;					\
+	 add	r12, r4;				\
+	/* Unreachable.	 */				\
+.Lfail0:						\
+	.align	2;					\
+.Lgot:							\
+	.long	_GLOBAL_OFFSET_TABLE_;			\
+.Lstr:							\
+	.long	longjmp_msg@GOTOFF;			\
+.Lfail:							\
+	.long	__GI___fortify_fail@PLT-(.Lfail0-.);	\
+	cfi_restore_state;
+#else
+# define CALL_FAIL \
+	mov.l	.Lfail, r1;				\
+	mov.l	.Lstr, r4;				\
+	sts.l	pr, @-r15;				\
+	cfi_remember_state;				\
+	cfi_adjust_cfa_offset (4);			\
+	cfi_rel_offset (pr, 0);				\
+	jsr	@r1;					\
+	 nop;						\
+	/* Unreachable.	 */				\
+	.align	2;					\
+.Lstr:							\
+	.long	longjmp_msg;				\
+.Lfail:							\
+	.long	__fortify_fail;				\
+	cfi_restore_state;
+#endif
+
+#define CHECK_SP(reg) \
+	cmp/hs	r15, reg;				\
+	bt	.Lok;					\
+	CALL_FAIL					\
+.Lok:
+
+#include <__longjmp.S>
diff --git a/REORG.TODO/sysdeps/sh/_mcount.S b/REORG.TODO/sysdeps/sh/_mcount.S
new file mode 100644
index 0000000000..1deee2ddad
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/_mcount.S
@@ -0,0 +1,87 @@
+/* Machine-specific calling sequence for `mcount' profiling function.  SuperH
+   Copyright (C) 2001-2017 Free Software Foundation, Inc.
+   Contributed by NIIBE Yutaka <gniibe@m17n.org>
+   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>
+
+	.globl C_SYMBOL_NAME(_mcount)
+	.type C_SYMBOL_NAME(_mcount),@function
+	cfi_startproc
+	.align	5
+C_LABEL(_mcount)
+	/* Save registers.  */
+	mov.l	r4,@-r15
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r4, 0)
+	mov.l	r5,@-r15
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r5, 0)
+	mov.l	r6,@-r15
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r6, 0)
+	mov.l	r7,@-r15
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (r7, 0)
+	sts.l	pr,@-r15
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (pr, 0)
+
+	mov.l	@(20,r15),r4
+	sts	pr,r5
+
+#ifdef SHARED
+	mov.l	0f,r1
+	mova	0f,r0
+	add	r1,r0
+	mov.l	1f,r1
+	mov.l	@(r0,r1),r1
+#else
+	mov.l	1f,r1
+#endif
+	jsr	@r1
+	 nop
+
+	/* Pop the saved registers.  */
+	lds.l	@r15+,pr
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (pr)
+	mov.l	@r15+,r7
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r7)
+	mov.l	@r15+,r6
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r6)
+	mov.l	@r15+,r5
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (r5)
+	rts
+	 mov.l	@r15+,r4
+	/* Omit CFI for restore in delay slot.  */
+
+	.align 2
+#ifdef SHARED
+0:	.long	_GLOBAL_OFFSET_TABLE_
+1:	.long	C_SYMBOL_NAME(__mcount_internal)@GOT
+#else
+1:	.long	C_SYMBOL_NAME(__mcount_internal)
+#endif
+	cfi_endproc
+ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
+
+#undef mcount
+weak_alias (_mcount, mcount)
diff --git a/REORG.TODO/sysdeps/sh/abort-instr.h b/REORG.TODO/sysdeps/sh/abort-instr.h
new file mode 100644
index 0000000000..69381aec8e
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/abort-instr.h
@@ -0,0 +1,3 @@
+/* An instruction which should crash any program is `sleep'.  */
+#define ABORT_INSTRUCTION_ASM sleep
+#define ABORT_INSTRUCTION asm ("sleep")
diff --git a/REORG.TODO/sysdeps/sh/backtrace.c b/REORG.TODO/sysdeps/sh/backtrace.c
new file mode 100644
index 0000000000..4f3eafb09c
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/backtrace.c
@@ -0,0 +1 @@
+#include "../x86_64/backtrace.c"
diff --git a/REORG.TODO/sysdeps/sh/bits/endian.h b/REORG.TODO/sysdeps/sh/bits/endian.h
new file mode 100644
index 0000000000..1fef1ff938
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bits/endian.h
@@ -0,0 +1,13 @@
+/* SH is bi-endian but with a big-endian FPU.  */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#ifdef __LITTLE_ENDIAN__
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#define __FLOAT_WORD_ORDER __BIG_ENDIAN
+#endif
diff --git a/REORG.TODO/sysdeps/sh/bits/fenv.h b/REORG.TODO/sysdeps/sh/bits/fenv.h
new file mode 100644
index 0000000000..a121efb101
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bits/fenv.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1999-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
+
+
+/* Define bits representing the exception.  We use the bit positions
+   of the appropriate bits in the FPU control word.  */
+enum
+  {
+    FE_INEXACT =
+#define FE_INEXACT	0x04
+      FE_INEXACT,
+    FE_UNDERFLOW =
+#define FE_UNDERFLOW	0x08
+      FE_UNDERFLOW,
+    FE_OVERFLOW =
+#define FE_OVERFLOW	0x10
+      FE_OVERFLOW,
+    FE_DIVBYZERO =
+#define FE_DIVBYZERO	0x20
+      FE_DIVBYZERO,
+    FE_INVALID =
+#define FE_INVALID	0x40
+      FE_INVALID,
+  };
+
+#define FE_ALL_EXCEPT \
+	(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The SH FPU supports two of the four defined rounding modes: round to nearest
+   and round to zero.  We use again the bit positions in the FPU control word
+   as the values for the appropriate macros.  */
+enum
+  {
+    __FE_UNDEFINED = -1,
+
+    FE_TONEAREST =
+#define FE_TONEAREST	0x0
+      FE_TONEAREST,
+    FE_TOWARDZERO =
+#define FE_TOWARDZERO	0x1
+      FE_TOWARDZERO,
+  };
+
+
+/* Type representing exception flags.  */
+typedef unsigned short int fexcept_t;
+
+
+/* Type representing floating-point environment.  This function corresponds
+   to the layout of the block written by the `fstenv'.  */
+typedef struct
+  {
+    unsigned int __fpscr;
+  }
+fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV	((const fenv_t *) -1)
+
+#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/sh/bits/huge_val.h b/REORG.TODO/sysdeps/sh/bits/huge_val.h
new file mode 100644
index 0000000000..aab7a23b17
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bits/huge_val.h
@@ -0,0 +1,54 @@
+/* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity).
+   Used by <stdlib.h> and <math.h> functions for overflow.
+   SH version.
+   Copyright (C) 1992-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 _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+/* IEEE positive infinity (-HUGE_VAL is negative infinity).  */
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VAL	(__builtin_huge_val())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VAL	(__extension__ 0x1.0p2047)
+#elif defined __GNUC__
+
+#  define HUGE_VAL \
+  (__extension__							      \
+   ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; })   \
+    { __l: 0x000000007ff00000ULL }).__d)
+
+#else /* not GCC */
+
+# include <endian.h>
+
+typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
+
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define __HUGE_VAL_bytes	{ 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 }
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define __HUGE_VAL_bytes	{ 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
+# endif
+
+static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
+# define HUGE_VAL	(__huge_val.__d)
+
+#endif	/* GCC.  */
diff --git a/REORG.TODO/sysdeps/sh/bits/link.h b/REORG.TODO/sysdeps/sh/bits/link.h
new file mode 100644
index 0000000000..0427ebc961
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bits/link.h
@@ -0,0 +1,69 @@
+/* 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 SH.  */
+typedef struct La_sh_regs
+{
+  uint32_t lr_r2;
+  uint32_t lr_r3;
+  uint32_t lr_r4;
+  uint32_t lr_r5;
+  uint32_t lr_r6;
+  uint32_t lr_r7;
+  uint32_t lr_fpscr;
+  float lr_fr4;
+  float lr_fr5;
+  float lr_fr6;
+  float lr_fr7;
+  float lr_fr8;
+  float lr_fr9;
+  float lr_fr10;
+  float lr_fr11;
+} La_sh_regs;
+
+/* Return values for calls from PLT on SH.  */
+typedef struct La_sh_retval
+{
+  uint32_t lrv_r0;
+  uint32_t lrv_r1;
+  float lrv_fr0;
+  float lrv_fr1;
+} La_sh_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf32_Addr la_sh_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+				      uintptr_t *__refcook,
+				      uintptr_t *__defcook,
+				      La_sh_regs *__regs,
+				      unsigned int *__flags,
+				      const char *__symname,
+				      long int *__framesizep);
+extern unsigned int la_sh_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+				       uintptr_t *__refcook,
+				       uintptr_t *__defcook,
+				       const La_sh_regs *__inregs,
+				       La_sh_retval *__outregs,
+				       const char *__symname);
+
+__END_DECLS
diff --git a/REORG.TODO/sysdeps/sh/bits/setjmp.h b/REORG.TODO/sysdeps/sh/bits/setjmp.h
new file mode 100644
index 0000000000..11617d7c8a
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bits/setjmp.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 1999-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'.  SH version. */
+#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
+
+#ifndef _ASM
+typedef struct __jmp_buf_internal_tag
+  {
+    /* Callee-saved registers r8 through r15.  */
+    int __regs[8];
+
+    /* Program counter.  */
+    void * __pc;
+
+    /* The global pointer.  */
+    void * __gbr;
+
+    /* Floating point status register.  */
+    int __fpscr;
+
+    /* Callee-saved floating point registers fr12 through fr15.  */
+    int __fpregs[4];
+  } __jmp_buf[1];
+#endif
+
+#endif  /* bits/setjmp.h */
diff --git a/REORG.TODO/sysdeps/sh/bsd-_setjmp.S b/REORG.TODO/sysdeps/sh/bsd-_setjmp.S
new file mode 100644
index 0000000000..d5d011ec6c
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bsd-_setjmp.S
@@ -0,0 +1,51 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  SH version.
+   Copyright (C) 1999-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 just does a tail-call to `__sigsetjmp (ARG, 0)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+ENTRY (_setjmp)
+#ifdef SHARED
+	mova	1f, r0
+	mov.l	1f, r1
+	bra	2f
+	 add	r1, r0
+	.align	2
+1:
+	.long	_GLOBAL_OFFSET_TABLE_
+2:
+	mov.l	3f, r1
+	mov.l	@(r0,r1), r1
+	jmp	@r1
+	 mov	#0, r5
+	.align	2
+3:
+	.long	C_SYMBOL_NAME(__sigsetjmp@GOT)
+#else
+	mov.l	1f, r1
+	jmp	@r1
+	 mov	#0, r5
+	.align	2
+1:
+	.long	C_SYMBOL_NAME(__sigsetjmp)
+#endif
+END (_setjmp)
+libc_hidden_def (_setjmp)
diff --git a/REORG.TODO/sysdeps/sh/bsd-setjmp.S b/REORG.TODO/sysdeps/sh/bsd-setjmp.S
new file mode 100644
index 0000000000..73e4209e73
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/bsd-setjmp.S
@@ -0,0 +1,50 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  SH version.
+   Copyright (C) 1999-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 just does a tail-call to `__sigsetjmp (ARG, 1)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+#ifdef SHARED
+	mova	1f, r0
+	mov.l	1f, r1
+	bra	2f
+	 add	r1, r0
+	.align	2
+1:
+	.long	_GLOBAL_OFFSET_TABLE_
+2:
+	mov.l	3f, r1
+	mov.l	@(r0,r1), r1
+	jmp	@r1
+	 mov	#1, r5
+	.align	2
+3:
+	.long	C_SYMBOL_NAME(__sigsetjmp@GOT)
+#else
+	mov.l	1f, r1
+	jmp	@r1
+	 mov	#1, r5
+	.align	2
+1:
+	.long	C_SYMBOL_NAME(__sigsetjmp)
+#endif
+END (setjmp)
diff --git a/REORG.TODO/sysdeps/sh/configure b/REORG.TODO/sysdeps/sh/configure
new file mode 100644
index 0000000000..110eb65b06
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/configure
@@ -0,0 +1,5 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/sh.
+
+$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
+
diff --git a/REORG.TODO/sysdeps/sh/configure.ac b/REORG.TODO/sysdeps/sh/configure.ac
new file mode 100644
index 0000000000..21400c447d
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/configure.ac
@@ -0,0 +1,6 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/sh.
+
+dnl It is always possible to access static and hidden symbols in an
+dnl position independent way.
+AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/REORG.TODO/sysdeps/sh/crti.S b/REORG.TODO/sysdeps/sh/crti.S
new file mode 100644
index 0000000000..d19de956a6
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/crti.S
@@ -0,0 +1,120 @@
+/* Special .init and .fini section support for SH.
+   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.
+
+   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 5
+	.global	_init
+	.type	_init, @function
+_init:
+	mov.l	r12,@-r15
+	mova	.L12,r0
+	mov.l	.L12,r12
+	mov.l	r14,@-r15
+	add	r0,r12
+	sts.l	pr,@-r15
+#if PREINIT_FUNCTION_WEAK
+	mov.l	.L13,r0
+	mov.l	@(r0,r12),r1
+	tst	r1,r1
+	bt/s	.L8
+	mov	r15,r14
+	mov.l	.L14,r1
+	bsrf	r1
+.LPCS0:
+	nop
+.L8:
+#else
+	mova    .L13,r0
+	mov.l	.L13,r1
+	add	r0,r1
+	jsr	@r1
+	mov    r15,r14
+#endif
+	bra	1f
+	nop
+	.align 2
+.L12:
+	.long	_GLOBAL_OFFSET_TABLE_
+#if PREINIT_FUNCTION_WEAK
+.L13:
+	.long	PREINIT_FUNCTION@GOT
+.L14:
+	.long	PREINIT_FUNCTION@PLT-(.LPCS0+2-(.))
+#else
+.L13:
+	.long	PREINIT_FUNCTION@PLT
+#endif
+1:
+
+	.section	.fini,"ax",@progbits
+	.align 5
+	.global	_fini
+	.type	_fini, @function
+_fini:
+	mov.l	r12,@-r15
+	mova	.L19,r0
+	mov.l	r14,@-r15
+	sts.l	pr,@-r15
+	mov.l	.L19,r12
+	mov	r15,r14
+	add	r0,r12
+	bra	0f
+	nop
+	.align 2
+.L19:
+	.long	_GLOBAL_OFFSET_TABLE_
+0:
diff --git a/REORG.TODO/sysdeps/sh/crtn.S b/REORG.TODO/sysdeps/sh/crtn.S
new file mode 100644
index 0000000000..128f951e90
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/crtn.S
@@ -0,0 +1,53 @@
+/* Special .init and .fini section support for SH.
+   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.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file with other
+   programs, and to distribute those programs without any restriction
+   coming from the use of this file. (The GNU Lesser General Public
+   License restrictions do apply in other respects; for example, they
+   cover modification of the file, and distribution when not linked
+   into another program.)
+
+   Note that people who make modified versions of this file are not
+   obligated to grant this special exception for their modified
+   versions; it is their choice whether to do so. The GNU Lesser
+   General Public License gives permission to release a modified
+   version without this exception; this exception also makes it
+   possible to release a modified version which carries forward this
+   exception.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* crtn.S puts function epilogues in the .init and .fini sections
+   corresponding to the prologues in crti.S. */
+
+	.section .init,"ax",@progbits
+	mov	r14,r15
+	lds.l	@r15+,pr
+	mov.l	@r15+,r14
+	mov.l	@r15+,r12
+	rts
+	nop
+
+	.section .fini,"ax",@progbits
+	mov	r14,r15
+	lds.l	@r15+,pr
+	mov.l	@r15+,r14
+	mov.l	@r15+,r12
+	rts
+	nop
diff --git a/REORG.TODO/sysdeps/sh/dl-machine.h b/REORG.TODO/sysdeps/sh/dl-machine.h
new file mode 100644
index 0000000000..2b468af6fa
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/dl-machine.h
@@ -0,0 +1,466 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  SH version.
+   Copyright (C) 1999-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 "SH"
+
+#include <sys/param.h>
+#include <sysdep.h>
+#include <assert.h>
+
+/* Return nonzero iff ELF header is compatible with the running host.  */
+static inline int __attribute__ ((unused))
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+  return ehdr->e_machine == EM_SH;
+}
+
+
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_dynamic (void)
+{
+  register Elf32_Addr *got;
+  asm ("mov r12,%0" :"=r" (got));
+  return *got;
+}
+
+
+/* Return the run-time load address of the shared object.  */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_load_address (void)
+{
+  Elf32_Addr addr;
+  asm ("mov.l 1f,r0\n\
+	mov.l 3f,r2\n\
+	add r12,r2\n\
+	mov.l @(r0,r12),r0\n\
+	bra 2f\n\
+	 sub r0,r2\n\
+	.align 2\n\
+	1: .long _dl_start@GOT\n\
+	3: .long _dl_start@GOTOFF\n\
+	2: mov r2,%0"
+       : "=r" (addr) : : "r0", "r1", "r2");
+  return addr;
+}
+
+
+/* Set up the loaded object described by L so its unrelocated PLT
+   entries will jump to the on-demand fixup code in dl-runtime.c.  */
+
+static inline int __attribute__ ((unused, always_inline))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+  Elf32_Addr *got;
+  extern void _dl_runtime_resolve (Elf32_Word);
+  extern void _dl_runtime_profile (Elf32_Word);
+
+  if (l->l_info[DT_JMPREL] && lazy)
+    {
+      /* The GOT entries for functions in the PLT have not yet been filled
+	 in.  Their initial contents will arrange when called to load an
+	 offset into the .rela.plt section and _GLOBAL_OFFSET_TABLE_[1],
+	 and then jump to _GLOBAL_OFFSET_TABLE[2].  */
+      got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+      /* If a library is prelinked but we have to relocate anyway,
+	 we have to be able to undo the prelinking of .got.plt.
+	 The prelinker saved us here address of .plt + 36.  */
+      if (got[1])
+	{
+	  l->l_mach.plt = got[1] + l->l_addr;
+	  l->l_mach.gotplt = (Elf32_Addr) &got[3];
+	}
+      got[1] = (Elf32_Addr) l;	/* Identify this shared object.	 */
+
+      /* The got[2] entry contains the address of a function which gets
+	 called to get the address of a so far unresolved function and
+	 jump to it.  The profiling extension of the dynamic linker allows
+	 to intercept the calls to collect information.	 In this case we
+	 don't store the address in the GOT so that all future calls also
+	 end in this function.	*/
+      if (profile)
+	{
+	  got[2] = (Elf32_Addr) &_dl_runtime_profile;
+	  /* Say that we really want profiling and the timers are started.  */
+	  if (GLRO(dl_profile) != NULL
+	      && _dl_name_match_p (GLRO(dl_profile), l))
+	    GL(dl_profile_map) = l;
+	}
+      else
+	/* This function will get called to fix up the GOT entry indicated by
+	   the offset on the stack, and then jump to the resolved address.  */
+	got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+    }
+  return lazy;
+}
+
+#define ELF_MACHINE_RUNTIME_FIXUP_ARGS int plt_type
+#define ELF_MACHINE_RUNTIME_FIXUP_PARAMS plt_type
+
+/* 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\
+.globl _dl_start_user\n\
+_start:\n\
+	mov r15,r4\n\
+	mov.l .L_dl_start,r1\n\
+	mova .L_dl_start,r0\n\
+	add r1,r0\n\
+	jsr @r0\n\
+	 nop\n\
+_dl_start_user:\n\
+	! Save the user entry point address in r8.\n\
+	mov r0,r8\n\
+	! Point r12 at the GOT.\n\
+	mov.l 1f,r12\n\
+	mova 1f,r0\n\
+	bra 2f\n\
+	 add r0,r12\n\
+	.align 2\n\
+1:	.long _GLOBAL_OFFSET_TABLE_\n\
+2:	! See if we were run as a command with the executable file\n\
+	! name as an extra leading argument.\n\
+	mov.l .L_dl_skip_args,r0\n\
+	mov.l @(r0,r12),r0\n\
+	mov.l @r0,r0\n\
+	! Get the original argument count.\n\
+	mov.l @r15,r5\n\
+	! Subtract _dl_skip_args from it.\n\
+	sub r0,r5\n\
+	! Adjust the stack pointer to skip _dl_skip_args words.\n\
+	shll2 r0\n\
+	add r0,r15\n\
+	! Store back the modified argument count.\n\
+	mov.l r5,@r15\n\
+	! Compute argv address and envp.\n\
+	mov r15,r6\n\
+	add #4,r6\n\
+	mov r5,r7\n\
+	shll2 r7\n\
+	add r15,r7\n\
+	add #8,r7\n\
+	mov.l .L_dl_loaded,r0\n\
+	mov.l @(r0,r12),r0\n\
+	mov.l @r0,r4\n\
+	! Call _dl_init.\n\
+	mov.l .L_dl_init,r1\n\
+	mova .L_dl_init,r0\n\
+	add r1,r0\n\
+	jsr @r0\n\
+	 nop\n\
+1:	! Pass our finalizer function to the user in r4, as per ELF ABI.\n\
+	mov.l .L_dl_fini,r0\n\
+	mov.l @(r0,r12),r4\n\
+	! Jump to the user's entry point.\n\
+	jmp @r8\n\
+	 nop\n\
+	.align 2\n\
+.L_dl_start:\n\
+	.long _dl_start@PLT\n\
+.L_dl_skip_args:\n\
+	.long _dl_skip_args@GOT\n\
+.L_dl_init:\n\
+	.long _dl_init@PLT\n\
+.L_dl_loaded:\n\
+	.long _rtld_local@GOT\n\
+.L_dl_fini:\n\
+	.long _dl_fini@GOT\n\
+	.type __fpscr_values,@object\n\
+	.global __fpscr_values\n\
+__fpscr_values:\n\
+	.long   0\n\
+	.long   0x80000\n\
+	.weak __fpscr_values\n\
+.previous\n\
+");
+
+/* 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.  */
+#define elf_machine_type_class(type) \
+  ((((type) == R_SH_JMP_SLOT || (type) == R_SH_TLS_DTPMOD32		      \
+     || (type) == R_SH_TLS_DTPOFF32 || (type) == R_SH_TLS_TPOFF32)	      \
+    * ELF_RTYPE_CLASS_PLT)						      \
+   | (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
+#define ELF_MACHINE_JMP_SLOT	R_SH_JMP_SLOT
+
+/* We define an initialization functions.  This is called very early in
+   _dl_sysdep_start.  */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+  if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
+    /* Avoid an empty string which would disturb us.  */
+    GLRO(dl_platform) = NULL;
+}
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+		       const Elf32_Rela *reloc,
+		       Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+  return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation.	*/
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+		       Elf32_Addr value)
+{
+  return value + reloc->r_addend;
+}
+
+#define ARCH_LA_PLTENTER sh_gnu_pltenter
+#define ARCH_LA_PLTEXIT sh_gnu_pltexit
+
+#endif /* !dl_machine_h */
+
+/* SH never uses Elf32_Rel relocations.	 */
+#define ELF_MACHINE_NO_REL 1
+#define ELF_MACHINE_NO_RELA 0
+
+#ifdef RESOLVE_MAP
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+   MAP is the object containing the reloc.  */
+
+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 unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+  Elf32_Addr value;
+
+#define COPY_UNALIGNED_WORD(swp, twp, align) \
+  { \
+    void *__s = (swp), *__t = (twp); \
+    unsigned char *__s1 = __s, *__t1 = __t; \
+    unsigned short *__s2 = __s, *__t2 = __t; \
+    unsigned long *__s4 = __s, *__t4 = __t; \
+    switch ((align)) \
+    { \
+    case 0: \
+      *__t4 = *__s4; \
+      break; \
+    case 2: \
+      *__t2++ = *__s2++; \
+      *__t2 = *__s2; \
+      break; \
+    default: \
+      *__t1++ = *__s1++; \
+      *__t1++ = *__s1++; \
+      *__t1++ = *__s1++; \
+      *__t1 = *__s1; \
+      break; \
+    } \
+  }
+
+  if (__glibc_unlikely (r_type == R_SH_RELATIVE))
+    {
+#ifndef RTLD_BOOTSTRAP
+      if (map != &GL(dl_rtld_map)) /* Already done in rtld itself.	 */
+#endif
+	{
+	  if (reloc->r_addend)
+	    value = map->l_addr + reloc->r_addend;
+	  else
+	    {
+	      COPY_UNALIGNED_WORD (reloc_addr_arg, &value,
+				   (int) reloc_addr_arg & 3);
+	      value += map->l_addr;
+	    }
+	  COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
+			       (int) reloc_addr_arg & 3);
+	}
+    }
+#ifndef RTLD_BOOTSTRAP
+  else if (__glibc_unlikely (r_type == R_SH_NONE))
+    return;
+#endif
+  else
+    {
+      const Elf32_Sym *const refsym = sym;
+      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+
+      value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+      value += reloc->r_addend;
+
+      switch (r_type)
+	{
+	case R_SH_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
+	  if (sym->st_size > refsym->st_size
+	      || (sym->st_size < refsym->st_size && GLRO(dl_verbose)))
+	    {
+	      const char *strtab;
+
+	      strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+	      _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+				RTLD_PROGNAME, strtab + refsym->st_name);
+	    }
+	  memcpy (reloc_addr_arg, (void *) value,
+		  MIN (sym->st_size, refsym->st_size));
+	  break;
+	case R_SH_GLOB_DAT:
+	case R_SH_JMP_SLOT:
+	  /* These addresses are always aligned.  */
+	  *reloc_addr = value;
+	  break;
+	  /* XXX Remove TLS relocations which are not needed.  */
+	case R_SH_TLS_DTPMOD32:
+#ifdef RTLD_BOOTSTRAP
+	  /* During startup the dynamic linker is always the module
+	     with index 1.
+	     XXX If this relocation is necessary move before RESOLVE
+	     call.  */
+	  *reloc_addr = 1;
+#else
+	  /* Get the information from the link map returned by the
+	     resolv function.  */
+	  if (sym_map != NULL)
+	    *reloc_addr = sym_map->l_tls_modid;
+#endif
+	  break;
+	case R_SH_TLS_DTPOFF32:
+#ifndef RTLD_BOOTSTRAP
+	  /* During relocation all TLS symbols are defined and used.
+	     Therefore the offset is already correct.  */
+	  if (sym != NULL)
+	    *reloc_addr = sym->st_value;
+#endif
+	  break;
+	case R_SH_TLS_TPOFF32:
+	  /* The offset is positive, afterward from the thread pointer.  */
+#ifdef RTLD_BOOTSTRAP
+	  *reloc_addr = map->l_tls_offset + sym->st_value + reloc->r_addend;
+#else
+	  /* We know the offset of object the symbol is contained in.
+	     It is a positive value which will be added to the thread
+	     pointer.  To get the variable position in the TLS block
+	     we add the offset from that of the TLS block.  */
+	  if (sym != NULL)
+	    {
+	      CHECK_STATIC_TLS (map, sym_map);
+	      *reloc_addr = sym_map->l_tls_offset + sym->st_value
+			    + reloc->r_addend;
+	    }
+#endif
+	  break;
+	case R_SH_DIR32:
+	  {
+#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP
+	   /* This is defined in rtld.c, but nowhere in the static
+	      libc.a; make the reference weak so static programs can
+	      still link.  This declaration cannot be done when
+	      compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
+	      rtld.c contains the common defn for _dl_rtld_map, which
+	      is incompatible with a weak decl in the same file.  */
+# ifndef SHARED
+	    weak_extern (_dl_rtld_map);
+# endif
+	    if (map == &GL(dl_rtld_map))
+	      /* Undo the relocation done here during bootstrapping.
+		 Now we will relocate it anew, possibly using a
+		 binding found in the user program or a loaded library
+		 rather than the dynamic linker's built-in definitions
+		 used while loading those libraries.  */
+	      value -= map->l_addr + refsym->st_value + reloc->r_addend;
+#endif
+	    COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
+				 (int) reloc_addr_arg & 3);
+	    break;
+	  }
+	case R_SH_REL32:
+	  value = (value - (Elf32_Addr) reloc_addr);
+	  COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
+			       (int) reloc_addr_arg & 3);
+	  break;
+	default:
+	  _dl_reloc_bad_type (map, r_type, 0);
+	  break;
+	}
+    }
+}
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+			   void *const reloc_addr_arg)
+{
+  Elf32_Addr value;
+
+  if (reloc->r_addend)
+    value = l_addr + reloc->r_addend;
+  else
+    {
+      COPY_UNALIGNED_WORD (reloc_addr_arg, &value, (int) reloc_addr_arg & 3);
+      value += l_addr;
+    }
+  COPY_UNALIGNED_WORD (&value, reloc_addr_arg, (int) reloc_addr_arg & 3);
+
+#undef COPY_UNALIGNED_WORD
+}
+
+auto inline void
+__attribute__ ((always_inline))
+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);
+  /* Check for unexpected PLT reloc type.  */
+  if (ELF32_R_TYPE (reloc->r_info) == R_SH_JMP_SLOT)
+    {
+      if (__builtin_expect (map->l_mach.plt, 0) == 0)
+	*reloc_addr += l_addr;
+      else
+	*reloc_addr =
+	  map->l_mach.plt
+	  + (((Elf32_Addr) reloc_addr) - map->l_mach.gotplt) * 7;
+    }
+  else
+    _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1);
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/REORG.TODO/sysdeps/sh/dl-tls.h b/REORG.TODO/sysdeps/sh/dl-tls.h
new file mode 100644
index 0000000000..3f094a77a0
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker.  SH version.
+   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/>.  */
+
+
+/* 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/sh/dl-trampoline.S b/REORG.TODO/sysdeps/sh/dl-trampoline.S
new file mode 100644
index 0000000000..3dfed100b2
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/dl-trampoline.S
@@ -0,0 +1,430 @@
+/* PLT trampolines.  SH version.
+   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>
+
+	.text
+	.globl _dl_runtime_resolve
+	.type _dl_runtime_resolve, @function
+	cfi_startproc
+	.align 5
+_dl_runtime_resolve:
+	mov.l r2,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r3,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r4,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r5,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r6,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r7,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r12,@-r15
+	cfi_adjust_cfa_offset (4)
+	sts.l macl,@-r15
+	cfi_adjust_cfa_offset (4)
+	sts.l mach,@-r15
+	cfi_adjust_cfa_offset (4)
+	movt r3			! Save T flag.
+	mov.l r3,@-r15
+	cfi_adjust_cfa_offset (4)
+#ifdef HAVE_FPU
+	sts.l	fpscr,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov	#8,r3
+	swap.w	r3,r3
+	lds	r3,fpscr
+	fmov.s	fr11,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr10,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr9,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr8,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr7,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr6,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr5,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr4,@-r15
+	cfi_adjust_cfa_offset (4)
+#endif
+	sts.l pr,@-r15
+	cfi_adjust_cfa_offset (4)
+	tst r0,r0
+	bt 1f
+	mov r0,r2
+1:
+	mov r0,r4		! PLT type
+	mov r2,r5		! link map address
+#ifdef SHARED
+	mov.l 2f,r2
+	mova 2f,r0
+	add r0,r2		! Get GOT address in r2
+	mov.l 3f,r0
+	add r2,r0
+#else
+	mov.l 3f,r0
+#endif
+	jsr @r0			! Call resolver.
+	 mov r1,r6		! reloc offset
+	lds.l @r15+,pr		! Get register content back.
+	cfi_adjust_cfa_offset (-4)
+#ifdef HAVE_FPU
+	fmov.s	@r15+,fr4
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr5
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr6
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr7
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr8
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr9
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr10
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr11
+	cfi_adjust_cfa_offset (-4)
+	lds.l	@r15+,fpscr
+	cfi_adjust_cfa_offset (-4)
+#endif
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	shal r3			! Lode T flag.
+	lds.l @r15+,mach
+	cfi_adjust_cfa_offset (-4)
+	lds.l @r15+,macl
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r12
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r7
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r6
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r5
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r4
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	jmp @r0			! Jump to function address.
+	 mov.l @r15+,r2
+	cfi_adjust_cfa_offset (-4)
+	.align 2
+#ifdef SHARED
+2:	.long _GLOBAL_OFFSET_TABLE_
+3:	.long _dl_fixup@GOTOFF
+#else
+3:	.long _dl_fixup
+#endif
+	cfi_endproc
+	.size _dl_runtime_resolve, .-_dl_runtime_resolve
+
+
+	.globl _dl_runtime_profile
+	.type _dl_runtime_profile,@function
+	cfi_startproc
+	.align 5
+_dl_runtime_profile:
+	mov.l r12,@-r15
+	cfi_adjust_cfa_offset (4)
+#ifdef HAVE_FPU
+	sts.l	fpscr,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov	#8,r12
+	swap.w	r12,r12
+	lds	r12,fpscr
+	fmov.s	fr11,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr10,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr9,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr8,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr7,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr6,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr5,@-r15
+	cfi_adjust_cfa_offset (4)
+	fmov.s	fr4,@-r15
+	cfi_adjust_cfa_offset (4)
+#else
+	add #-36,r15
+	cfi_adjust_cfa_offset (36)
+#endif
+	mov.l r7,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r6,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r5,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r4,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r3,@-r15
+	cfi_adjust_cfa_offset (4)
+	mov.l r2,@-r15
+	cfi_adjust_cfa_offset (4)
+	sts.l macl,@-r15
+	cfi_adjust_cfa_offset (4)
+	sts.l mach,@-r15
+	cfi_adjust_cfa_offset (4)
+	movt r3			! Save T flag.
+	mov.l r3,@-r15
+	cfi_adjust_cfa_offset (4)
+	sts.l pr,@-r15
+	cfi_adjust_cfa_offset (4)
+	tst r0,r0
+	bt 1f
+	mov r0,r2
+1:
+	mov r0,r4		! PLT type
+	mov r2,r5		! link map address
+	sts pr,r7		! return address
+	add #-24,r15
+	cfi_adjust_cfa_offset (24)
+	mov #40,r0
+	add r15,r0
+	mov.l r0,@r15		! Address of the register structure
+	mov #-1,r0
+	mov.l r0,@(8,r15)
+	mov #8,r0
+	add r15,r0
+	mov.l r0,@(4,r15)
+	mov.l r5,@(12,r15)
+	mov.l r1,@(16,r15)
+#ifdef SHARED
+	mov.l 2f,r12
+	mova 2f,r0
+	add r0,r12		! Get GOT address in r12
+	mov.l 3f,r0
+	add r12,r0
+#else
+	mov.l 3f,r0
+#endif
+	jsr @r0			! Call resolver.
+	 mov r1,r6		! reloc offset
+	mov.l @(8,r15),r1
+	cmp/pz r1
+	bt 4f
+	add #24,r15
+	cfi_adjust_cfa_offset (-24)
+	lds.l @r15+,pr		! Get register content back.
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	shal r3			! Lode T flag.
+	lds.l @r15+,mach
+	cfi_adjust_cfa_offset (-4)
+	lds.l @r15+,macl
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r2
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r4
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r5
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r6
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r7
+	cfi_adjust_cfa_offset (-4)
+#ifdef HAVE_FPU
+	fmov.s	@r15+,fr4
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr5
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr6
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr7
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr8
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr9
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr10
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr11
+	cfi_adjust_cfa_offset (-4)
+	lds.l	@r15+,fpscr
+	cfi_adjust_cfa_offset (-4)
+#else
+	add #36,r15
+	cfi_adjust_cfa_offset (-36)
+#endif
+	jmp @r0			! Jump to function address.
+	 mov.l @r15+,r12
+	cfi_adjust_cfa_offset (-4)
+	.align 2
+#ifdef SHARED
+2:	.long _GLOBAL_OFFSET_TABLE_
+3:	.long _dl_profile_fixup@GOTOFF
+#else
+3:	.long _dl_profile_fixup
+#endif
+
+	cfi_adjust_cfa_offset (104)
+4:
+	mov #104,r3
+	add r15,r3		! Original stack
+	mov.l r8,@(20,r15)
+	cfi_rel_offset (r8, 20)
+	mov r15,r8
+	sub r1,r15
+	shlr2 r15
+	shll2 r15
+	mov r15,r4
+	shlr2 r1
+	tst r1,r1
+5:
+	bt/s 6f
+	 dt r1
+	mov.l @r3+,r2
+	mov.l r2,@r4
+	bra 5b
+	 add #4,r4
+6:
+	mov.l @r8,r12
+	mov.l @r12+,r2
+	mov.l @r12+,r3
+	mov.l @r12+,r4
+	mov.l @r12+,r5
+	mov.l @r12+,r6
+	mov.l @r12+,r7
+#ifdef HAVE_FPU
+	fmov.s	@r12+,fr4
+	fmov.s	@r12+,fr5
+	fmov.s	@r12+,fr6
+	fmov.s	@r12+,fr7
+	fmov.s	@r12+,fr8
+	fmov.s	@r12+,fr9
+	fmov.s	@r12+,fr10
+	fmov.s	@r12+,fr11
+	lds.l	@r12+,fpscr
+#else
+	add #36,r2
+#endif
+	jsr @r0			! Call function.
+	 nop
+	mov r8,r15
+	mov.l @(12,r15),r4	! link map address
+	mov.l @(16,r15),r5	! reloc offset
+	mov.l @r15,r6		! input registers
+#ifdef HAVE_FPU
+	mov #16,r8
+	add r15,r8
+	fmov.s fr1,@-r8
+	fmov.s fr0,@-r8
+#else
+	mov #8,r8
+	add r15,r8
+#endif
+	mov.l r1,@-r8
+	mov.l r0,@-r8
+	mov.l @(20,r15),r8
+	cfi_restore (r8)
+#ifdef SHARED
+	mov.l 7f,r12
+	mova 7f,r0
+	add r0,r12		! Get GOT address in r12
+	mov.l 8f,r0
+	add r12,r0
+#else
+	mov.l 8f,r0
+#endif
+	jsr @r0
+	 mov r15,r7		! output registers
+	mov.l @r15+,r0
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r1
+	cfi_adjust_cfa_offset (-4)
+#ifdef HAVE_FPU
+	fmov.s @r15+,fr0
+	cfi_adjust_cfa_offset (-4)
+	fmov.s @r15+,fr1
+	cfi_adjust_cfa_offset (-4)
+	add #8,r15
+	cfi_adjust_cfa_offset (-8)
+#else
+	add #16,r15
+	cfi_adjust_cfa_offset (-16)
+#endif
+	lds.l @r15+,pr		! Get register content back.
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	shal r3			! Lode T flag.
+	lds.l @r15+,mach
+	cfi_adjust_cfa_offset (-4)
+	lds.l @r15+,macl
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r2
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r3
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r4
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r5
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r6
+	cfi_adjust_cfa_offset (-4)
+	mov.l @r15+,r7
+	cfi_adjust_cfa_offset (-4)
+#ifdef HAVE_FPU
+	fmov.s	@r15+,fr4
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr5
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr6
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr7
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr8
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr9
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr10
+	cfi_adjust_cfa_offset (-4)
+	fmov.s	@r15+,fr11
+	cfi_adjust_cfa_offset (-4)
+	lds.l	@r15+,fpscr
+	cfi_adjust_cfa_offset (-4)
+#else
+	add #36,r15
+	cfi_adjust_cfa_offset (-36)
+#endif
+	rts			! Jump to function address.
+	 mov.l @r15+,r12
+	cfi_adjust_cfa_offset (-4)
+	cfi_endproc
+	.align 2
+#ifdef SHARED
+7:	.long _GLOBAL_OFFSET_TABLE_
+8:	.long _dl_call_pltexit@GOTOFF
+#else
+8:	.long _dl_call_pltexit
+#endif
+	.size _dl_runtime_profile, .-_dl_runtime_profile
diff --git a/REORG.TODO/sysdeps/sh/fpu_control.h b/REORG.TODO/sysdeps/sh/fpu_control.h
new file mode 100644
index 0000000000..df2627ad1e
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/fpu_control.h
@@ -0,0 +1,76 @@
+/* FPU control word definitions.  SH version.
+   Copyright (C) 1999-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 _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+#if !defined(__SH_FPU_ANY__)
+
+#define _FPU_RESERVED 0xffffffff
+#define _FPU_DEFAULT  0x00000000
+typedef unsigned int fpu_control_t;
+#define _FPU_GETCW(cw) (cw) = 0
+#define _FPU_SETCW(cw) (void) (cw)
+extern fpu_control_t __fpu_control;
+
+#else
+
+#include <features.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_VM	0x0800	/* Invalid operation */
+#define _FPU_MASK_ZM	0x0400	/* Division by zero  */
+#define _FPU_MASK_OM	0x0200	/* Overflow	     */
+#define _FPU_MASK_UM	0x0100	/* Underflow	     */
+#define _FPU_MASK_IM	0x0080	/* Inexact operation */
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x0	/* RECOMMENDED */
+#define _FPU_RC_ZERO	0x1
+
+#define _FPU_RESERVED 0xffc00000  /* These bits are reserved.  */
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+   and no interrupts for exceptions, rounding to nearest.  */
+#define _FPU_DEFAULT	0x00080000 /* Default value.  */
+#define _FPU_IEEE	0x00080f80 /* Default + exceptions enabled. */
+
+/* Type of the control word.  */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word.  */
+#define _FPU_GETCW(cw) __asm__ ("sts fpscr,%0" : "=r" (cw))
+
+#if defined __GNUC__
+__BEGIN_DECLS
+
+/* GCC provides this function.  */
+extern void __set_fpscr (unsigned long);
+#define _FPU_SETCW(cw) __set_fpscr ((cw))
+#else
+#define _FPU_SETCW(cw) __asm__ ("lds %0,fpscr" : : "r" (cw))
+#endif
+
+/* Default control word set at startup.	 */
+extern fpu_control_t __fpu_control;
+
+__END_DECLS
+
+#endif /* __SH_FPU_ANY__ */
+
+#endif /* _FPU_CONTROL_H */
diff --git a/REORG.TODO/sysdeps/sh/gccframe.h b/REORG.TODO/sysdeps/sh/gccframe.h
new file mode 100644
index 0000000000..e12a845e22
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/gccframe.h
@@ -0,0 +1,21 @@
+/* Definition of object in frame unwind info.  sh version.
+   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/>.  */
+
+#define DWARF_FRAME_REGISTERS 49
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/REORG.TODO/sysdeps/sh/gmp-mparam.h b/REORG.TODO/sysdeps/sh/gmp-mparam.h
new file mode 100644
index 0000000000..a579b48787
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/gmp-mparam.h
@@ -0,0 +1,29 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991-2017 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#define BITS_PER_MP_LIMB 32
+#define BYTES_PER_MP_LIMB 4
+#define BITS_PER_LONGINT 32
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
+
+#define IEEE_DOUBLE_BIG_ENDIAN 0
+#define IEEE_DOUBLE_MIXED_ENDIAN 1
diff --git a/REORG.TODO/sysdeps/sh/jmpbuf-offsets.h b/REORG.TODO/sysdeps/sh/jmpbuf-offsets.h
new file mode 100644
index 0000000000..fc5fae92c1
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/* Private macros for accessing __jmp_buf contents.  SH version.
+   Copyright (C) 2006-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 JB_SIZE		(4 * 15)
diff --git a/REORG.TODO/sysdeps/sh/jmpbuf-unwind.h b/REORG.TODO/sysdeps/sh/jmpbuf-unwind.h
new file mode 100644
index 0000000000..8af8d0d44f
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/jmpbuf-unwind.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+   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].__regs[7]))
+
+#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].__regs[7];
+#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/sh/ldsodefs.h b/REORG.TODO/sysdeps/sh/ldsodefs.h
new file mode 100644
index 0000000000..68fd828aed
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/ldsodefs.h
@@ -0,0 +1,40 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+   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	_SH_LDSODEFS_H
+#define	_SH_LDSODEFS_H	1
+
+#include <elf.h>
+
+struct La_sh_regs;
+struct La_sh_retval;
+
+#define ARCH_PLTENTER_MEMBERS						\
+    uintptr_t (*sh_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
+				  uintptr_t *, struct La_sh_regs *, \
+				  unsigned int *, const char *name,	\
+				  long int *framesizep)
+
+#define ARCH_PLTEXIT_MEMBERS						\
+    unsigned int (*sh_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
+				    uintptr_t *, const struct La_sh_regs *, \
+				    struct La_sh_retval *, const char *)
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/REORG.TODO/sysdeps/sh/libc-tls.c b/REORG.TODO/sysdeps/sh/libc-tls.c
new file mode 100644
index 0000000000..3fb6f057ee
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/libc-tls.c
@@ -0,0 +1,32 @@
+/* Thread-local storage handling in the ELF dynamic linker.  SH version.
+   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/>.  */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+/* On SH, 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/sh/libm-test-ulps b/REORG.TODO/sysdeps/sh/libm-test-ulps
new file mode 100644
index 0000000000..a00f04e2a3
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/libm-test-ulps
@@ -0,0 +1,417 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos_towardzero":
+float: 1
+ifloat: 1
+
+Function: "acosh":
+double: 1
+idouble: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 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: "cos_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cosh_towardzero":
+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 "ctan_towardzero":
+double: 5
+float: 3
+idouble: 5
+ifloat: 3
+
+Function: Imaginary part of "ctan_towardzero":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+
+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: Real part of "ctanh_towardzero":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+
+Function: Imaginary part of "ctanh_towardzero":
+double: 5
+float: 3
+idouble: 5
+ifloat: 3
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp10":
+double: 1
+idouble: 1
+
+Function: "exp10_towardzero":
+double: 1
+idouble: 1
+
+Function: "exp_towardzero":
+double: 1
+idouble: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "expm1_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "fma_towardzero":
+double: 1
+idouble: 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: "pow_towardzero":
+float: 1
+ifloat: 1
+
+Function: "sin":
+float: 1
+ifloat: 1
+
+Function: "sin_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sincos":
+float: 1
+ifloat: 1
+
+Function: "sinh_towardzero":
+double: 1
+idouble: 1
+
+Function: "tan_towardzero":
+double: 1
+float: 1
+idouble: 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/sh/libm-test-ulps-name b/REORG.TODO/sysdeps/sh/libm-test-ulps-name
new file mode 100644
index 0000000000..b6c67c9520
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/libm-test-ulps-name
@@ -0,0 +1 @@
+SH
diff --git a/REORG.TODO/sysdeps/sh/linkmap.h b/REORG.TODO/sysdeps/sh/linkmap.h
new file mode 100644
index 0000000000..bb2fbb5f16
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/linkmap.h
@@ -0,0 +1,5 @@
+struct link_map_machine
+  {
+    Elf32_Addr plt; /* Address of .plt + 36 */
+    Elf32_Addr gotplt; /* Address of .got + 0x0c */
+  };
diff --git a/REORG.TODO/sysdeps/sh/machine-gmon.h b/REORG.TODO/sysdeps/sh/machine-gmon.h
new file mode 100644
index 0000000000..56e45bcdb4
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/machine-gmon.h
@@ -0,0 +1,30 @@
+/* Machine-dependent definitions for profiling support.  SH version.
+   Copyright (C) 1996-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 must not pollute the global namespace.  */
+#define mcount_internal __mcount_internal
+
+void mcount_internal (u_long frompc, u_long selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+void mcount_internal (u_long frompc, u_long selfpc)
+
+
+/* Define MCOUNT as empty since we have the implementation in another
+   file.  */
+#define MCOUNT
diff --git a/REORG.TODO/sysdeps/sh/math_private.h b/REORG.TODO/sysdeps/sh/math_private.h
new file mode 100644
index 0000000000..d13f2d49d3
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/math_private.h
@@ -0,0 +1,10 @@
+#ifndef SH_MATH_PRIVATE_H
+#define SH_MATH_PRIVATE_H 1
+
+/* Enable __finitel, __isinfl, and __isnanl for binary compatibility
+   when built without long double support. */
+#define LDBL_CLASSIFY_COMPAT 1
+
+#include_next <math_private.h>
+
+#endif
diff --git a/REORG.TODO/sysdeps/sh/memcpy.S b/REORG.TODO/sysdeps/sh/memcpy.S
new file mode 100644
index 0000000000..c13afeaf24
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/memcpy.S
@@ -0,0 +1,198 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
+   Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
+
+   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>
+
+/* void *memcpy(void *dst, const void *src, size_t n);
+    No overlap between the memory of DST and of SRC are assumed.  */
+
+ENTRY(memcpy)
+	mov	r4,r3		/* Save destination.  */
+
+	/* If less than 11 bytes, just do a byte copy.  */
+	mov	#11,r0
+	cmp/gt	r6,r0
+	bt	L_byteloop_init
+
+	/* Check if we need to word-align source.  */
+	mov	r5,r0
+	tst	#1,r0
+	bt	L_wordalign
+
+	mov.b	@r0+,r1		/* Copy one byte.  */
+	add	#-1,r6
+	mov.b	r1,@r4
+	add	#1,r4
+
+	.balignw 4,0x0009
+L_wordalign:
+	/* Check if we need to longword-align source.  */
+	tst	#2,r0
+	bt	L_copy
+
+	mov.w	@r0+,r1		/* Copy one word.  */
+	add	#-2,r6
+#ifdef __BIG_ENDIAN__
+	add	#1,r4
+	mov.b	r1,@r4
+	shlr8	r1
+	mov.b	r1,@-r4
+	add	#2,r4
+#else
+	mov.b	r1,@r4
+	add	#1,r4
+	shlr8	r1
+	mov.b	r1,@r4
+	add	#1,r4
+#endif
+L_copy:
+	mov	r0,r5
+
+	/* Calculate the correct routine to handle the destination
+	   alignment and simultaneously calculate the loop counts for
+	   both the 2 word copy loop and byte copy loop.  */
+	mova	L_jumptable,r0
+	mov	r0,r1
+	mov	r4,r0
+	mov	r6,r7
+	and	#3,r0
+	shlr2	r7
+	shll	r0
+	shlr	r7
+	mov.w	@(r0,r1),r2
+	mov	#7,r0
+	braf	r2
+	and	r0,r6
+L_base:
+
+	.balign	4
+L_jumptable:
+	.word	L_copydest0 - L_base
+	.word	L_copydest1_or_3 - L_base
+	.word	L_copydest2 - L_base
+	.word	L_copydest1_or_3 - L_base
+
+	.balign	4
+	/* Copy routine for (dest mod 4) == 1 or == 3.  */
+L_copydest1_or_3:
+	add	#-1,r4
+	.balignw 4,0x0009
+L_copydest1_or_3_loop:
+	mov.l	@r5+,r0		/* Read first longword.  */
+	dt	r7
+	mov.l	@r5+,r1		/* Read second longword.  */
+#ifdef __BIG_ENDIAN__
+	/* Write first longword as byte, word, byte.  */
+	mov.b	r0,@(4,r4)
+	shlr8	r0
+	mov.w	r0,@(2,r4)
+	shlr16	r0
+	mov.b	r0,@(1,r4)
+	mov	r1,r0
+	/* Write second longword as byte, word, byte.  */
+	mov.b	r0,@(8,r4)
+	shlr8	r0
+	mov.w	r0,@(6,r4)
+	shlr16	r0
+	mov.b	r0,@(5,r4)
+#else
+	/* Write first longword as byte, word, byte.  */
+	mov.b	r0,@(1,r4)
+	shlr8	r0
+	mov.w	r0,@(2,r4)
+	shlr16	r0
+	mov.b	r0,@(4,r4)
+	mov	r1,r0
+	/* Write second longword as byte, word, byte.  */
+	mov.b	r0,@(5,r4)
+	shlr8	r0
+	mov.w	r0,@(6,r4)
+	shlr16	r0
+	mov.b	r0,@(8,r4)
+#endif
+	bf/s	L_copydest1_or_3_loop
+	add	#8,r4
+
+	bra	L_byteloop_init
+	add	#1,r4
+
+	.balign 4
+	/* Copy routine for (dest mod 4) == 2.  */
+L_copydest2:
+L_copydest2_loop:
+	mov.l	@r5+,r0
+	dt	r7
+	mov.l	@r5+,r1
+#ifdef __BIG_ENDIAN__
+	mov.w	r0,@(2,r4)
+	shlr16	r0
+	mov.w	r0,@r4
+	mov	r1,r0
+	mov.w	r0,@(6,r4)
+	shlr16	r0
+	mov.w	r0,@(4,r4)
+#else
+	mov.w	r0,@r4
+	shlr16	r0
+	mov.w	r0,@(2,r4)
+	mov	r1,r0
+	mov.w	r0,@(4,r4)
+	shlr16	r0
+	mov.w	r0,@(6,r4)
+#endif
+	bf/s	L_copydest2_loop
+	add	#8,r4
+
+	bra	L_byteloop_init
+	nop
+
+	.balign 4
+	/* Copy routine for (dest mod 4) == 0.  */
+L_copydest0:
+	add	#-8,r4
+	.balignw 4,0x0009
+L_copydest0_loop:
+	mov.l	@r5+,r0
+	dt	r7
+	mov.l	@r5+,r1
+	add	#8,r4
+	mov.l	r0,@r4
+	bf/s	L_copydest0_loop
+	mov.l	r1,@(4,r4)
+
+	add	#8,r4		/* Fall through.  */
+
+L_byteloop_init:
+	tst	r6,r6
+	bt	L_exit
+
+	.balignw 4,0x0009
+	/* Copy remaining bytes.  */
+L_byteloop:
+	mov.b	@r5+,r0
+	dt	r6
+	mov.b	r0,@r4
+	bf/s	L_byteloop
+	add	#1,r4
+
+L_exit:
+	rts
+	mov	r3,r0		/* Return destination.  */
+END(memcpy)
+libc_hidden_builtin_def (memcpy)
diff --git a/REORG.TODO/sysdeps/sh/memset.S b/REORG.TODO/sysdeps/sh/memset.S
new file mode 100644
index 0000000000..cb47e0c709
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/memset.S
@@ -0,0 +1,88 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
+   Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
+
+   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>
+
+/* void *memset (t, c, len);  */
+
+ENTRY(memset)
+	mov	#12,r0
+	cmp/gt	r6,r0
+	bt.s	L_byte_loop_init
+	mov	r4,r7
+
+	extu.b	r5,r5
+	swap.b	r5,r1
+	or	r1,r5
+	swap.w	r5,r1
+	or	r1,r5
+
+	mov	r4,r0
+	tst	#1,r0
+	bt	L_wordalign
+
+	mov.b	r5,@r4
+	add	#-1,r6
+	add	#1,r4
+	mov	r4,r0
+
+	.balignw 4,0x0009
+L_wordalign:
+	tst	#2,r0
+	bt	L_word_loop_init
+
+	mov.w	r5,@r4
+	add	#-2,r6
+	add	#2,r4
+	mov	r4,r0
+
+	.balignw 4,0x0009
+L_word_loop_init:
+	mov	r6,r3
+	shlr2	r3
+	mov	#7,r0
+	shlr	r3
+	and	r0,r6
+
+	.balignw 4,0x0009
+L_2word_loop:
+	mov.l	r5,@r4
+	dt	r3
+	mov.l	r5,@(4,r4)
+	bf.s	L_2word_loop
+	add	#8,r4
+
+	.balignw 4,0x0009
+L_byte_loop_init:
+	tst	r6,r6
+	bt	L_byte_exit
+
+	.balignw 4,0x0009
+L_byte_loop:
+	mov.b	r5,@r4
+	dt	r6
+	bf.s	L_byte_loop
+	add	#1,r4
+
+	.balignw 4,0x0009
+L_byte_exit:
+	rts
+	mov	r7,r0
+END(memset)
+libc_hidden_builtin_def (memset)
diff --git a/REORG.TODO/sysdeps/sh/memusage.h b/REORG.TODO/sysdeps/sh/memusage.h
new file mode 100644
index 0000000000..1821c69485
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/memusage.h
@@ -0,0 +1,20 @@
+/* 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 ("r15"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/REORG.TODO/sysdeps/sh/nptl/bits/pthreadtypes-arch.h b/REORG.TODO/sysdeps/sh/nptl/bits/pthreadtypes-arch.h
new file mode 100644
index 0000000000..b2615fe314
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/bits/pthreadtypes-arch.h
@@ -0,0 +1,69 @@
+/* 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
+  unsigned long int __cur_writer;
+};
+
+#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
+#endif	/* bits/pthreadtypes.h */
diff --git a/REORG.TODO/sysdeps/sh/nptl/bits/semaphore.h b/REORG.TODO/sysdeps/sh/nptl/bits/semaphore.h
new file mode 100644
index 0000000000..42a0836285
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   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/sh/nptl/pthread_spin_init.c b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_init.c
new file mode 100644
index 0000000000..a1205b9698
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_init.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+   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/>.  */
+
+/* Not needed.  pthread_spin_init is an alias for pthread_spin_unlock.  */
diff --git a/REORG.TODO/sysdeps/sh/nptl/pthread_spin_lock.c b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_lock.c
new file mode 100644
index 0000000000..3daa19d3f9
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_lock.c
@@ -0,0 +1,33 @@
+/* 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 "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+  unsigned int val;
+
+  do
+    asm volatile ("tas.b @%1; movt %0"
+		  : "=&r" (val)
+		  : "r" (lock)
+		  : "memory");
+  while (val == 0);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/nptl/pthread_spin_trylock.S b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_trylock.S
new file mode 100644
index 0000000000..524dbf9533
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_trylock.S
@@ -0,0 +1,31 @@
+/* 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 <pthread-errnos.h>
+
+	.globl	pthread_spin_trylock
+	.type	pthread_spin_trylock,@function
+	.align	5
+pthread_spin_trylock:
+	tas.b	@r4
+	bf/s	1f
+	mov	#EBUSY, r0
+	mov	#0, r0
+1:
+	rts
+	 nop
+	.size	pthread_spin_trylock,.-pthread_spin_trylock
diff --git a/REORG.TODO/sysdeps/sh/nptl/pthread_spin_unlock.S b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_unlock.S
new file mode 100644
index 0000000000..aabf1e463d
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/pthread_spin_unlock.S
@@ -0,0 +1,29 @@
+/* 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/>.  */
+
+	.globl	pthread_spin_unlock
+	.type	pthread_spin_unlock,@function
+	.align	5
+pthread_spin_unlock:
+	mov	#0,r0
+	rts
+	 mov.l	r0,@r4
+	.size	pthread_spin_unlock,.-pthread_spin_unlock
+
+	/* The implementation of pthread_spin_init is identical.  */
+	.globl	pthread_spin_init
+pthread_spin_init = pthread_spin_unlock
diff --git a/REORG.TODO/sysdeps/sh/nptl/pthreaddef.h b/REORG.TODO/sysdeps/sh/nptl/pthreaddef.h
new file mode 100644
index 0000000000..327f090788
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/pthreaddef.h
@@ -0,0 +1,34 @@
+/* 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 <sysdep.h>
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE	(2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN		8
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK	2048
+
+/* Alignment requirement for TCB.  */
+#define TCB_ALIGNMENT		8
+
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME	__builtin_frame_address (0)
diff --git a/REORG.TODO/sysdeps/sh/nptl/tcb-offsets.sym b/REORG.TODO/sysdeps/sh/nptl/tcb-offsets.sym
new file mode 100644
index 0000000000..4963e1506f
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/tcb-offsets.sym
@@ -0,0 +1,15 @@
+#include <sysdep.h>
+#include <tls.h>
+#include <kernel-features.h>
+
+RESULT			offsetof (struct pthread, result)
+TID			offsetof (struct pthread, tid)
+CANCELHANDLING		offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF		offsetof (struct pthread, cleanup_jmp_buf)
+MULTIPLE_THREADS_OFFSET	offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE	sizeof (struct pthread)
+MUTEX_FUTEX		offsetof (pthread_mutex_t, __data.__lock)
+POINTER_GUARD		offsetof (tcbhead_t, pointer_guard)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX		offsetof (struct pthread, header.private_futex)
+#endif
diff --git a/REORG.TODO/sysdeps/sh/nptl/tls.h b/REORG.TODO/sysdeps/sh/nptl/tls.h
new file mode 100644
index 0000000000..547cff179f
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/nptl/tls.h
@@ -0,0 +1,168 @@
+/* Definition for thread-local data handling.  NPTL/SH version.
+   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/>.  */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+# include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <dl-dtv.h>
+
+typedef struct
+{
+  dtv_t *dtv;
+  uintptr_t pointer_guard;
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information.  */
+# include <sysdep.h>
+
+/* 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)
+
+/* The TLS blocks start right after the TCB.  */
+# define TLS_DTV_AT_TP	1
+# define TLS_TCB_AT_TP	0
+
+/* Get the thread descriptor definition.  */
+# include <nptl/descr.h>
+
+/* 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) \
+  ({ tcbhead_t *__tcbp;							      \
+     __asm __volatile ("stc gbr,%0" : "=r" (__tcbp));			      \
+     __tcbp->dtv = (dtv);})
+
+/* Return dtv of given thread descriptor.  */
+# define GET_DTV(tcbp) \
+  (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer.  This might need
+   special attention since 'errno' is not yet available and if the
+   operation can cause a failure 'errno' must not be touched.  */
+# define TLS_INIT_TP(tcbp) \
+  ({ __asm __volatile ("ldc %0,gbr" : : "r" (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 *__tcbp;							      \
+     __asm __volatile ("stc gbr,%0" : "=r" (__tcbp));			      \
+     __tcbp->dtv;})
+
+/* Return the thread descriptor for the current thread.
+   The contained asm must *not* be marked volatile since otherwise
+   assignments like
+	struct pthread *self = thread_self();
+   do not get optimized away.  */
+# define THREAD_SELF \
+  ({ struct pthread *__self;						      \
+     __asm ("stc gbr,%0" : "=r" (__self));				      \
+     __self - 1;})
+
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF \
+  REGISTER (32, 32, REG_GBR * 4, -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)
+
+#define THREAD_GET_POINTER_GUARD() \
+  ({ tcbhead_t *__tcbp;							      \
+     __asm __volatile ("stc gbr,%0" : "=r" (__tcbp));			      \
+     __tcbp->pointer_guard;})
+ #define THREAD_SET_POINTER_GUARD(value) \
+  ({ tcbhead_t *__tcbp;							      \
+     __asm __volatile ("stc gbr,%0" : "=r" (__tcbp));			      \
+     __tcbp->pointer_guard = (value);})
+#define THREAD_COPY_POINTER_GUARD(descr) \
+  ({ tcbhead_t *__tcbp;							      \
+     __asm __volatile ("stc gbr,%0" : "=r" (__tcbp));			      \
+     ((tcbhead_t *) (descr + 1))->pointer_guard	= __tcbp->pointer_guard;})
+
+/* 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/sh/preconfigure b/REORG.TODO/sysdeps/sh/preconfigure
new file mode 100644
index 0000000000..c1f6537797
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/preconfigure
@@ -0,0 +1,6 @@
+# preconfigure fragment for sh.
+
+case "$machine" in
+sh3*)		base_machine=sh machine=sh/sh3 ;;
+sh4*)		base_machine=sh machine=sh/sh4 ;;
+esac
diff --git a/REORG.TODO/sysdeps/sh/s_fma.c b/REORG.TODO/sysdeps/sh/s_fma.c
new file mode 100644
index 0000000000..d92438d448
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/s_fma.c
@@ -0,0 +1,5 @@
+#ifdef __SH_FPU_ANY__
+# include <sysdeps/ieee754/dbl-64/s_fma.c>
+#else
+# include <soft-fp/fmadf4.c>
+#endif
diff --git a/REORG.TODO/sysdeps/sh/s_fmaf.c b/REORG.TODO/sysdeps/sh/s_fmaf.c
new file mode 100644
index 0000000000..3b811ae6da
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/s_fmaf.c
@@ -0,0 +1,5 @@
+#ifdef __SH_FPU_ANY__
+# include <sysdeps/ieee754/dbl-64/s_fmaf.c>
+#else
+# include <soft-fp/fmasf4.c>
+#endif
diff --git a/REORG.TODO/sysdeps/sh/sh3/__longjmp.S b/REORG.TODO/sysdeps/sh/sh3/__longjmp.S
new file mode 100644
index 0000000000..27d6141a98
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh3/__longjmp.S
@@ -0,0 +1,63 @@
+/* longjmp for SH.
+   Copyright (C) 1999-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>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+	mov.l	@r4+, r8
+	mov.l	@r4+, r9
+	mov.l	@r4+, r10
+	mov.l	@r4+, r11
+	mov.l	@r4+, r12
+	mov	r5, r0		/* get the return value in place */
+	tst	r0, r0
+	bf.s	1f
+	 mov.l	@r4+, r13
+	mov	#1,r0		/* can't let setjmp() return zero! */
+1:
+#ifdef PTR_DEMANGLE
+	mov.l	@r4+, r2
+	PTR_DEMANGLE (r2, r1)
+	mov	r2, r14
+	mov.l	@r4+, r2
+	PTR_DEMANGLE2 (r2, r1)
+# ifdef CHECK_SP
+	CHECK_SP (r2)
+# endif
+	mov	r2, r15
+	mov.l	@r4+, r2
+	PTR_DEMANGLE2 (r2, r1)
+	lds	r2, pr
+	mov	#0, r1
+#else
+	mov.l	@r4+, r14
+# ifdef CHECK_SP
+	mov.l	@r4, r2
+	CHECK_SP (r2)
+# endif
+	mov.l	@r4+, r15
+	lds.l	@r4+, pr
+#endif
+	rts
+	 ldc.l	@r4+, gbr
+END (__longjmp)
diff --git a/REORG.TODO/sysdeps/sh/sh3/setjmp.S b/REORG.TODO/sysdeps/sh/sh3/setjmp.S
new file mode 100644
index 0000000000..ef039a2114
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh3/setjmp.S
@@ -0,0 +1,81 @@
+/* setjmp for SH3.
+   Copyright (C) 1999-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 <jmpbuf-offsets.h>
+
+ENTRY (__sigsetjmp)
+	/* Save registers */
+	add	#(JB_SIZE - 4 * 5), r4
+	stc.l	gbr, @-r4
+#ifdef PTR_MANGLE
+	sts	pr, r2
+	PTR_MANGLE (r2, r1)
+	mov.l	r2, @-r4
+	mov	r15, r2
+	PTR_MANGLE2 (r2, r1)
+	mov.l	r2, @-r4
+	mov	r14, r2
+	PTR_MANGLE2 (r2, r1)
+	mov.l	r2, @-r4
+	mov	#0, r1
+#else
+	sts.l	pr, @-r4
+	mov.l	r15, @-r4
+	mov.l	r14, @-r4
+#endif
+	mov.l	r13, @-r4
+	mov.l	r12, @-r4
+	mov.l	r11, @-r4
+	mov.l	r10, @-r4
+	mov.l	r9, @-r4
+	mov.l	r8, @-r4
+
+#if IS_IN (rtld)
+	/* In ld.so we never save the signal mask.  */
+	rts
+	 mov	#0, r0
+#else
+	/* Make a tail call to __sigjmp_save; it takes the same args.  */
+# ifdef SHARED
+	mov.l	1f, r1
+	mova	1f, r0
+	bra	2f
+	 add	r1, r0
+	.align	2
+1:
+	.long	_GLOBAL_OFFSET_TABLE_
+2:
+	mov.l	.L1, r1
+	mov.l	@(r0,r1), r1
+	jmp	@r1
+	 nop
+	.align	2
+.L1:
+	.long	C_SYMBOL_NAME(__sigjmp_save@GOT)
+# else
+	mov.l	.L1, r1
+	jmp	@r1
+	 nop
+	.align	2
+.L1:
+	.long	C_SYMBOL_NAME(__sigjmp_save)
+# endif
+#endif
+END (__sigsetjmp)
+hidden_def (__sigsetjmp)
diff --git a/REORG.TODO/sysdeps/sh/sh4/Makefile b/REORG.TODO/sysdeps/sh/sh4/Makefile
new file mode 100644
index 0000000000..ccac91432a
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/Makefile
@@ -0,0 +1,3 @@
+# Build everything with full IEEE math support.  -mieee isn't
+# default for the older SH compilers.
+sysdep-CFLAGS += -mieee
diff --git a/REORG.TODO/sysdeps/sh/sh4/Versions b/REORG.TODO/sysdeps/sh/sh4/Versions
new file mode 100644
index 0000000000..8cc1c7b7d4
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/Versions
@@ -0,0 +1,5 @@
+ld {
+  GLIBC_PRIVATE {
+    __fpscr_values;
+  }
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/__longjmp.S b/REORG.TODO/sysdeps/sh/sh4/__longjmp.S
new file mode 100644
index 0000000000..2a5c25da32
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/__longjmp.S
@@ -0,0 +1,73 @@
+/* longjmp for SH.
+   Copyright (C) 1999-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>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+	mov.l	@r4+, r8
+	mov.l	@r4+, r9
+	mov.l	@r4+, r10
+	mov.l	@r4+, r11
+	mov.l	@r4+, r12
+	mov	r5, r0		/* get the return value in place */
+	tst	r0, r0
+	bf.s	1f
+	 mov.l	@r4+, r13
+	mov	#1,r0		/* can't let setjmp() return zero! */
+1:
+#ifdef PTR_DEMANGLE
+	mov.l	@r4+, r2
+	PTR_DEMANGLE (r2, r1)
+	mov	r2, r14
+	mov.l	@r4+, r2
+	PTR_DEMANGLE2 (r2, r1)
+# ifdef CHECK_SP
+	CHECK_SP (r2)
+# endif
+	mov	r2, r15
+	mov.l	@r4+, r2
+	PTR_DEMANGLE2 (r2, r1)
+	lds	r2, pr
+	mov	#0, r1
+#else
+	mov.l	@r4+, r14
+# ifdef CHECK_SP
+	mov.l	@r4, r2
+	CHECK_SP (r2)
+# endif
+	mov.l	@r4+, r15
+	lds.l	@r4+, pr
+#endif
+#ifdef __SH_FPU_ANY__
+	ldc.l	@r4+, gbr
+	lds.l	@r4+, fpscr
+	fmov.s	@r4+, fr12
+	fmov.s	@r4+, fr13
+	fmov.s	@r4+, fr14
+	rts
+	 fmov.s	@r4+, fr15
+#else
+	rts
+	 ldc.l	@r4+, gbr
+#endif  /* !__SH_FPU_ANY__ */
+END (__longjmp)
diff --git a/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S b/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S
new file mode 100644
index 0000000000..bd9bb7e5bd
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S
@@ -0,0 +1,4 @@
+#ifdef __SH_FPU_ANY__
+# define HAVE_FPU
+#endif
+#include <sysdeps/sh/dl-trampoline.S>
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c
new file mode 100644
index 0000000000..5a430f6655
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c
@@ -0,0 +1,42 @@
+/* Clear given exceptions in current floating-point environment.
+   Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+feclearexcept (int excepts)
+{
+  fpu_control_t cw;
+
+  /* Mask out unsupported bits/exceptions.  */
+  excepts &= FE_ALL_EXCEPT;
+
+  /* Read the complete control word.  */
+  _FPU_GETCW (cw);
+
+  /* Clear exception bits.  */
+  cw &= ~excepts;
+
+  /* Put the new data in effect.  */
+  _FPU_SETCW (cw);
+
+  return 0;
+}
+libm_hidden_def (feclearexcept)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c
new file mode 100644
index 0000000000..718ae70899
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c
@@ -0,0 +1,39 @@
+/* Disable floating-point exceptions.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fedisableexcept (int excepts)
+{
+  fpu_control_t temp, old_exc;
+
+  /* Get the current control register contents.  */
+  _FPU_GETCW (temp);
+
+  old_exc = (temp >> 5) & FE_ALL_EXCEPT;
+
+  excepts &= FE_ALL_EXCEPT;
+
+  temp &= ~(excepts << 5);
+  _FPU_SETCW (temp);
+
+  return old_exc;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c
new file mode 100644
index 0000000000..d638714149
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c
@@ -0,0 +1,38 @@
+/* Enable floating-point exceptions.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+feenableexcept (int excepts)
+{
+  fpu_control_t temp, old_flag;
+
+  /* Get current exceptions.  */
+  _FPU_GETCW (temp);
+
+  old_flag = (temp >> 5) & FE_ALL_EXCEPT;
+  excepts &= FE_ALL_EXCEPT;
+
+  temp |= excepts << 5;
+  _FPU_SETCW (temp);
+
+  return old_flag;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c
new file mode 100644
index 0000000000..00945f1072
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c
@@ -0,0 +1,34 @@
+/* Store current floating-point environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+  fpu_control_t temp;
+  _FPU_GETCW (temp);
+
+  envp->__fpscr = temp;
+
+  return 0;
+}
+libm_hidden_def (__fegetenv)
+weak_alias (__fegetenv, fegetenv)
+libm_hidden_weak (fegetenv)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c
new file mode 100644
index 0000000000..4d1299e310
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c
@@ -0,0 +1,32 @@
+/* Get enabled floating-point exceptions.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexcept (void)
+{
+  fpu_control_t temp;
+
+  /* Get current exceptions.  */
+  _FPU_GETCW (temp);
+
+  return (temp >> 5) & FE_ALL_EXCEPT;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c
new file mode 100644
index 0000000000..e839a9b25f
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c
@@ -0,0 +1,27 @@
+/* Store current floating-point control modes.  SH4 version.
+   Copyright (C) 2016-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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetmode (femode_t *modep)
+{
+  _FPU_GETCW (*modep);
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c
new file mode 100644
index 0000000000..4c97d23e12
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c
@@ -0,0 +1,35 @@
+/* Return current rounding direction.
+   Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fegetround (void)
+{
+  fpu_control_t cw;
+
+  /* Get control word.  */
+  _FPU_GETCW (cw);
+
+  return cw & 0x1;
+}
+libm_hidden_def (__fegetround)
+weak_alias (__fegetround, fegetround)
+libm_hidden_weak (fegetround)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c
new file mode 100644
index 0000000000..b905e594cd
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c
@@ -0,0 +1,44 @@
+/* Store current floating-point environment and clear exceptions.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__feholdexcept (fenv_t *envp)
+{
+  fpu_control_t temp;
+
+  /* Store the environment.  */
+  _FPU_GETCW (temp);
+  envp->__fpscr = temp;
+
+  /* Clear the status flags.  */
+  temp &= ~FE_ALL_EXCEPT;
+
+  /* Now set all exceptions to non-stop.  */
+  temp &= ~(FE_ALL_EXCEPT << 5);
+
+  _FPU_SETCW (temp);
+
+  /* Success.  */
+  return 0;
+}
+libm_hidden_def (__feholdexcept)
+weak_alias (__feholdexcept, feholdexcept)
+libm_hidden_weak (feholdexcept)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c
new file mode 100644
index 0000000000..8628c508e5
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c
@@ -0,0 +1,36 @@
+/* Install given floating-point environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+  if (envp == FE_DFL_ENV)
+      _FPU_SETCW (_FPU_DEFAULT);
+  else
+    {
+      fpu_control_t temp = envp->__fpscr;
+      _FPU_SETCW (temp);
+    }
+  return 0;
+}
+libm_hidden_def (__fesetenv)
+weak_alias (__fesetenv, fesetenv)
+libm_hidden_weak (fesetenv)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c
new file mode 100644
index 0000000000..ecfad75fff
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c
@@ -0,0 +1,32 @@
+/* Set given exception flags.  SH4 version.
+   Copyright (C) 2016-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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetexcept (int excepts)
+{
+  fpu_control_t temp;
+
+  _FPU_GETCW (temp);
+  temp |= (excepts & FE_ALL_EXCEPT);
+  _FPU_SETCW (temp);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c
new file mode 100644
index 0000000000..d2b9e05128
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c
@@ -0,0 +1,38 @@
+/* Install given floating-point control modes.  SH4 version.
+   Copyright (C) 2016-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 <fenv.h>
+#include <fpu_control.h>
+
+#define FPU_STATUS 0x3f07c
+
+int
+fesetmode (const femode_t *modep)
+{
+  fpu_control_t fpscr;
+
+  _FPU_GETCW (fpscr);
+  fpscr &= FPU_STATUS;
+  if (modep == FE_DFL_MODE)
+    fpscr |= _FPU_DEFAULT;
+  else
+    fpscr |= *modep & ~FPU_STATUS;
+  _FPU_SETCW (fpscr);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c
new file mode 100644
index 0000000000..20acb7c5e9
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c
@@ -0,0 +1,45 @@
+/* Set current rounding direction.
+   Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__fesetround (int round)
+{
+  fpu_control_t cw;
+
+  if ((round & ~0x1) != 0)
+    /* ROUND is no valid rounding mode.  */
+    return 1;
+
+  /* Get current state.  */
+  _FPU_GETCW (cw);
+
+  /* Set rounding bits.  */
+  cw &= ~0x1;
+  cw |= round;
+  /* Set new state.  */
+  _FPU_SETCW (cw);
+
+  return 0;
+}
+libm_hidden_def (__fesetround)
+weak_alias (__fesetround, fesetround)
+libm_hidden_weak (fesetround)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c
new file mode 100644
index 0000000000..3b886a2235
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c
@@ -0,0 +1,41 @@
+/* Install given floating-point environment and raise exceptions.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012.
+
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+__feupdateenv (const fenv_t *envp)
+{
+  fpu_control_t temp;
+
+  _FPU_GETCW (temp);
+  temp = (temp & FE_ALL_EXCEPT);
+
+  /* Raise the saved exception. Incidently for us the implementation
+    defined format of the values in objects of type fexcept_t is the
+    same as the ones specified using the FE_* constants. */
+  __fesetenv (envp);
+  __feraiseexcept ((int) temp);
+
+  return 0;
+}
+libm_hidden_def (__feupdateenv)
+weak_alias (__feupdateenv, feupdateenv)
+libm_hidden_weak (feupdateenv)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c
new file mode 100644
index 0000000000..02fc3948bc
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c
@@ -0,0 +1,38 @@
+/* Store current representation for exceptions.
+   Copyright (C) 2013-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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+  fpu_control_t temp;
+
+  /* Get the current exceptions.  */
+  _FPU_GETCW (temp);
+
+  /* We only save the relevant bits here. In particular, care has to be
+     taken with the CAUSE bits, as an inadvertent restore later on could
+     generate unexpected exceptions.  */
+
+  *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+  /* Success.  */
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c
new file mode 100644
index 0000000000..4bd0eb9ef5
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c
@@ -0,0 +1,75 @@
+/* Raise given exceptions.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012.
+
+   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 <fenv.h>
+#include <float.h>
+#include <fpu_control.h>
+#include <math.h>
+
+int
+__feraiseexcept (int excepts)
+{
+  if (excepts == 0)
+    return 0;
+
+  /* Raise exceptions represented by EXPECTS.  */
+
+  if (excepts & FE_INEXACT)
+  {
+    double d = 1.0, x = 3.0;
+    __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x));
+  }
+
+  if (excepts & FE_UNDERFLOW)
+  {
+    long double d = LDBL_MIN, x = 10;
+    __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x));
+  }
+
+  if (excepts & FE_OVERFLOW)
+  {
+    long double d = LDBL_MAX;
+    __asm__ __volatile__ ("fmul %0, %0" : "+d" (d) : "d" (d));
+  }
+
+  if (excepts & FE_DIVBYZERO)
+  {
+    double d = 1.0, x = 0.0;
+    __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x));
+  }
+
+  if (excepts & FE_INVALID)
+  {
+    double d = HUGE_VAL, x = 0.0;
+    __asm__ __volatile__ ("fmul %1, %0" : "+d" (d) : "d" (x));
+  }
+
+  {
+    /* Restore flag fields.  */
+    fpu_control_t cw;
+    _FPU_GETCW (cw);
+    cw |= (excepts & FE_ALL_EXCEPT);
+    _FPU_SETCW (cw);
+  }
+
+  return 0;
+}
+libm_hidden_def (__feraiseexcept)
+weak_alias (__feraiseexcept, feraiseexcept)
+libm_hidden_weak (feraiseexcept)
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c
new file mode 100644
index 0000000000..3a6ea33c26
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c
@@ -0,0 +1,39 @@
+/* Set floating-point environment exception handling.
+   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 <fenv.h>
+#include <math.h>
+#include <fpu_control.h>
+
+int
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+  fpu_control_t temp;
+
+  /* Get the current environment.  */
+  _FPU_GETCW (temp);
+
+  /* Set the desired exception mask.  */
+  temp &= ~(excepts & FE_ALL_EXCEPT);
+  temp |= (*flagp & excepts & FE_ALL_EXCEPT);
+
+  /* Save state back to the FPU.  */
+  _FPU_SETCW (temp);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c
new file mode 100644
index 0000000000..fa2c011825
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+   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 <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+  fpu_control_t temp;
+
+  /* Get current exceptions.  */
+  _FPU_GETCW (temp);
+
+  return temp & excepts & FE_ALL_EXCEPT;
+}
+libm_hidden_def (fetestexcept)
diff --git a/REORG.TODO/sysdeps/sh/sh4/setjmp.S b/REORG.TODO/sysdeps/sh/sh4/setjmp.S
new file mode 100644
index 0000000000..a09ffab627
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/setjmp.S
@@ -0,0 +1,90 @@
+/* setjmp for SH4.
+   Copyright (C) 1999-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 <jmpbuf-offsets.h>
+
+ENTRY (__sigsetjmp)
+	/* Save registers */
+#ifdef __SH_FPU_ANY__
+	add	#JB_SIZE, r4
+	fmov.s	fr15, @-r4
+	fmov.s	fr14, @-r4
+	fmov.s	fr13, @-r4
+	fmov.s	fr12, @-r4
+	sts.l	fpscr, @-r4
+#else
+	add	#(JB_SIZE - 4 * 5), r4
+#endif /* __SH_FPU_ANY__ */
+	stc.l	gbr, @-r4
+#ifdef PTR_MANGLE
+	sts	pr, r2
+	PTR_MANGLE (r2, r1)
+	mov.l	r2, @-r4
+	mov	r15, r2
+	PTR_MANGLE2 (r2, r1)
+	mov.l	r2, @-r4
+	mov	r14, r2
+	PTR_MANGLE2 (r2, r1)
+	mov.l	r2, @-r4
+	mov	#0, r1
+#else
+	sts.l	pr, @-r4
+	mov.l	r15, @-r4
+	mov.l	r14, @-r4
+#endif
+	mov.l	r13, @-r4
+	mov.l	r12, @-r4
+	mov.l	r11, @-r4
+	mov.l	r10, @-r4
+	mov.l	r9, @-r4
+	mov.l	r8, @-r4
+
+#if IS_IN (rtld)
+	/* In ld.so we never save the signal mask.  */
+	rts
+	 mov	#0, r0
+#else
+	/* Make a tail call to __sigjmp_save; it takes the same args.  */
+# ifdef SHARED
+	mov.l	1f, r1
+	mova	1f, r0
+	bra	2f
+	 add	r1, r0
+	.align	2
+1:
+	.long	_GLOBAL_OFFSET_TABLE_
+2:
+	mov.l	.L1, r1
+	mov.l	@(r0,r1), r1
+	jmp	@r1
+	 nop
+	.align	2
+.L1:
+	.long	C_SYMBOL_NAME(__sigjmp_save@GOT)
+# else
+	mov.l	.L1, r1
+	jmp	@r1
+	 nop
+	.align	2
+.L1:
+	.long	C_SYMBOL_NAME(__sigjmp_save)
+# endif
+#endif
+END (__sigsetjmp)
+hidden_def (__sigsetjmp)
diff --git a/REORG.TODO/sysdeps/sh/soft-fp/sfp-machine.h b/REORG.TODO/sysdeps/sh/soft-fp/sfp-machine.h
new file mode 100644
index 0000000000..81474e8a7c
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/soft-fp/sfp-machine.h
@@ -0,0 +1,57 @@
+#define _FP_W_TYPE_SIZE		32
+#define _FP_W_TYPE		unsigned long
+#define _FP_WS_TYPE		signed long
+#define _FP_I_TYPE		long
+
+#define _FP_MUL_MEAT_S(R,X,Y)				\
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)				\
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y)				\
+  _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_MUL_MEAT_DW_S(R,X,Y)				\
+  _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_D(R,X,Y)				\
+  _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_Q(R,X,Y)				\
+  _FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_loop(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S		((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D		((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q		((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S		0
+#define _FP_NANSIGN_D		0
+#define _FP_NANSIGN_Q		0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+/* Someone please check this.  */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)			\
+  do {								\
+    if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)		\
+	&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))	\
+      {								\
+	R##_s = Y##_s;						\
+	_FP_FRAC_COPY_##wc(R,Y);				\
+      }								\
+    else							\
+      {								\
+	R##_s = X##_s;						\
+	_FP_FRAC_COPY_##wc(R,X);				\
+      }								\
+    R##_c = FP_CLS_NAN;						\
+  } while (0)
+
+#define FP_EX_INVALID           (1 << 6)
+#define FP_EX_DIVZERO           (1 << 5)
+#define FP_EX_OVERFLOW          (1 << 4)
+#define FP_EX_UNDERFLOW         (1 << 3)
+#define FP_EX_INEXACT           (1 << 2)
+
+#define _FP_TININESS_AFTER_ROUNDING 1
diff --git a/REORG.TODO/sysdeps/sh/sotruss-lib.c b/REORG.TODO/sysdeps/sh/sotruss-lib.c
new file mode 100644
index 0000000000..152e502113
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sotruss-lib.c
@@ -0,0 +1,50 @@
+/* Override generic sotruss-lib.c to define actual functions for SH.
+   Copyright (C) 2013-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_sh_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
+		    unsigned int ndx __attribute__ ((unused)),
+		    uintptr_t *refcook, uintptr_t *defcook,
+		    La_sh_regs *regs, unsigned int *flags,
+		    const char *symname, long int *framesizep)
+{
+  print_enter (refcook, defcook, symname,
+	       regs->lr_r4, regs->lr_r5, regs->lr_r6, *flags);
+
+  /* No need to copy anything, we will not need the parameters in any case.  */
+  *framesizep = 0;
+
+  return sym->st_value;
+}
+
+unsigned int
+la_sh_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
+		   uintptr_t *defcook,
+		   const struct La_sh_regs *inregs,
+		   struct La_sh_retval *outregs, const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_r0);
+
+  return 0;
+}
diff --git a/REORG.TODO/sysdeps/sh/stackguard-macros.h b/REORG.TODO/sysdeps/sh/stackguard-macros.h
new file mode 100644
index 0000000000..55a5771b62
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/stackguard-macros.h
@@ -0,0 +1,6 @@
+#include <stdint.h>
+
+extern uintptr_t __stack_chk_guard;
+#define STACK_CHK_GUARD __stack_chk_guard
+
+#define POINTER_CHK_GUARD THREAD_GET_POINTER_GUARD()
diff --git a/REORG.TODO/sysdeps/sh/stackinfo.h b/REORG.TODO/sysdeps/sh/stackinfo.h
new file mode 100644
index 0000000000..cdbb27113d
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/stackinfo.h
@@ -0,0 +1,33 @@
+/* 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 SH 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/sh/start.S b/REORG.TODO/sysdeps/sh/start.S
new file mode 100644
index 0000000000..0e6b90df9b
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/start.S
@@ -0,0 +1,111 @@
+/* Startup code for SH & ELF.
+   Copyright (C) 1999-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/>.  */
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.
+
+	Note that the code in the .init section has already been run.
+	This includes _init and _libc_init
+
+
+	At this entry point, most registers' values are unspecified, except:
+
+   r4		Contains a function pointer to be registered with `atexit'.
+		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
+   sp		The stack contains the arguments and environment:
+		0(sp)			argc
+		4(sp)			argv[0]
+		...
+		(4*argc)(sp)		NULL
+		(4*(argc+1))(sp)	envp[0]
+		...
+					NULL
+*/
+
+	.text
+	.globl _start
+	.type _start,@function
+_start:
+	/* Clear the frame pointer since this is the outermost frame.  */
+	mov #0, r14
+
+	/* Pop argc off the stack and save a pointer to argv */
+	mov.l @r15+,r5
+	mov r15, r6
+
+	/* Push the last arguments to main() onto the stack */
+	mov.l r4,@-r15
+	mov.l L_fini,r0
+	mov.l r0,@-r15
+
+	/* Set up the other arguments for main() that go in registers */
+	mov.l L_main,r4
+	mov.l L_init,r7
+
+	/* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
+
+	/* Let the libc call main and exit with its return code.  */
+	mov.l L_libc_start_main,r1
+	jsr @r1
+	nop
+	/* should never get here....*/
+	mov.l L_abort,r1
+	jsr @r1
+	nop
+	.align	2
+L_main:
+	.long	main
+L_init:
+	.long	__libc_csu_init
+L_fini:
+	.long	__libc_csu_fini
+L_libc_start_main:
+	.long	__libc_start_main
+L_abort:
+	.long	abort
+/* 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
+	.global __fpscr_values
+__fpscr_values:
+	.long   0
+	.long   0x80000
diff --git a/REORG.TODO/sysdeps/sh/strlen.S b/REORG.TODO/sysdeps/sh/strlen.S
new file mode 100644
index 0000000000..8e0d53c471
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/strlen.S
@@ -0,0 +1,83 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
+
+   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>
+
+/* size_t strlen (const char *s)  */
+
+ENTRY(strlen)
+	mov	r4, r0
+	and	#3, r0
+	tst	r0, r0
+	bt/s	1f
+	mov	#0, r2
+
+	add	#-1, r0
+	shll2	r0
+	shll	r0
+	braf	r0
+	nop
+
+	mov.b	@r4+, r1
+	tst	r1, r1
+	bt	8f
+	add	#1, r2
+
+	mov.b	@r4+, r1
+	tst	r1, r1
+	bt	8f
+	add	#1, r2
+
+	mov.b	@r4+, r1
+	tst	r1, r1
+	bt	8f
+	add	#1, r2
+
+1:
+	mov	#0, r3
+2:
+	mov.l	@r4+, r1
+	cmp/str	r3, r1
+	bf/s	2b
+	add	#4, r2
+
+	add	#-4, r2
+#ifdef __BIG_ENDIAN__
+	swap.b	r1, r1
+	swap.w	r1, r1
+	swap.b	r1, r1
+#endif
+	extu.b	r1, r0
+	tst	r0, r0
+	bt/s	8f
+	shlr8	r1
+	add	#1, r2
+	extu.b	r1, r0
+	tst	r0, r0
+	bt/s	8f
+	shlr8	r1
+	add	#1, r2
+	extu.b	r1, r0
+	tst	r0, r0
+	bt	8f
+	add	#1, r2
+8:
+	rts
+	mov	r2, r0
+END(strlen)
+libc_hidden_builtin_def (strlen)
diff --git a/REORG.TODO/sysdeps/sh/sysdep.h b/REORG.TODO/sysdeps/sh/sysdep.h
new file mode 100644
index 0000000000..939c93144e
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sysdep.h
@@ -0,0 +1,75 @@
+/* Assembler macros for SH.
+   Copyright (C) 1999-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
+
+#ifdef SHARED
+#define PLTJMP(_x)	_x##@PLT
+#else
+#define PLTJMP(_x)	_x
+#endif
+
+
+/* Define an entry point visible from C.  */
+#define	ENTRY(name)							      \
+  .globl C_SYMBOL_NAME(name);						      \
+  .type C_SYMBOL_NAME(name),@function;					      \
+  .align ALIGNARG(5);							      \
+  C_LABEL(name)								      \
+  cfi_startproc;							      \
+  CALL_MCOUNT
+
+#undef	END
+#define END(name)							      \
+  cfi_endproc;								      \
+  ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(name))
+
+/* If compiled for profiling, call `mcount' at the start of each function.  */
+#ifdef	PROF
+#define CALL_MCOUNT					\
+	mov.l	1f,r1;					\
+	sts.l	pr,@-r15;				\
+	cfi_adjust_cfa_offset (4);			\
+	cfi_rel_offset (pr, 0);				\
+	mova	2f,r0;					\
+	jmp	@r1;					\
+	 lds	r0,pr;					\
+	.align	2;					\
+1:	.long	mcount;					\
+2:	lds.l	@r15+,pr;				\
+	cfi_adjust_cfa_offset (-4);			\
+	cfi_restore (pr)
+
+#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
+
+#endif	/* __ASSEMBLER__ */
diff --git a/REORG.TODO/sysdeps/sh/tininess.h b/REORG.TODO/sysdeps/sh/tininess.h
new file mode 100644
index 0000000000..1db37790f8
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/tininess.h
@@ -0,0 +1 @@
+#define TININESS_AFTER_ROUNDING	1
diff --git a/REORG.TODO/sysdeps/sh/tls-macros.h b/REORG.TODO/sysdeps/sh/tls-macros.h
new file mode 100644
index 0000000000..aa56b0a01f
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/tls-macros.h
@@ -0,0 +1,143 @@
+#define TLS_LE(x) \
+  ({ int *__l; void *__tp;						      \
+     asm ("stc gbr,%1\n\t"						      \
+	  "mov.l 1f,%0\n\t"						      \
+	  "bra 2f\n\t"							      \
+	  " add %1,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@tpoff\n\t"					      \
+	  "2:"								      \
+	  : "=r" (__l), "=r" (__tp));					      \
+     __l; })
+
+#ifdef PIC
+# define TLS_IE(x) \
+  ({ int *__l; void *__tp;						      \
+     register void *__gp __asm__("r12");				      \
+     asm ("mov.l 1f,r0\n\t"						      \
+	  "stc gbr,%1\n\t"						      \
+	  "mov.l @(r0,r12),%0\n\t"					      \
+	  "bra 2f\n\t"							      \
+	  " add %1,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@gottpoff\n\t"				      \
+	  "2:"								      \
+	  : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0");		      \
+     __l; })
+#else
+# define TLS_IE(x) \
+  ({ int *__l; void *__tp;						      \
+     asm ("mov.l r12,@-r15\n\t"						      \
+	  "mova 0f,r0\n\t"						      \
+	  "mov.l 0f,r12\n\t"						      \
+	  "add r0,r12\n\t"						      \
+	  "mov.l 1f,r0\n\t"						      \
+	  "stc gbr,%1\n\t"						      \
+	  "mov.l @(r0,r12),%0\n\t"					      \
+	  "bra 2f\n\t"							      \
+	  " add %1,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@gottpoff\n\t"				      \
+	  "0: .long _GLOBAL_OFFSET_TABLE_\n\t"				      \
+	  "2: mov.l @r15+,r12"						      \
+	  : "=r" (__l), "=r" (__tp) : : "r0");				      \
+     __l; })
+#endif
+
+#ifdef PIC
+# define TLS_LD(x) \
+  ({ int *__l;								      \
+     register void *__gp __asm__("r12");				      \
+     asm ("mov.l 1f,r4\n\t"						      \
+	  "mova 2f,r0\n\t"						      \
+	  "mov.l 2f,r1\n\t"						      \
+	  "add r0,r1\n\t"						      \
+	  "jsr @r1\n\t"							      \
+	  " add r12,r4\n\t"						      \
+	  "bra 4f\n\t"							      \
+	  " nop\n\t"							      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@tlsldm\n\t"					      \
+	  "2: .long __tls_get_addr@plt\n\t"				      \
+	  "4: mov.l 3f,%0\n\t"						      \
+	  "bra 5f\n\t"							      \
+	  " add r0,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "3: .long " #x "@dtpoff\n\t"					      \
+	  "5:"								      \
+	  : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5",     \
+				      "r6", "r7", "pr", "t");		      \
+     __l; })
+#else
+# define TLS_LD(x) \
+  ({ int *__l;								      \
+     asm ("mov.l r12,@-r15\n\t"						      \
+	  "mova 0f,r0\n\t"						      \
+	  "mov.l 0f,r12\n\t"						      \
+	  "add r0,r12\n\t"						      \
+	  "mov.l 1f,r4\n\t"						      \
+	  "mova 2f,r0\n\t"						      \
+	  "mov.l 2f,r1\n\t"						      \
+	  "add r0,r1\n\t"						      \
+	  "jsr @r1\n\t"							      \
+	  " add r12,r4\n\t"						      \
+	  "bra 4f\n\t"							      \
+	  " nop\n\t"							      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@tlsldm\n\t"					      \
+	  "2: .long __tls_get_addr@plt\n\t"				      \
+	  "0: .long _GLOBAL_OFFSET_TABLE_\n\t"				      \
+	  "4: mov.l 3f,%0\n\t"						      \
+	  "bra 5f\n\t"							      \
+	  " add r0,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "3: .long " #x "@dtpoff\n\t"					      \
+	  "5: mov.l @r15+,r12"						      \
+	  : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",    \
+			   "pr", "t");					      \
+     __l; })
+#endif
+
+#ifdef PIC
+# define TLS_GD(x) \
+  ({ int *__l;								      \
+     register void *__gp __asm__("r12");				      \
+     asm ("mov.l 1f,r4\n\t"						      \
+	  "mova 2f,r0\n\t"						      \
+	  "mov.l 2f,r1\n\t"						      \
+	  "add r0,r1\n\t"						      \
+	  "jsr @r1\n\t"							      \
+	  " add r12,r4\n\t"						      \
+	  "bra 3f\n\t"							      \
+	  " mov r0,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@tlsgd\n\t"					      \
+	  "2: .long __tls_get_addr@plt\n\t"				      \
+	  "3:"								      \
+	  : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5",     \
+				      "r6", "r7", "pr", "t");		      \
+     __l; })
+#else
+# define TLS_GD(x) \
+  ({ int *__l;								      \
+     asm ("mov.l r12,@-r15\n\t"						      \
+	  "mova 0f,r0\n\t"						      \
+	  "mov.l 0f,r12\n\t"						      \
+	  "add r0,r12\n\t"						      \
+	  "mov.l 1f,r4\n\t"						      \
+	  "mova 2f,r0\n\t"						      \
+	  "mov.l 2f,r1\n\t"						      \
+	  "add r0,r1\n\t"						      \
+	  "jsr @r1\n\t"							      \
+	  " add r12,r4\n\t"						      \
+	  "bra 3f\n\t"							      \
+	  " mov r0,%0\n\t"						      \
+	  ".align 2\n\t"						      \
+	  "1: .long " #x "@tlsgd\n\t"					      \
+	  "2: .long __tls_get_addr@plt\n\t"				      \
+	  "0: .long _GLOBAL_OFFSET_TABLE_\n\t"				      \
+	  "3: mov.l @r15+,r12"						      \
+	  : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",    \
+			   "pr", "t");					      \
+     __l; })
+#endif
diff --git a/REORG.TODO/sysdeps/sh/tst-audit.h b/REORG.TODO/sysdeps/sh/tst-audit.h
new file mode 100644
index 0000000000..a7250a9817
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/tst-audit.h
@@ -0,0 +1,25 @@
+/* Definitions for testing PLT entry/exit auditing.  SH 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_sh_gnu_pltenter
+#define pltexit la_sh_gnu_pltexit
+#define La_regs La_sh_regs
+#define La_retval La_sh_retval
+#define int_retval lrv_r0