diff -uraN gcc-4.2.4.orig/gcc/config/i386/gnu.h gcc-4.2.4/gcc/config/i386/gnu.h
--- gcc-4.2.4.orig/gcc/config/i386/gnu.h	2005-11-21 22:09:59.000000000 -0500
+++ gcc-4.2.4/gcc/config/i386/gnu.h	2008-08-29 06:03:46.000000000 -0400
@@ -36,3 +36,5 @@
 
 /* FIXME: Is a Hurd-specific fallback mechanism necessary?  */
 #undef MD_UNWIND_SUPPORT
+
+#undef TARGET_C99_FUNCTIONS /* config.gcc includes i386/linux.h.  */
diff -uraN gcc-4.2.4.orig/gcc/config/i386/kopensolaris-gnu.h gcc-4.2.4/gcc/config/i386/kopensolaris-gnu.h
--- gcc-4.2.4.orig/gcc/config/i386/kopensolaris-gnu.h	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.2.4/gcc/config/i386/kopensolaris-gnu.h	2008-08-29 06:11:03.000000000 -0400
@@ -0,0 +1,22 @@
+/* Definitions for Intel 386 running kOpenSolaris-based GNU systems with ELF format
+   Copyright (C) 2008
+   Free Software Foundation, Inc.
+   Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#define MD_UNWIND_SUPPORT "config/i386/sol2-unwind.h"
diff -uraN gcc-4.2.4.orig/gcc/config/i386/sol2-unwind.h gcc-4.2.4/gcc/config/i386/sol2-unwind.h
--- gcc-4.2.4.orig/gcc/config/i386/sol2-unwind.h	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.2.4/gcc/config/i386/sol2-unwind.h	2008-08-29 06:09:37.000000000 -0400
@@ -0,0 +1,155 @@
+/* DWARF2 EH unwinding support for AMD x86-64 and x86.
+   Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+
+Based on i386/linux-unwind.h.
+Modified for OpenSolaris by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file with other programs, and to distribute
+those programs without any restriction coming from the use of this
+file.  (The General Public License restrictions do apply in other
+respects; for example, they cover modification of the file, and
+distribution when not linked into another program.)
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+/* Do code reading to identify a signal frame, and set the frame
+   state data appropriately.  See unwind-dw2.c for the structs.
+   Don't use this at all if inhibit_libc is used.  */
+
+#ifndef inhibit_libc
+
+#ifdef __x86_64__
+
+#include <ucontext.h>
+#include <sys/regset.h>
+
+#define MD_FALLBACK_FRAME_STATE_FOR x86_64_fallback_frame_state
+
+static _Unwind_Reason_Code
+x86_64_fallback_frame_state (struct _Unwind_Context *context,
+			     _Unwind_FrameState *fs)
+{
+  long new_cfa;
+  ucontext_t *ctx;
+  greg_t *regs;
+
+  /* Solaris inserts an address of -1 into the base of the signal stack.  */
+  if (*((void **)context->cfa - 1) != (void *)-1)
+    return _URC_END_OF_STACK;
+
+  /* The 3rd argument of __sighandler is the previous context.  */
+  ctx = *((void **)context->cfa + 2);
+  regs = ctx->uc_mcontext.gregs;
+
+  new_cfa = regs[REG_RSP];
+  fs->cfa_how = CFA_REG_OFFSET;
+  /* Register 7 is rsp  */
+  fs->cfa_reg = 7;
+  fs->cfa_offset = new_cfa - (long) context->cfa;
+
+  /* The SVR4 register numbering macros aren't usable in libgcc.  */
+  fs->regs.reg[0].how = REG_SAVED_OFFSET;
+  fs->regs.reg[0].loc.offset = (long)&regs[REG_RAX] - new_cfa;
+  fs->regs.reg[1].how = REG_SAVED_OFFSET;
+  fs->regs.reg[1].loc.offset = (long)&regs[REG_RDX] - new_cfa;
+  fs->regs.reg[2].how = REG_SAVED_OFFSET;
+  fs->regs.reg[2].loc.offset = (long)&regs[REG_RCX] - new_cfa;
+  fs->regs.reg[3].how = REG_SAVED_OFFSET;
+  fs->regs.reg[3].loc.offset = (long)&regs[REG_RBX] - new_cfa;
+  fs->regs.reg[4].how = REG_SAVED_OFFSET;
+  fs->regs.reg[4].loc.offset = (long)&regs[REG_RSI] - new_cfa;
+  fs->regs.reg[5].how = REG_SAVED_OFFSET;
+  fs->regs.reg[5].loc.offset = (long)&regs[REG_RDI] - new_cfa;
+  fs->regs.reg[6].how = REG_SAVED_OFFSET;
+  fs->regs.reg[6].loc.offset = (long)&regs[REG_RBP] - new_cfa;
+  fs->regs.reg[8].how = REG_SAVED_OFFSET;
+  fs->regs.reg[8].loc.offset = (long)&regs[REG_R8] - new_cfa;
+  fs->regs.reg[9].how = REG_SAVED_OFFSET;
+  fs->regs.reg[9].loc.offset = (long)&regs[REG_R9] - new_cfa;
+  fs->regs.reg[10].how = REG_SAVED_OFFSET;
+  fs->regs.reg[10].loc.offset = (long)&regs[REG_R10] - new_cfa;
+  fs->regs.reg[11].how = REG_SAVED_OFFSET;
+  fs->regs.reg[11].loc.offset = (long)&regs[REG_R11] - new_cfa;
+  fs->regs.reg[12].how = REG_SAVED_OFFSET;
+  fs->regs.reg[12].loc.offset = (long)&regs[REG_R12] - new_cfa;
+  fs->regs.reg[13].how = REG_SAVED_OFFSET;
+  fs->regs.reg[13].loc.offset = (long)&regs[REG_R13] - new_cfa;
+  fs->regs.reg[14].how = REG_SAVED_OFFSET;
+  fs->regs.reg[14].loc.offset = (long)&regs[REG_R14] - new_cfa;
+  fs->regs.reg[15].how = REG_SAVED_OFFSET;
+  fs->regs.reg[15].loc.offset = (long)&regs[REG_R15] - new_cfa;
+  fs->regs.reg[16].how = REG_SAVED_OFFSET;
+  fs->regs.reg[16].loc.offset = (long)&regs[REG_RIP] - new_cfa;
+  fs->retaddr_column = 16;
+  fs->signal_frame = 1;
+  return _URC_NO_REASON;
+}
+
+#else /* ifdef __x86_64__  */
+
+#include <ucontext.h>
+#include <sys/regset.h>
+
+#define MD_FALLBACK_FRAME_STATE_FOR x86_fallback_frame_state
+
+static _Unwind_Reason_Code
+x86_fallback_frame_state (struct _Unwind_Context *context,
+			  _Unwind_FrameState *fs)
+{
+  long new_cfa;
+  ucontext_t *ctx;
+  greg_t *regs;
+
+  /* Solaris inserts an address of -1 into the base of the signal stack.  */
+  if (*((void **)context->cfa - 1) != (void *)-1)
+    return _URC_END_OF_STACK;
+
+  /* The 3rd argument of __sighandler is the previous context.  */
+  ctx = *((void **)context->cfa + 2);
+  regs = ctx->uc_mcontext.gregs;
+
+  new_cfa = regs[UESP];
+  fs->cfa_how = CFA_REG_OFFSET;
+  fs->cfa_reg = 4;
+  fs->cfa_offset = new_cfa - (long) context->cfa;
+
+  /* The SVR4 register numbering macros aren't usable in libgcc.  */
+  fs->regs.reg[0].how = REG_SAVED_OFFSET;
+  fs->regs.reg[0].loc.offset = (long)&regs[EAX] - new_cfa;
+  fs->regs.reg[3].how = REG_SAVED_OFFSET;
+  fs->regs.reg[3].loc.offset = (long)&regs[EBX] - new_cfa;
+  fs->regs.reg[1].how = REG_SAVED_OFFSET;
+  fs->regs.reg[1].loc.offset = (long)&regs[ECX] - new_cfa;
+  fs->regs.reg[2].how = REG_SAVED_OFFSET;
+  fs->regs.reg[2].loc.offset = (long)&regs[EDX] - new_cfa;
+  fs->regs.reg[6].how = REG_SAVED_OFFSET;
+  fs->regs.reg[6].loc.offset = (long)&regs[ESI] - new_cfa;
+  fs->regs.reg[7].how = REG_SAVED_OFFSET;
+  fs->regs.reg[7].loc.offset = (long)&regs[EDI] - new_cfa;
+  fs->regs.reg[5].how = REG_SAVED_OFFSET;
+  fs->regs.reg[5].loc.offset = (long)&regs[EBP] - new_cfa;
+  fs->regs.reg[8].how = REG_SAVED_OFFSET;
+  fs->regs.reg[8].loc.offset = (long)&regs[EIP] - new_cfa;
+  fs->retaddr_column = 8;
+  fs->signal_frame = 1;
+  return _URC_NO_REASON;
+}
+#endif /* ifdef __x86_64__  */
+#endif /* ifdef inhibit_libc  */
diff -uraN gcc-4.2.4.orig/gcc/config/kopensolaris-gnu.h gcc-4.2.4/gcc/config/kopensolaris-gnu.h
--- gcc-4.2.4.orig/gcc/config/kopensolaris-gnu.h	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.2.4/gcc/config/kopensolaris-gnu.h	2008-08-29 06:03:46.000000000 -0400
@@ -0,0 +1,39 @@
+/* Definitions for OpenSolaris-based GNU systems with ELF format
+   Copyright (C) 2004, 2006, 2007, 2008
+   Free Software Foundation, Inc.
+   Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008.
+   Based on kfreebsd-gnu.h contributed by Robert Millan.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#undef LINUX_TARGET_OS_CPP_BUILTINS
+#define LINUX_TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+	builtin_define ("__OpenSolaris_kernel__");	\
+	builtin_define_std ("unix");		\
+	builtin_assert ("system=unix");		\
+	builtin_assert ("system=posix");	\
+    }						\
+  while (0)
+
+#ifdef GLIBC_DYNAMIC_LINKER
+#undef GLIBC_DYNAMIC_LINKER
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+#endif
+
+#undef MD_UNWIND_SUPPORT
diff -uraN gcc-4.2.4.orig/gcc/config.gcc gcc-4.2.4/gcc/config.gcc
--- gcc-4.2.4.orig/gcc/config.gcc	2008-03-13 15:11:43.000000000 -0400
+++ gcc-4.2.4/gcc/config.gcc	2008-08-29 06:03:46.000000000 -0400
@@ -460,7 +460,7 @@
 *-*-linux*libc1* | *-*-linux*aout*)
   # Avoid the generic linux case.
   ;;
-*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-kopensolaris*-gnu )
   # Must come before *-*-gnu* (because of *-*-linux-gnu* systems).
   extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
   extra_options="${extra_options} linux.opt"
@@ -1093,22 +1093,24 @@
 	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/i386-coff.h"
 	use_fixproto=yes
 	;;
-i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu)
+i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-kopensolaris*-gnu )
 			# Intel 80386's running GNU/*
 			# with ELF format using glibc 2
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h"
 	case ${target} in
 	i[34567]86-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h i386/knetbsd-gnu.h" ;;
 	i[34567]86-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu.h" ;;
+	i[34567]86-*-kopensolaris*-gnu) tm_file="${tm_file} kopensolaris-gnu.h i386/kopensolaris-gnu.h" ;;
 	esac
 	tmake_file="${tmake_file} i386/t-crtstuff i386/t-crtfm t-dfprules"
 	;;
-x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
+x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu | x86_64-*-kopensolaris*-gnu )
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h \
 		 i386/x86-64.h i386/linux64.h"
 	case ${target} in
 	x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h" ;;
 	x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
+	x86_64-*-kopensolaris*-gnu) tm_file="${tm_file} kopensolaris-gnu.h" ;;
 	esac
 	tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtfm t-dfprules"
 	;;

