SH support, from Paul Mundt.

diff --git a/include/arch/sh/klibc/archsetjmp.h b/include/arch/sh/klibc/archsetjmp.h
new file mode 100644
index 0000000..28dd932
--- /dev/null
+++ b/include/arch/sh/klibc/archsetjmp.h
@@ -0,0 +1,22 @@
+/*
+ * arch/sh/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+  unsigned long r8;
+  unsigned long r9;
+  unsigned long r10;
+  unsigned long r11;
+  unsigned long r12;
+  unsigned long r13;
+  unsigned long r14;
+  unsigned long r15;
+  unsigned long pr;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/README b/klibc/README
index a4a3b53..7d57518 100644
--- a/klibc/README
+++ b/klibc/README
@@ -35,13 +35,13 @@
    The following is the last known status of various architectures:
 
    Known to work:	       alpha arm i386 s390 s390x sparc sparc64 x86_64*
-   Works static, not shared:   mips* arm-thumb
+   Works static, not shared:   mips* arm-thumb sh*
    Need crt0.S updates:	       ppc 
    Missing setjmp:	       ppc64
-   Need porting work:	       cris ia64 m68k mips64 parisc sh
+   Need porting work:	       cris ia64 m68k mips64 parisc
 
-   x86_64: requires a kernel header patch (to be created)
-   mips:   linker problem; might work with fixed linker
+   x86_64:   requires a kernel header patch (to be created)
+   mips, sh: linker problem; might work with fixed linker
 
    Shared library support for sparc/sparc64 requires binutils 2.13.90.0.4.
 
diff --git a/klibc/arch/sh/MCONFIG b/klibc/arch/sh/MCONFIG
index 05e09e4..6cd4e5c 100644
--- a/klibc/arch/sh/MCONFIG
+++ b/klibc/arch/sh/MCONFIG
@@ -7,5 +7,13 @@
 # accordingly.
 #
 
-OPTFLAGS = -Os -fomit-frame-pointer
-BITSIZE  = 32
+ARCHREGFLAGS = -m4 -mno-implicit-fp
+OPTFLAGS     = -Os -fomit-frame-pointer
+BITSIZE      = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 2 MB -- the normal starting point for text is 4 MB.
+SHAREDFLAGS	= -Ttext 0x00200200
+
diff --git a/klibc/arch/sh/Makefile.inc b/klibc/arch/sh/Makefile.inc
index 231911f..16d7ea1 100644
--- a/klibc/arch/sh/Makefile.inc
+++ b/klibc/arch/sh/Makefile.inc
@@ -7,4 +7,8 @@
 # accordingly.
 #
 
+ARCHOBJS = arch/sh/setjmp.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
 archclean:
diff --git a/klibc/arch/sh/crt0.S b/klibc/arch/sh/crt0.S
new file mode 100644
index 0000000..c9938a5
--- /dev/null
+++ b/klibc/arch/sh/crt0.S
@@ -0,0 +1,28 @@
+#
+# arch/sh/crt0.S
+#
+# void _start(void)
+# {
+#    /* Divine up argc, argv, and envp */
+#    environ = envp;
+#    exit(main(argc, argv, envp));
+# } 
+#
+
+	.text
+	.align 2
+	.type _start,#function
+	.globl _start
+	
+_start:
+	mov	r15, r4
+	mov	#0, r5
+	mov.l	1f, r0
+
+	jsr	@r0
+	 nop
+
+	.align 2
+1:	.long	__libc_init
+
+	.size _start,.-_start
diff --git a/klibc/arch/sh/include/klibc/archsetjmp.h b/klibc/arch/sh/include/klibc/archsetjmp.h
new file mode 100644
index 0000000..28dd932
--- /dev/null
+++ b/klibc/arch/sh/include/klibc/archsetjmp.h
@@ -0,0 +1,22 @@
+/*
+ * arch/sh/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+  unsigned long r8;
+  unsigned long r9;
+  unsigned long r10;
+  unsigned long r11;
+  unsigned long r12;
+  unsigned long r13;
+  unsigned long r14;
+  unsigned long r15;
+  unsigned long pr;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
diff --git a/klibc/arch/sh/setjmp.S b/klibc/arch/sh/setjmp.S
new file mode 100644
index 0000000..63f7602
--- /dev/null
+++ b/klibc/arch/sh/setjmp.S
@@ -0,0 +1,65 @@
+#
+# arch/sh/setjmp.S
+#
+# setjmp/longjmp for the SuperH architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+#
+#		r8
+#		r9
+#		r10
+#		r11
+#		r12
+#		r13
+#		r14
+#		r15
+#		pr
+#
+
+	.text
+	.align 2
+
+	.globl setjmp
+	.type setjmp, #function
+
+setjmp:
+	add	#(9*4), r4
+	sts.l	pr, @-r4
+	mov.l	r15, @-r4
+	mov.l	r14, @-r4
+	mov.l	r13, @-r4
+	mov.l	r12, @-r4
+	mov.l	r11, @-r4
+	mov.l	r10, @-r4
+	mov.l	r9, @-r4
+	mov.l	r8, @-r4
+	rts
+	 mov	#0, r0
+
+	.size setjmp,.-setjmp
+
+	.align 2
+	.globl longjmp
+	.type setjmp, #function
+
+longjmp:
+	mov.l	@r4+, r8
+	mov.l	@r4+, r9
+	mov.l	@r4+, r10
+	mov.l	@r4+, r11
+	mov.l	@r4+, r12
+	mov.l	@r4+, r13
+	mov.l	@r4+, r14
+	mov.l	@r4+, r15
+	lds.l	@r4+, pr
+	mov	r5, r0
+	tst	r0, r0
+	bf	1f
+	mov	#1, r0	! in case val==0
+1:	rts
+	 nop
+
+	.size longjmp,.-longjmp
+