diff -rNu gcc-3.4.3/boehm-gc/include/private/gcconfig.h gcc/boehm-gc/include/private/gcconfig.h
--- gcc-3.4.3/boehm-gc/include/private/gcconfig.h	2004-04-22 00:17:48.000000000 +0900
+++ gcc/boehm-gc/include/private/gcconfig.h	2004-10-22 10:22:24.000000000 +0900
@@ -249,6 +249,10 @@
 #    define SH
 #    define mach_type_known
 # endif
+# if defined(LINUX) && defined(__m32r__)
+#    define M32R
+#    define mach_type_known
+# endif
 # if defined(__alpha) || defined(__alpha__)
 #   define ALPHA
 #   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
@@ -1768,6 +1772,23 @@
 #   define DATAEND /* not needed */
 # endif
 
+# ifdef M32R
+#   define CPP_WORDSZ 32
+#   define MACH_TYPE "M32R"
+#   define ALIGNMENT 4
+#   ifdef LINUX
+#     define OS_TYPE "LINUX"
+#     define LINUX_STACKBOTTOM
+#     undef STACK_GRAN
+#     define STACK_GRAN 0x10000000
+#     define USE_GENERIC_PUSH_REGS
+#     define DYNAMIC_LOADING
+#     define SEARCH_FOR_DATA_START
+      extern int _end[];
+#     define DATAEND (_end)
+#   endif
+# endif
+
 # ifdef X86_64
 #   define MACH_TYPE "X86_64"
 #   define ALIGNMENT 8
diff -rNu gcc-3.4.3/gcc/config/m32r/libgcc-glibc.ver gcc/gcc/config/m32r/libgcc-glibc.ver
--- gcc-3.4.3/gcc/config/m32r/libgcc-glibc.ver	1970-01-01 09:00:00.000000000 +0900
+++ gcc/gcc/config/m32r/libgcc-glibc.ver	2005-02-03 10:05:13.000000000 +0900
@@ -0,0 +1,21 @@
+# In order to work around the very problems that force us to now generally
+# create a libgcc.so, glibc reexported a number of routines from libgcc.a.
+# By now choosing the same version tags for these specific routines, we
+# maintain enough binary compatibility to allow future versions of glibc
+# to defer implementation of these routines to libgcc.so via DT_AUXILIARY.
+
+# Note that we cannot use the default libgcc-glibc.ver file on m32r,
+# because GLIBC_2.0 does not exist on this architecture, as the first 
+# ever glibc release on the platform was GLIBC_2.3.
+
+%inherit GCC_3.0 GLIBC_2.3
+GLIBC_2.3 {
+  __register_frame
+  __register_frame_table
+  __deregister_frame
+  __register_frame_info
+  __deregister_frame_info
+  __frame_state_for
+  __register_frame_info_table
+}
+
diff -rNu gcc-3.4.3/gcc/config/m32r/linux.h gcc/gcc/config/m32r/linux.h
--- gcc-3.4.3/gcc/config/m32r/linux.h	2003-12-31 19:33:02.000000000 +0900
+++ gcc/gcc/config/m32r/linux.h	2005-02-03 10:05:26.000000000 +0900
@@ -102,3 +102,4 @@
                                                                                 
 #define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS()
 
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
diff -rNu gcc-3.4.3/gcc/config/m32r/m32r.c gcc/gcc/config/m32r/m32r.c
--- gcc-3.4.3/gcc/config/m32r/m32r.c	2004-08-26 22:00:13.000000000 +0900
+++ gcc/gcc/config/m32r/m32r.c	2005-02-03 10:01:42.000000000 +0900
@@ -2204,6 +2204,15 @@
       else
         address = reg;
 
+      current_function_uses_pic_offset_table = 1;
+      if (GET_CODE (orig) == LABEL_REF
+          || GET_CODE (orig) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (orig))
+        {
+          emit_insn (gen_gotoff_load_addr (reg, orig));
+          emit_insn (gen_addsi3 (reg, reg, pic_offset_table_rtx));
+          return reg;
+        }
+
       emit_insn (gen_pic_load_addr (address, orig));
 
       emit_insn (gen_addsi3 (address, address, pic_offset_table_rtx));
@@ -2211,7 +2220,6 @@
 
       RTX_UNCHANGING_P (pic_ref) = 1;
       insn = emit_move_insn (reg, pic_ref);
-      current_function_uses_pic_offset_table = 1;
 #if 0
       /* Put a REG_EQUAL note on this insn, so that it can be optimized
          by loop.  */
diff -rNu gcc-3.4.3/gcc/config/m32r/m32r.md gcc/gcc/config/m32r/m32r.md
--- gcc-3.4.3/gcc/config/m32r/m32r.md	2004-08-24 18:37:43.000000000 +0900
+++ gcc/gcc/config/m32r/m32r.md	2005-02-03 10:01:35.000000000 +0900
@@ -31,7 +31,8 @@
   [(UNSPEC_LOAD_SDA_BASE	2)
    (UNSPEC_SET_CBIT		3)
    (UNSPEC_PIC_LOAD_ADDR	4)
-   (UNSPEC_GET_PC		5)])
+   (UNSPEC_GET_PC		5)
+   (UNSPEC_GOTOFF		6)])
 
 ;; Insn type.  Used to default other attribute values.
 (define_attr "type"
@@ -2711,6 +2712,14 @@
   "ld24 %0,%#%1"
   [(set_attr "type" "int4")])
 
+(define_insn "gotoff_load_addr"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+        (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOTOFF))]
+  "flag_pic"
+  "seth %0,%#shigh(%1@GOTOFF)\;add3 %0,%0,low(%1@GOTOFF)"
+  [(set_attr "type" 	"int4")
+   (set_attr "length"	"8")])
+
 ;; Load program counter insns.
 
 (define_insn "get_pc"
diff -rNu gcc-3.4.3/gcc/config/m32r/t-linux gcc/gcc/config/m32r/t-linux
--- gcc-3.4.3/gcc/config/m32r/t-linux	2003-12-31 19:33:02.000000000 +0900
+++ gcc/gcc/config/m32r/t-linux	2005-02-03 10:01:17.000000000 +0900
@@ -23,7 +23,6 @@
 # to produce a shared library, but since we don't know ahead of time when
 # we will be doing that, we just always use -fpic when compiling the
 # routines in initfini.c.
-# -fpic currently isn't supported for the m32r.
 
 CRTSTUFF_T_CFLAGS_S = -fPIC
 
@@ -40,3 +39,15 @@
 CROSS_LIBGCC1 =
 LIBGCC1_TEST =
 
+# Override t-slibgcc-elf-ver to export some libgcc symbols with
+# the symbol versions that glibc used.
+SHLIB_MAPFILES += $(srcdir)/libgcc-std.ver \
+	$(srcdir)/config/m32r/libgcc-glibc.ver
+
+# Use unwind-dw2-fde-glibc
+LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \
+  $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c
+LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c gthr-gnat.c
+
+# We're GNU system, where GNU C library is native C library.
+CROSS_SYSTEM_HEADER_DIR = $(gcc_tooldir)/include
diff -rNu gcc-3.4.3/gcc/config.gcc gcc/gcc/config.gcc
--- gcc-3.4.3/gcc/config.gcc	2004-09-09 00:16:10.000000000 +0900
+++ gcc/gcc/config.gcc	2005-02-03 10:03:24.000000000 +0900
@@ -1304,7 +1304,7 @@
 m32r-*-linux*)
 	tm_file="dbxelf.h elfos.h svr4.h linux.h ${tm_file} m32r/linux.h"
 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
-	tmake_file="m32r/t-linux"
+	tmake_file="t-slibgcc-elf-ver m32r/t-linux"
 	gnu_ld=yes
 	use_fixproto=yes
 	if test x$enable_threads = xyes; then
@@ -1314,7 +1314,7 @@
 m32rle-*-linux*)
 	tm_file="dbxelf.h elfos.h svr4.h linux.h m32r/little.h ${tm_file} m32r/linux.h"
 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
-	tmake_file="m32r/t-linux"
+	tmake_file="t-slibgcc-elf-ver m32r/t-linux"
 	gnu_ld=yes
 	use_fixproto=yes
 	if test x$enable_threads = xyes; then
diff -rNu gcc-3.4.3/libffi/Makefile.am gcc/libffi/Makefile.am
--- gcc-3.4.3/libffi/Makefile.am	2003-10-22 04:01:53.000000000 +0900
+++ gcc/libffi/Makefile.am	2005-02-03 10:24:46.000000000 +0900
@@ -18,6 +18,7 @@
 	src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
 	src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
 	src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \
+	src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
 	src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
 	src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
 	src/sparc/ffi.c \
@@ -102,6 +103,7 @@
 TARGET_SRC_S390 =  src/s390/sysv.S src/s390/ffi.c
 TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
 TARGET_SRC_SH =  src/sh/sysv.S src/sh/ffi.c
+TARGET_SRC_M32R =  src/m32r/sysv.S src/m32r/ffi.c
 TARGET_SRC_SH64 =  src/sh64/sysv.S src/sh64/ffi.c
 
 ##libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c $(TARGET_SRC_@TARGET@)
diff -rNu gcc-3.4.3/libffi/Makefile.in gcc/libffi/Makefile.in
--- gcc-3.4.3/libffi/Makefile.in	2003-11-22 22:41:32.000000000 +0900
+++ gcc/libffi/Makefile.in	2005-02-03 10:25:19.000000000 +0900
@@ -109,6 +109,7 @@
 	src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
 	src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
 	src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \
+ 	src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
 	src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
 	src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
 	src/sparc/ffi.c \
@@ -186,6 +187,7 @@
 TARGET_SRC_S390 = src/s390/sysv.S src/s390/ffi.c
 TARGET_SRC_X86_64 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
 TARGET_SRC_SH = src/sh/sysv.S src/sh/ffi.c
+TARGET_SRC_M32R = src/m32r/sysv.S src/m32r/ffi.c
 TARGET_SRC_SH64 = src/sh64/sysv.S src/sh64/ffi.c
 
 libffi_la_common_SOURCES = src/debug.c src/prep_cif.c src/types.c \
@@ -206,6 +208,7 @@
 @S390_TRUE@libffi_la_SOURCES = @S390_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
 @X86_64_TRUE@libffi_la_SOURCES = @X86_64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
 @SH_TRUE@libffi_la_SOURCES = @SH_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
+@M32R_TRUE@libffi_la_SOURCES = @M32R_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_M32R)
 @SH64_TRUE@libffi_la_SOURCES = @SH64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH64)
 @MIPS_IRIX_TRUE@libffi_convenience_la_SOURCES = @MIPS_IRIX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_IRIX)
 @MIPS_LINUX_TRUE@libffi_convenience_la_SOURCES = @MIPS_LINUX_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_MIPS_LINUX)
@@ -222,6 +225,7 @@
 @S390_TRUE@libffi_convenience_la_SOURCES = @S390_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_S390)
 @X86_64_TRUE@libffi_convenience_la_SOURCES = @X86_64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_X86_64)
 @SH_TRUE@libffi_convenience_la_SOURCES = @SH_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH)
+@M32R_TRUE@libffi_convenience_la_SOURCES = @M32R_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_M32R)
 @SH64_TRUE@libffi_convenience_la_SOURCES = @SH64_TRUE@$(libffi_la_common_SOURCES) $(TARGET_SRC_SH64)
 
 AM_CFLAGS = -Wall -g -fexceptions
@@ -275,6 +279,9 @@
 @SH_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
 @SH_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo src/sh/sysv.lo \
 @SH_TRUE@src/sh/ffi.lo
+@M32R_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
+@M32R_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo src/m32r/sysv.lo \
+@M32R_TRUE@src/m32r/ffi.lo
 @X86_WIN32_TRUE@libffi_convenience_la_OBJECTS =  src/debug.lo \
 @X86_WIN32_TRUE@src/prep_cif.lo src/types.lo src/raw_api.lo \
 @X86_WIN32_TRUE@src/java_raw_api.lo src/x86/ffi.lo src/x86/win32.lo
@@ -331,6 +338,9 @@
 @SH_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
 @SH_TRUE@src/raw_api.lo src/java_raw_api.lo src/sh/sysv.lo \
 @SH_TRUE@src/sh/ffi.lo
+@M32R_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo src/types.lo \
+@M32R_TRUE@src/raw_api.lo src/java_raw_api.lo src/m32r/sysv.lo \
+@M32R_TRUE@src/m32r/ffi.lo
 @X86_WIN32_TRUE@libffi_la_OBJECTS =  src/debug.lo src/prep_cif.lo \
 @X86_WIN32_TRUE@src/types.lo src/raw_api.lo src/java_raw_api.lo \
 @X86_WIN32_TRUE@src/x86/ffi.lo src/x86/win32.lo
@@ -609,6 +619,7 @@
 	-chmod 777 $(distdir)
 	$(mkinstalldirs) $(distdir)/src/alpha $(distdir)/src/arm \
 	   $(distdir)/src/m68k $(distdir)/src/mips \
+	   $(distdir)/src/powerpc $(distdir)/src/m32r \
 	   $(distdir)/src/powerpc $(distdir)/src/s390 $(distdir)/src/sh \
 	   $(distdir)/src/sh64 $(distdir)/src/sparc $(distdir)/src/x86
 	@for file in $(DISTFILES); do \
diff -rNu gcc-3.4.3/libffi/configure gcc/libffi/configure
--- gcc-3.4.3/libffi/configure	2004-05-18 18:08:39.000000000 +0900
+++ gcc/libffi/configure	2005-02-03 10:27:43.000000000 +0900
@@ -2844,6 +2844,7 @@
 s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
 x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
 sh-*-linux* | sh[34]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
+m32r*-*-linux* ) TARGET=M32R; TARGETDIR=m32r;;
 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
 esac
 
@@ -2989,6 +2990,13 @@
   SH_FALSE=
 fi
 
+if test x$TARGET = xM32R; then
+  M32R_TRUE=
+  M32R_FALSE='#'
+else
+  M32R_TRUE='#'
+  M32R_FALSE=
+fi
 
 if test x$TARGET = xSH64; then
   SH64_TRUE=
@@ -4030,6 +4038,8 @@
 s%@X86_64_FALSE@%$X86_64_FALSE%g
 s%@SH_TRUE@%$SH_TRUE%g
 s%@SH_FALSE@%$SH_FALSE%g
+s%@M32R_TRUE@%$M32R_TRUE%g
+s%@M32R_FALSE@%$M32R_FALSE%g
 s%@SH64_TRUE@%$SH64_TRUE%g
 s%@SH64_FALSE@%$SH64_FALSE%g
 s%@ALLOCA@%$ALLOCA%g
diff -rNu gcc-3.4.3/libffi/configure.in gcc/libffi/configure.in
--- gcc-3.4.3/libffi/configure.in	2004-04-27 14:10:19.000000000 +0900
+++ gcc/libffi/configure.in	2005-02-03 10:27:15.000000000 +0900
@@ -86,6 +86,7 @@
 s390x-*-linux-*) TARGET=S390; TARGETDIR=s390;;
 x86_64-*-linux*) TARGET=X86_64; TARGETDIR=x86;;
 sh-*-linux* | sh[[34]]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
+m32r*-*-linux* ) TARGET=M32R; TARGETDIR=m32r;;
 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
 esac
 
@@ -110,6 +111,7 @@
 AM_CONDITIONAL(S390, test x$TARGET = xS390)
 AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
 AM_CONDITIONAL(SH, test x$TARGET = xSH)
+AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
 AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
 
 case x$TARGET in
diff -rNu gcc-3.4.3/libffi/src/m32r/ffi.c gcc/libffi/src/m32r/ffi.c
--- gcc-3.4.3/libffi/src/m32r/ffi.c	1970-01-01 09:00:00.000000000 +0900
+++ gcc/libffi/src/m32r/ffi.c	2004-10-22 11:16:10.000000000 +0900
@@ -0,0 +1,246 @@
+/* -----------------------------------------------------------------------
+   ffi.c - Copyright (c) 2004  Renesas Technology
+   
+   M32R Foreign Function Interface 
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+   ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* ffi_prep_args is called by the assembly routine once stack space
+   has been allocated for the function's arguments */
+
+/*@-exportheader@*/
+void ffi_prep_args(char *stack, extended_cif *ecif)
+/*@=exportheader@*/
+{
+  register unsigned int i;
+  register int tmp;
+  register unsigned int avn;
+  register void **p_argv;
+  register char *argp;
+  register ffi_type **p_arg;
+
+  tmp = 0;
+  argp = stack;
+
+  if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 8 ) {
+    *(void **) argp = ecif->rvalue;
+    argp += 4;
+  }
+
+  avn = ecif->cif->nargs;
+  p_argv = ecif->avalue;
+
+  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+       (i != 0) && (avn != 0);
+       i--, p_arg++)
+    {
+      size_t z;
+
+      /* Align if necessary */
+      if (((*p_arg)->alignment - 1) & (unsigned) argp) {
+	argp = (char *) ALIGN(argp, (*p_arg)->alignment);
+      }
+
+      if (avn != 0) 
+	{
+	  avn--;
+	  z = (*p_arg)->size;
+	  if (z < sizeof(int))
+	    {
+	      z = sizeof(int);
+	      switch ((*p_arg)->type)
+		{
+		case FFI_TYPE_SINT8:
+		  *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+		  break;
+		  
+		case FFI_TYPE_UINT8:
+		  *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+		  break;
+		  
+		case FFI_TYPE_SINT16:
+		  *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+		  break;
+		  
+		case FFI_TYPE_UINT16:
+		  *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+		  break;
+		  
+		case FFI_TYPE_STRUCT:
+	  	  z = (*p_arg)->size;
+	  	  if ( (*p_arg)->alignment != 1 )
+	          	memcpy(argp, *p_argv, z);
+		  else
+	          	memcpy(argp + 4 - z, *p_argv, z);
+	  	  z = sizeof(int);
+		  break;
+
+		default:
+		  FFI_ASSERT(0);
+		}
+	    }
+	  else if (z == sizeof(int))
+	    {
+	       *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+	    }
+	  else
+	    {
+	      if ( (*p_arg)->type == FFI_TYPE_STRUCT )
+	        {
+		  if ( z > 8 )
+		    {
+		      *(unsigned int *) argp = (unsigned int)(void *)(* p_argv);
+		      z = sizeof(void *);
+		    }
+		  else
+		    {
+	              memcpy(argp, *p_argv, z);
+		      z = 8;
+		    }
+	        }
+	      else
+	        { /* double or long long 64bit */
+	          memcpy(argp, *p_argv, z);
+	        }
+	    }
+	  p_argv++;
+	  argp += z;
+	}
+    }
+  
+  return;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+  /* Set the return type flag */
+  switch (cif->rtype->type)
+    {
+    case FFI_TYPE_VOID:
+      cif->flags = (unsigned) cif->rtype->type;
+      break;
+
+    case FFI_TYPE_STRUCT:
+      if (cif->rtype->size <= 4)
+	{
+          cif->flags = FFI_TYPE_INT;
+	}
+      else if (cif->rtype->size <= 8)
+	{
+          cif->flags = FFI_TYPE_DOUBLE;
+	}
+      else
+	{
+          cif->flags = (unsigned) cif->rtype->type;
+	}
+      break;
+
+    case FFI_TYPE_SINT64:
+    case FFI_TYPE_UINT64:
+    case FFI_TYPE_DOUBLE:
+      cif->flags = FFI_TYPE_DOUBLE;
+      break;
+
+    case FFI_TYPE_FLOAT:
+    default:
+      cif->flags = FFI_TYPE_INT;
+      break;
+    }
+
+  return FFI_OK;
+}
+
+/*@-declundef@*/
+/*@-exportheader@*/
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), 
+			  /*@out@*/ extended_cif *, 
+			  unsigned, unsigned, 
+			  /*@out@*/ unsigned *, 
+			  void (*fn)());
+/*@=declundef@*/
+/*@=exportheader@*/
+
+void ffi_call(/*@dependent@*/ ffi_cif *cif, 
+	      void (*fn)(), 
+	      /*@out@*/ void *rvalue, 
+	      /*@dependent@*/ void **avalue)
+{
+  extended_cif ecif;
+
+  ecif.cif = cif;
+  ecif.avalue = avalue;
+  
+  /* If the return value is a struct and we don't have a return	*/
+  /* value address then we need to make one		        */
+
+  if ((rvalue == NULL) && 
+      (cif->rtype->type == FFI_TYPE_STRUCT))
+    {
+      /*@-sysunrecog@*/
+      ecif.rvalue = alloca(cif->rtype->size);
+      /*@=sysunrecog@*/
+    }
+  else
+    ecif.rvalue = rvalue;
+    
+  
+  switch (cif->abi) 
+    {
+    case FFI_SYSV:
+      /*@-usedef@*/
+      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, 
+		    cif->flags, ecif.rvalue, fn);
+      if ( cif->rtype->type == FFI_TYPE_STRUCT )
+	{
+	  int size = cif->rtype->size;
+	  int align = cif->rtype->alignment;
+	  if (size < 4)
+	    {
+	      if ( align == 1 )
+	        *(unsigned long *)(ecif.rvalue) <<= (4 - size)*8;
+	    }
+	  else if ( 4 < size && size < 8 )
+	    {
+	       if ( align == 1 )
+	         {
+	            memcpy(ecif.rvalue, ecif.rvalue + 8-size, size);
+	         }
+	       else if (align == 2)
+	         {
+		    if (size & 1) size += 1;
+		    if (size != 8)
+	              memcpy(ecif.rvalue, ecif.rvalue + 8-size, size);
+	         }
+	    }
+	}
+      /*@=usedef@*/
+      break;
+    default:
+      FFI_ASSERT(0);
+      break;
+    }
+}
diff -rNu gcc-3.4.3/libffi/src/m32r/ffitarget.h gcc/libffi/src/m32r/ffitarget.h
--- gcc-3.4.3/libffi/src/m32r/ffitarget.h	1970-01-01 09:00:00.000000000 +0900
+++ gcc/libffi/src/m32r/ffitarget.h	2005-02-03 09:33:29.000000000 +0900
@@ -0,0 +1,48 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 2004  Renesas Technology.
+   Target configuration macros for M32R.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long          ffi_arg;
+typedef signed long            ffi_sarg;
+
+typedef enum ffi_abi {
+  FFI_FIRST_ABI = 0,
+  FFI_SYSV,
+  FFI_DEFAULT_ABI = FFI_SYSV,
+  FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+#define FFI_CLOSURES 0
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff -rNu gcc-3.4.3/libffi/src/m32r/sysv.S gcc/libffi/src/m32r/sysv.S
--- gcc-3.4.3/libffi/src/m32r/sysv.S	1970-01-01 09:00:00.000000000 +0900
+++ gcc/libffi/src/m32r/sysv.S	2004-10-22 10:22:24.000000000 +0900
@@ -0,0 +1,122 @@
+/* -----------------------------------------------------------------------
+   sysv.S - Copyright (c) 2004 Renesas Technology
+   
+   M32R Foreign Function Interface 
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+   OTHER DEALINGS IN THE SOFTWARE.
+   ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM	
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+/* XXX these lose for some platforms, I'm sure. */
+#define CNAME(x) x
+#define ENTRY(x) .globl CNAME(x)! .type CNAME(x),%function! CNAME(x):
+#endif
+	
+.text
+
+	/* R0:   ffi_prep_args */
+	/* R1:   &ecif */
+	/* R2:   cif->bytes */
+	/* R3:   fig->flags */
+	/* sp+0: ecif.rvalue */
+	/* sp+4: fn */
+
+	/* This assumes we are using gas. */
+ENTRY(ffi_call_SYSV)
+	/* Save registers */
+	push	fp
+	push	lr
+	push	r3
+	push	r2
+	push	r1
+	push	r0
+	mv	fp, sp
+
+	/* Make room for all of the new args. */
+	sub	sp, r2
+
+	/* Place all of the ffi_prep_args in position */
+	mv	lr, r0	
+	mv	r0, sp
+	/* R1 already set */
+
+	/* And call */
+	jl	lr
+
+	/* move first 4 parameters in registers */
+	ld	r0, @(0,sp)
+	ld	r1, @(4,sp)
+	ld	r2, @(8,sp)
+        ld	r3, @(12,sp)
+
+	/* and adjust stack */
+	ld	lr, @(8,fp)
+        cmpi	lr, #16
+	bc	adjust_stack
+	ldi	lr, #16
+adjust_stack:
+        add	sp, lr
+
+	/* call function */
+	ld	lr, @(28,fp)
+	jl	lr	
+
+	/* Remove the space we pushed for the args */
+	mv	sp, fp	
+
+	/* Load R2 with the pointer to storage for the return value */
+	ld	r2, @(24,sp)
+
+	/* Load R3 with the return type code */
+	ld	r3, @(12,sp)
+
+	/* If the return value pointer is NULL, assume no return value. */
+	beqz	r2, epilogue
+
+/* return INT */
+	ldi	r4, #FFI_TYPE_INT
+	bne	r3, r4, return_double
+	st	r0, @r2	
+	bra	epilogue
+
+return_double:
+/* return DOUBLE or LONGDOUBLE */
+	ldi	r4, #FFI_TYPE_DOUBLE
+	bne	r3, r4, epilogue
+	st	r0, @r2	
+	st	r1, @(4,r2)
+
+epilogue:
+	pop	r0
+	pop	r1
+	pop	r2
+	pop	r3
+	pop	lr
+	pop	fp
+        jmp lr
+
+.ffi_call_SYSV_end:
+        .size    CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+
diff -rNu gcc-3.4.3/libffi/src/types.c gcc/libffi/src/types.c
--- gcc-3.4.3/libffi/src/types.c	2004-03-12 10:35:31.000000000 +0900
+++ gcc/libffi/src/types.c	2004-10-22 10:22:24.000000000 +0900
@@ -53,7 +53,7 @@
 
 #endif
 
-#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K
+#if defined X86 || defined X86_WIN32 || defined ARM || defined M68K || defined M32R
 
 FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
 FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
@@ -76,7 +76,7 @@
 FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
 FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
 
-#elif defined ARM || defined SH || defined POWERPC_AIX || defined POWERPC_DARWIN
+#elif defined ARM || defined SH || defined M32R || defined POWERPC_AIX || defined POWERPC_DARWIN
 
 FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
 FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
diff -rNu gcc-3.4.3/libjava/java/lang/ieeefp.h gcc/libjava/java/lang/ieeefp.h
--- gcc-3.4.3/libjava/java/lang/ieeefp.h	2003-04-17 03:32:06.000000000 +0900
+++ gcc/libjava/java/lang/ieeefp.h	2004-10-22 10:22:24.000000000 +0900
@@ -60,6 +60,14 @@
 #endif
 #endif
 
+#ifdef __m32r__
+#ifdef __LITTLE_ENDIAN__
+#define __IEEE_LITTLE_ENDIAN
+#else
+#define __IEEE_BIG_ENDIAN
+#endif
+#endif
+
 #ifdef _AM29K
 #define __IEEE_BIG_ENDIAN
 #endif
diff -rNu gcc-3.4.3/libjava/libltdl/config.guess gcc/libjava/libltdl/config.guess
--- gcc-3.4.3/libjava/libltdl/config.guess	2004-02-22 23:43:12.000000000 +0900
+++ gcc/libjava/libltdl/config.guess	2004-10-22 10:22:24.000000000 +0900
@@ -928,6 +928,9 @@
     sh*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
