Cris architecture fixes

diff --git a/MCONFIG b/MCONFIG
index 0b6575c..c9e9b70 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -50,3 +50,6 @@
 # Include arch-specific rule fragments
 #
 include $(KLIBSRC)/arch/$(ARCH)/MCONFIG
+
+# How to tell the linker main() is the entrypoint
+EMAIN ?= -e main
diff --git a/ash/Makefile b/ash/Makefile
index 0f462dc..66bf533 100644
--- a/ash/Makefile
+++ b/ash/Makefile
@@ -38,7 +38,7 @@
 	$(STRIP) $@
 
 $(PROG).shared: $(OBJS) $(CRTSHARED) $(LIBSHARED) $(LIBGCC)
-	$(LD) $(LDFLAGS) -o $(PROG).shared -e main $(CRTSHARED) $(OBJS) -R $(LIBSHARED) $(LIBGCC)
+	$(LD) $(LDFLAGS) -o $(PROG).shared $(EMAIN) $(CRTSHARED) $(OBJS) -R $(LIBSHARED) $(LIBGCC)
 	cp -f $@ $@.g
 	$(STRIP) $@
 
diff --git a/klibc/arch/cris/MCONFIG b/klibc/arch/cris/MCONFIG
index 4ff7e05..646cd82 100644
--- a/klibc/arch/cris/MCONFIG
+++ b/klibc/arch/cris/MCONFIG
@@ -15,7 +15,7 @@
 # calls, and work on the memory models for this architecture
 # 224 MB - normal binaries start at 0
 # (lib?)gcc on cris seems to insist on producing .init and .fini sections
-SHAREDFLAGS     = -Wl,--section-start,.init=0x0e000100
+SHAREDFLAGS     = --section-start .init=0x0e000100
 
 # The CRIS compiler needs an -iprefix to find libgcc includes when
 # nostdinc is used. It also needs -mlinux to compile linux applications.
@@ -23,8 +23,7 @@
 ARCHREQFLAGS = -iprefix $(INCLUDE_PREFIX) -mlinux
 
 # How to tell the linker main() is the entrypoint
-EMAIN		:= -e _main
+EMAIN		:= -e main
 
-# Use gcc to link to get all the flags correct
-LD = cris-gcc
-LDFLAGS += -mlinux -nostdlib
\ No newline at end of file
+# Special flags needed for linking
+LDFLAGS 	+= -mcrislinux
diff --git a/klibc/arch/cris/Makefile.inc b/klibc/arch/cris/Makefile.inc
index eec7cb2..732307b 100644
--- a/klibc/arch/cris/Makefile.inc
+++ b/klibc/arch/cris/Makefile.inc
@@ -8,8 +8,8 @@
 #
 
 ARCHOBJS = \
-	arch/$(ARCH)/__UMod.o \
-	arch/$(ARCH)/__UDiv.o \
+	arch/$(ARCH)/__Umod.o \
+	arch/$(ARCH)/__Udiv.o \
 	arch/$(ARCH)/__Mod.o \
 	arch/$(ARCH)/__Div.o \
 	arch/$(ARCH)/setjmp.o \
@@ -21,10 +21,10 @@
 	libgcc/__udivmoddi4.o \
 	libgcc/__negdi2.o
 
-arch/$(ARCH)/__UMod.o: arch/$(ARCH)/divide.c
-	$(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__UMod -c -o $@ $<
-arch/$(ARCH)/__UDiv.o: arch/$(ARCH)/divide.c
-	$(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__UDiv -c -o $@ $<
+arch/$(ARCH)/__Umod.o: arch/$(ARCH)/divide.c
+	$(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__Umod -c -o $@ $<
+arch/$(ARCH)/__Udiv.o: arch/$(ARCH)/divide.c
+	$(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__Udiv -c -o $@ $<
 arch/$(ARCH)/__Mod.o: arch/$(ARCH)/divide.c
 	$(CC) $(CFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__Mod -c -o $@ $<
 arch/$(ARCH)/__Div.o: arch/$(ARCH)/divide.c
diff --git a/klibc/arch/cris/divide.c b/klibc/arch/cris/divide.c
index c36b657..ebf8173 100644
--- a/klibc/arch/cris/divide.c
+++ b/klibc/arch/cris/divide.c
@@ -2,34 +2,34 @@
 #include <signal.h>
 
 #if BITS == 64
-typedef uint64_t uint;
-typedef int64_t  sint;
+typedef uint64_t unum;
+typedef int64_t  snum;
 #else
-typedef uint32_t uint;
-typedef int32_t  sint;
+typedef uint32_t unum;
+typedef int32_t  snum;
 #endif
 
 #ifdef SIGNED
-typedef sint xint;
+typedef snum xnum;
 #else
-typedef uint xint;
+typedef unum xnum;
 #endif
 
 #ifdef __cris__
-static inline uint __attribute__((const)) dstep(uint rs, uint rd) {
+static inline unum __attribute__((const)) dstep(unum rs, unum rd) {
   asm("dstep %1,%0" : "+r" (rd) : "r" (rs));
   return rd;
 }
 
-static inline uint __attribute__((const)) lz(uint rs) {
-  uint rd;
+static inline unum __attribute__((const)) lz(unum rs) {
+  unum rd;
   asm("lz %1,%0" : "=r" (rd) : "r" (rs));
   return rd;
 }
 
 #else
 /* For testing */
-static inline uint __attribute__ ((const)) dstep(uint rs, uint rd) {
+static inline unum __attribute__ ((const)) dstep(unum rs, unum rd) {
   rd <<= 1;
   if ( rd >= rs )
     rd -= rs;
@@ -37,8 +37,8 @@
   return rd;
 }
 
-static inline uint __attribute__((const)) lz(uint rs) {
-  uint rd = 0;
+static inline unum __attribute__((const)) lz(unum rs) {
+  unum rd = 0;
   while ( rs >= 0x7fffffff ) {
     rd++;
     rs <<= 1;
@@ -48,11 +48,11 @@
 
 #endif
 
-xint NAME (uint num, uint den)
+xnum NAME (unum num, unum den)
 {
-  uint quot = 0, qbit = 1;
+  unum quot = 0, qbit = 1;
   int minus = 0;
-  xint v;
+  xnum v;
   
   if ( den == 0 ) {
     raise(SIGFPE);
@@ -60,17 +60,17 @@
   }
 
 #if SIGNED
-  if ( (sint)(num^den) < 0 )
+  if ( (snum)(num^den) < 0 )
     minus = 1;
-  if ( (sint)num < 0 ) num = -num;
-  if ( (sint)den < 0 ) den = -den;
+  if ( (snum)num < 0 ) num = -num;
+  if ( (snum)den < 0 ) den = -den;
 #endif
 
   den--;
 
 
   /* Left-justify denominator and count shift */
-  while ( (sint)den >= 0 ) {
+  while ( (snum)den >= 0 ) {
     den <<= 1;
     qbit <<= 1;
   }
@@ -84,7 +84,7 @@
     qbit >>= 1;
   }
 
-  v = (xint)(REM ? num : quot);
+  v = (xnum)(REM ? num : quot);
   if ( minus ) v = -v;
   return v;
 }
diff --git a/utils/Makefile b/utils/Makefile
index 23f2a77..da0fee9 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -22,7 +22,7 @@
 
 shared/%: %.o $(CRTSHARED) $(LIBSHARED) $(LIBUTILS)
 	mkdir -p shared shared.g
-	$(LD) $(LDFLAGS) -o $@ -e main $(CRTSHARED) $< $(LIBUTILS) \
+	$(LD) $(LDFLAGS) -o $@ $(EMAIN) $(CRTSHARED) $< $(LIBUTILS) \
 		-R $(LIBSHARED) $(LIBGCC)
 	cp -f $@ shared.g
 	$(STRIP) $@