diff -Nuar gcc-2.95.4.orig/gcc/config/mips/linux.h gcc-2.95.4/gcc/config/mips/linux.h
--- gcc-2.95.4.orig/gcc/config/mips/linux.h	Thu May 20 12:51:36 1999
+++ gcc-2.95.4/gcc/config/mips/linux.h	Tue Mar 18 14:06:15 2003
@@ -67,29 +67,36 @@
 
 
 #undef SUBTARGET_ASM_SPEC
-#define SUBTARGET_ASM_SPEC "-KPIC"
+#define SUBTARGET_ASM_SPEC "%{mno-abicalls:%{membedded-pic:-KPIC}} \
+	%{!mno-abicalls:%{!fno-PIC:%{!fno-pic:-KPIC}}} "
 
 /* Undefine the following which were defined in elf.h.  This will cause the linux
    port to continue to use collect2 for constructors/destructors.  These may be removed
    when .ctor/.dtor section support is desired. */
 
+/*
 #undef CTORS_SECTION_ASM_OP
 #undef DTORS_SECTION_ASM_OP
 
+
 #undef EXTRA_SECTIONS
 #define EXTRA_SECTIONS in_sdata, in_rdata
+*/
 
 #undef INVOKE__main
 #undef NAME__MAIN
 #undef SYMBOL__MAIN
 
+/*
 #undef EXTRA_SECTION_FUNCTIONS
 #define EXTRA_SECTION_FUNCTIONS                                         \
   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
 
+
 #undef ASM_OUTPUT_CONSTRUCTOR
 #undef ASM_OUTPUT_DESTRUCTOR
+*/
 
 #undef CTOR_LIST_BEGIN
 #undef CTOR_LIST_END
@@ -97,3 +104,29 @@
 #undef DTOR_LIST_END
 
 /*  End of undefines to turn off .ctor/.dtor section support */
+// To generate crtbegin and crtend that use .init and .fini sections
+#define INIT_SECTION_ASM_OP     ".section\t.init"
+#define FINI_SECTION_ASM_OP     ".section\t.fini"
+
+#undef CPP_PREDEFINES
+#define CPP_PREDEFINES "-Dmips -Acpu(mips) -Amachine(mips) \
+	-Dunix -Asystem(unix) -D__ELF__ -Dlinux -Asystem(linux) \
+	-Asystem(posix) -DMIPSEB -D__PIC__ -D__pic__"
+
+#undef SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC "\
+	%{mno-abicalls:%{!membedded-pic:-U__PIC__ -U__pic__}} \
+	%{fno-pic:-U__PIC__ -U__pic__} %{fno-PIC:-U__PIC__ -U__pic__} \
+	%{mcpu=r4kc:-DR4KC -D_R4KC -D__R4KC} \
+	%{!mcpu=r4kc:-DR3000 -D_R3000 -D__R3000}"
+
+#undef LIB_SPEC
+#define LIB_SPEC \
+	"%{shared: -lc} \
+	%{!shared: %{pthread:-lpthread} \
+	%{profile:-lc_p} %{!profile: -lc}}"
+
+#undef DEFAULT_VTABLE_THUNKS
+#define DEFAULT_VTABLE_THUNKS 1
+
+#define HANDLE_SYSV_PRAGMA
diff -Nuar gcc-2.95.4.orig/gcc/config/mips/mips.c gcc-2.95.4/gcc/config/mips/mips.c
--- gcc-2.95.4.orig/gcc/config/mips/mips.c	Thu May 20 12:51:36 1999
+++ gcc-2.95.4/gcc/config/mips/mips.c	Tue Mar 18 14:06:15 2003
@@ -4232,6 +4232,8 @@
 	    mips_cpu = PROCESSOR_R4600;
 	  else if (!strcmp (p, "4650"))
 	    mips_cpu = PROCESSOR_R4650;
+	  else if (!strcmp (p, "4kc") || !strcmp (p, "4Kc"))
+	    mips_cpu = PROCESSOR_R4KC;
 	  break;
 
 	case '5':
diff -Nuar gcc-2.95.4.orig/gcc/config/mips/mips.h gcc-2.95.4/gcc/config/mips/mips.h
--- gcc-2.95.4.orig/gcc/config/mips/mips.h	Thu May 20 12:51:36 1999
+++ gcc-2.95.4/gcc/config/mips/mips.h	Tue Mar 18 14:06:15 2003
@@ -69,7 +69,8 @@
   PROCESSOR_R4600,
   PROCESSOR_R4650,
   PROCESSOR_R5000,
-  PROCESSOR_R8000
+  PROCESSOR_R8000,
+  PROCESSOR_R4KC
 };
 
 /* Recast the cpu class to be the cpu attribute.  */
@@ -359,6 +360,8 @@
 /* generate mips 3900 insns */
 #define TARGET_MIPS3900         (target_flags & MASK_MIPS3900)
 
+#define TARGET_MIPS4KC          (mips_arch == PROCESSOR_R4KC)
+
 					/* Mips vs. GNU assembler */
 #define TARGET_GAS		(target_flags & MASK_GAS)
 #define TARGET_UNIX_ASM		(!TARGET_GAS)
diff -Nuar gcc-2.95.4.orig/gcc/configure.in gcc-2.95.4/gcc/configure.in
--- gcc-2.95.4.orig/gcc/configure.in	Fri Aug 24 12:50:50 2001
+++ gcc-2.95.4/gcc/configure.in	Tue Mar 18 14:06:15 2003
@@ -2375,7 +2375,7 @@
                        mipsel-*)  tm_file="mips/elfl.h mips/linux.h" ;;
                        *)         tm_file="mips/elf.h mips/linux.h" ;;
                esac
-		extra_parts="crtbegin.o crtend.o"
+		extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
 		gnu_ld=yes
 		gas=yes
 		;;
diff -Nuar gcc-2.95.4.orig/gcc/cross_update_cpu.c gcc-2.95.4/gcc/cross_update_cpu.c
--- gcc-2.95.4.orig/gcc/cross_update_cpu.c	Tue Mar 18 14:04:37 2003
+++ gcc-2.95.4/gcc/cross_update_cpu.c	Tue Mar 18 14:06:33 2003
@@ -23,6 +23,10 @@
   {"920TDI", "arm9"}
 };
 
+struct target_cpu mips_cpu_tbl[] = {
+  {"4KC", "r4kc"}
+};
+
 void cross_update_cpu(argc, argv, family_cpu)
   int *argc;
   char ***argv;
@@ -33,9 +37,9 @@
   int is_arm = 0;
 
   if (!strncasecmp(family_cpu, "ppc_", 4) || 
-      (is_arm = !strncasecmp(family_cpu, "arm_", 4)))
+      (is_arm = !strncasecmp(family_cpu, "arm_", 4)) ||
+      !strncasecmp(family_cpu, "mips_", 5))
   {
-    cpu = family_cpu + 4;
 
     for (i = 0; i < *argc; i++)
     {
@@ -49,7 +53,8 @@
       char **newargv = xmalloc((*argc + 1)*sizeof(char *));
       char *cpu_id = NULL;
 
-      if (is_arm)
+      if (is_arm) {
+        cpu = family_cpu + 4;
         for (i = 0; i < sizeof(arm_cpu_tbl)/sizeof(arm_cpu_tbl[0]); i++)
         {
           if (! strcmp(arm_cpu_tbl[i].target_arch, cpu)) {
@@ -57,7 +62,9 @@
             break;
           }
         }
-      else
+      }
+      if (!strncasecmp(family_cpu, "ppc_", 4)) {
+        cpu = family_cpu + 4;
         for (i = 0; i < sizeof(ppc_cpu_tbl)/sizeof(ppc_cpu_tbl[0]); i++)
         {
           if (! strcmp(ppc_cpu_tbl[i].target_arch, cpu)) {
@@ -65,7 +72,19 @@
             break;
           }
         }
-
+      }
+      if (!strncasecmp(family_cpu, "mips_", 5))
+      {
+        cpu = family_cpu + 5;
+        for (i = 0; i < sizeof(mips_cpu_tbl)/sizeof(mips_cpu_tbl[0]); i++)
+        {
+          if (! strcmp(mips_cpu_tbl[i].target_arch, cpu)) {
+            cpu_id = mips_cpu_tbl[i].cpu_id;
+            break;
+          }
+        }
+      }
+      
       if (cpu_id)
       {
         newargv[0] = (*argv)[0];
