More work on the cris architecture, but apparently it needs
multiply/divide helper functions, and might have some problem with ld?

diff --git a/klibc/Makefile b/klibc/Makefile
index b05a7e4..2ef8076 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -71,7 +71,7 @@
 	$(STRIP) $@.stripped
 
 tests/%.shared : tests/%.o interp.o $(SOLIB)
-	$(LD) $(LDFLAGS) -o $@ -e main interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
+	$(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
 	cp $@ $@.stripped
 	$(STRIP) $@.stripped
 
diff --git a/klibc/arch/cris/MCONFIG b/klibc/arch/cris/MCONFIG
index 33e0c48..6181576 100644
--- a/klibc/arch/cris/MCONFIG
+++ b/klibc/arch/cris/MCONFIG
@@ -13,5 +13,8 @@
 # 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
-# 96? MB - normal binaries start at 128? MB
-SHAREDFLAGS     = -Ttext 0x06000200
+# 1008 MB - normal binaries start at 0
+SHAREDFLAGS     = -Ttext 0x3f000200
+
+# How to tell the linker main() is the entrypoint
+EMAIN		:= -e _main
diff --git a/klibc/arch/cris/Makefile.inc b/klibc/arch/cris/Makefile.inc
index 9c8ed6d..ab35096 100644
--- a/klibc/arch/cris/Makefile.inc
+++ b/klibc/arch/cris/Makefile.inc
@@ -10,11 +10,6 @@
 ARCHOBJS = \
 	arch/$(ARCH)/setjmp.o \
 	arch/$(ARCH)/syscall.o \
-	libgcc/__ashldi3.o \
-	libgcc/__ashrdi3.o \
-	libgcc/__lshrdi3.o \
-	libgcc/__muldi3.o \
-	libgcc/__negdi2.o \
 	libgcc/__divdi3.o \
 	libgcc/__moddi3.o \
 	libgcc/__udivdi3.o \
diff --git a/klibc/arch/cris/crt0.S b/klibc/arch/cris/crt0.S
index 34fe875..73a262f 100644
--- a/klibc/arch/cris/crt0.S
+++ b/klibc/arch/cris/crt0.S
@@ -8,22 +8,21 @@
 # arguments.
 #
 
-	.set noreorder
-		
 	.text
 	.balign 4
-	.type	_start,@function
-	.globl	_start
-_start:
-	# Set up a dummy stack frame to keep gcc from getting confused
-	push	$p8		# p8 == 0
-	push	$p8		# p8 == 0
+	.type	__start,@function
+	.globl	__start
+__start:
+	/* Save the address of the ELF argument array */
+	move.d	$sp,$r10	/* Address of ELF arguments */
+
+	/* atexit() function (assume null) */
+	moveq	0,$r11
 	
-	# Save the address of the ELF argument array
-	move.d	$sp,$r10	# Address of ELF arguments
+	/* Set up a dummy stack frame to keep gcc from getting confused */
+	push	$r11
+	jump	___libc_init
+	  push	$r11
 
-	jump	__libc_init
-	  moveq.d	0,$r11	# atexit() function [assume null]
-
-	.size _start, .-_start
+	.size __start, .-__start
 
diff --git a/klibc/arch/cris/setjmp.S b/klibc/arch/cris/setjmp.S
index 8506810..cc45103 100644
--- a/klibc/arch/cris/setjmp.S
+++ b/klibc/arch/cris/setjmp.S
@@ -11,28 +11,26 @@
 #	return address
 #
 
-	.set noreorder
-	
 	.text
-	.align 4
-	.globl setjmp
-	.type setjmp, @function
-setjmp:
-	movem	$r8,[$r10+]		# Save $r8..$r0 at $r10..
+	.balign 4
+	.globl	_setjmp
+	.type	_setjmp, @function
+_setjmp:
+	movem	$r8,[$r10+]		/* Save $r8..$r0 at $r10... */
 	move.d	$sp,[$r10+]
 	ret
 	  move	$srp,[$r10+]
 
-	.size setjmp,.-setjmp
+	.size _setjmp,.-_setjmp
 
 	.text
-	.align 4
-	.globl longjmp
-	.type longjmp, @function
-longjmp:
-	movem	[$r10+],$r8		# Load $r8..$r0 from $r10..
+	.balign 4
+	.globl	_longjmp
+	.type	_longjmp, @function
+_longjmp:
+	movem	[$r10+],$r8		/* Load $r8..$r0 from $r10... */
 	move.d	[$r10+],$sp
 	jump	[$r10+]
 	  move.d $r11,$r10
 	
-	.size longjmp,.-longjmp
+	.size _longjmp,.-_longjmp
diff --git a/klibc/arch/cris/syscall.S b/klibc/arch/cris/syscall.S
index 12d8ce7..b913b1e 100644
--- a/klibc/arch/cris/syscall.S
+++ b/klibc/arch/cris/syscall.S
@@ -7,26 +7,23 @@
  * to save $srp around the system call.
  */
 
-	.set noreorder
-
-	.text
-	.subsection ".syscall"
-	.align	4
-	.globl	__syscall_common
-	.type	__syscall_common,@function
-__syscall_common:
+	.section ".text","ax"
+	.balign	4
+	.globl	___syscall_common
+	.type	___syscall_common,@function
+___syscall_common:
 	push	$srp
-	move.d	[$sp+4],$mof
-	move.d	[$sp+8],$srp
+	move	[$sp+4],$mof
+	move	[$sp+8],$srp
 	break	13
 
-	cmpq.d	-4096,$r10
+	cmp.d	-4096,$r10
 	blt	1f
 	  neg.d	$r10,$r11
-	move.d	$r11,[errno]
-	moveq.d	-1,$r10
+	move.d	$r11,[_errno]
+	moveq	-1,$r10
 1:
 	jump	[sp+]
 	  nop
 
-	.size	__syscall_common,.-__syscall_common
+	.size	___syscall_common,.-___syscall_common
diff --git a/klibc/arch/cris/sysstub.ph b/klibc/arch/cris/sysstub.ph
index cc4ca3a..42e94f2 100644
--- a/klibc/arch/cris/sysstub.ph
+++ b/klibc/arch/cris/sysstub.ph
@@ -5,25 +5,24 @@
 # Script to generate system call stubs
 #
 
-# We use a subsection for the syscall stubs, so we can be
-# sure they're within reach of a 16-bit BA
-
 sub make_sysstub($$$$@) {
     my($fname, $type, $sname, $stype, @args) = @_;
 
     open(OUT, '>', "syscalls/${fname}.S");
     print OUT "#include <asm/unistd.h>\n";
     print OUT "\n";
-    print OUT "\t.set noreorder\n";
-    print OUT "\n";
     print OUT "\t.text\n";
-    print OUT "\t.subsection \".syscall\"\n";
-    print OUT "\t.type ${fname},\@function\n";
-    print OUT "\t.globl ${fname}\n";
-    print OUT "${fname}:\n";
-    print OUT "\tba\t__syscall_common\n";
-    print OUT "\t  move.d\t__NR_${sname}, $r9\n";
-    print OUT "\t.size ${fname},.-${fname}\n";
+    print OUT "\t.type\t_${fname},\@function\n";
+    print OUT "\t.globl\t_${fname}\n";
+    print OUT "\t.balign\t4\n";
+    print OUT "_${fname}:\n";
+    print OUT "\tjump\t___syscall_common\n";
+    print OUT "#if __NR_${sname} <= 31\n";
+    print OUT "\t  moveq\t__NR_${sname}, \$r9\n";
+    print OUT "#else\n";
+    print OUT "\t  move.d\t__NR_${sname}, \$r9\n";
+    print OUT "#endif\n";
+    print OUT "\t.size _${fname},.-_${fname}\n";
     close(OUT);
 }