Index: libgcc/unwind-dw2-fde-dip.c
===================================================================
--- libgcc/unwind-dw2-fde-dip.c	(revision 190863)
+++ libgcc/unwind-dw2-fde-dip.c	(working copy)
@@ -33,7 +33,7 @@
 
 #include "tconfig.h"
 #include "tsystem.h"
-#ifndef inhibit_libc
+#if !defined(inhibit_libc) && !defined(__OpenBSD__)
 #include <elf.h>		/* Get DT_CONFIG.  */
 #endif
 #include "coretypes.h"
@@ -65,6 +65,12 @@
 #endif
 
 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+    && defined(__OpenBSD__)
+# define ElfW(type) Elf_##type
+# define USE_PT_GNU_EH_FRAME
+#endif
+
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
     && defined(TARGET_DL_ITERATE_PHDR) \
     && defined(__sun__) && defined(__svr4__)
 # define USE_PT_GNU_EH_FRAME
Index: libgcc/config.host
===================================================================
--- libgcc/config.host	(revision 190863)
+++ libgcc/config.host	(working copy)
@@ -213,7 +213,7 @@
   esac
   ;;
 *-*-openbsd*)
-  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic"
+  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
   case ${target_thread_file} in
     posix)
       tmake_file="$tmake_file t-openbsd-thread"
@@ -1150,7 +1150,8 @@
   i[34567]86-*-gnu* | \
   i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]* | \
   i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw* | \
-  i[34567]86-*-freebsd* | x86_64-*-freebsd*)
+  i[34567]86-*-freebsd* | x86_64-*-freebsd* | \
+  i[34567]86-*-openbsd* | x86_64-*-openbsd*)
   	tmake_file="${tmake_file} t-softfp-tf"
 	if test "${host_address}" = 32; then
 		tmake_file="${tmake_file} i386/${host_address}/t-softfp"
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 190863)
+++ gcc/config.gcc	(working copy)
@@ -708,6 +708,11 @@
     *-*-openbsd2.*|*-*-openbsd3.[012])
       tm_defines="${tm_defines} HAS_LIBC_R=1" ;;
   esac
+  case ${target} in
+    *-*-openbsd4.[3-9]|*-*-openbsd[5-9]*)
+      default_use_cxa_atexit=yes
+      ;;
+  esac
   ;;
 *-*-rtems*)
   case ${enable_threads} in
Index: gcc/config/i386/openbsdelf.h
===================================================================
--- gcc/config/i386/openbsdelf.h	(revision 190863)
+++ gcc/config/i386/openbsdelf.h	(working copy)
@@ -111,3 +111,9 @@
 #define OBSD_HAS_CORRECT_SPECS
 
 #define HAVE_ENABLE_EXECUTE_STACK
+
+/* Put all *tf routines in libgcc.  */
+#undef LIBGCC2_HAS_TF_MODE
+#define LIBGCC2_HAS_TF_MODE 1
+#define LIBGCC2_TF_CEXT q
+#define TF_SIZE 113
Index: gcc/config/openbsd-stdint.h
===================================================================
--- gcc/config/openbsd-stdint.h	(revision 190863)
+++ gcc/config/openbsd-stdint.h	(working copy)
@@ -26,6 +26,9 @@
 #define UINT_FAST16_TYPE	"unsigned int"
 #define UINT_FAST32_TYPE	"unsigned int"
 #define UINT_FAST64_TYPE	"long long unsigned int"
+
+#define INTMAX_TYPE		"long long int"
+#define UINTMAX_TYPE		"long long unsigned int"
  
 #define INTPTR_TYPE		"long int"
 #define UINTPTR_TYPE		"long unsigned int"
