diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4
index 7006b6f..8fcde4b 100644
--- a/libitm/acinclude.m4
+++ b/libitm/acinclude.m4
@@ -69,6 +69,32 @@ extern void bar(void) __attribute__((alias("foo")));],
       [Define to 1 if the target supports __attribute__((alias(...))).])
   fi])
 
+dnl Check how size_t is mangled.
+AC_DEFUN([LIBITM_CHECK_SIZE_T_MANGLING], [
+  AC_CACHE_CHECK([how size_t is mangled],
+                 libitm_cv_size_t_mangling, [
+    AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned long x;],
+	           [libitm_cv_size_t_mangling=m], [
+      AC_TRY_COMPILE([], [extern __SIZE_TYPE__ x; extern unsigned int x;],
+	             [libitm_cv_size_t_mangling=j], [
+        AC_TRY_COMPILE([],
+		       [extern __SIZE_TYPE__ x; extern unsigned long long x;],
+	               [libitm_cv_size_t_mangling=y], [
+          AC_TRY_COMPILE([],
+			 [extern __SIZE_TYPE__ x; extern unsigned short x;],
+			 [libitm_cv_size_t_mangling=t],
+		         [libitm_cv_size_t_mangling=x])
+	])
+      ])
+    ])
+  ])
+  if test $libitm_cv_size_t_mangling = x; then
+    AC_MSG_ERROR([Unknown underlying type for size_t])
+  fi
+  AC_DEFINE_UNQUOTED(MANGLE_SIZE_T, [$libitm_cv_size_t_mangling],
+    [Define to the letter to which size_t is mangled.])
+])
+
 sinclude(../libtool.m4)
 dnl The lines below arrange for aclocal not to bring an installed
 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
diff --git a/libitm/alloc_cpp.cc b/libitm/alloc_cpp.cc
index 85aac25..7036c2a 100644
--- a/libitm/alloc_cpp.cc
+++ b/libitm/alloc_cpp.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU Transactional Memory Library (libitm).
@@ -26,21 +26,38 @@
 
 using namespace GTM;
 
+/* Mangling the names by hand requires that we know how size_t is handled.
+   We've gotten the letter from autoconf, now substitute it into the names.
+   Everything below uses X as a placeholder for clarity.  */
+
+#define S1(x,y)			x##y
+#define S(x,y)			S1(x,y)
+
+#define _ZnwX			S(_Znw,MANGLE_SIZE_T)
+#define _ZnaX			S(_Zna,MANGLE_SIZE_T)
+#define _ZnwXRKSt9nothrow_t	S(S(_Znw,MANGLE_SIZE_T),RKSt9nothrow_t)
+#define _ZnaXRKSt9nothrow_t	S(S(_Zna,MANGLE_SIZE_T),RKSt9nothrow_t)
+
+#define _ZGTtnwX		S(_ZGTtnw,MANGLE_SIZE_T)
+#define _ZGTtnaX		S(_ZGTtna,MANGLE_SIZE_T)
+#define _ZGTtnwXRKSt9nothrow_t	S(S(_ZGTtnw,MANGLE_SIZE_T),RKSt9nothrow_t)
+#define _ZGTtnaXRKSt9nothrow_t	S(S(_ZGTtna,MANGLE_SIZE_T),RKSt9nothrow_t)
+
 /* Everything from libstdc++ is weak, to avoid requiring that library
    to be linked into plain C applications using libitm.so.  */
 
 extern "C" {
 
-extern void *_Znwm (size_t) __attribute__((weak));
+extern void *_ZnwX (size_t) __attribute__((weak));
 extern void _ZdlPv (void *) __attribute__((weak));
-extern void *_Znam (size_t) __attribute__((weak));
+extern void *_ZnaX (size_t) __attribute__((weak));
 extern void _ZdaPv (void *) __attribute__((weak));
 
 typedef const struct nothrow_t { } *c_nothrow_p;
 
-extern void *_ZnwmRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
+extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
-extern void *_ZnamRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
+extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
 
 /* Wrap the delete nothrow symbols for usage with a single argument.
@@ -62,9 +79,9 @@ del_opvnt (void *ptr)
 
 /* Wrap: operator new (std::size_t sz)  */
 void *
-_ZGTtnwm (size_t sz)
+_ZGTtnwX (size_t sz)
 {
-  void *r = _Znwm (sz);
+  void *r = _ZnwX (sz);
   if (r)
     gtm_tx()->record_allocation (r, _ZdlPv);
   return r;
@@ -72,9 +89,9 @@ _ZGTtnwm (size_t sz)
 
 /* Wrap: operator new (std::size_t sz, const std::nothrow_t&)  */
 void *
-_ZGTtnwmRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
+_ZGTtnwXRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
 {
-  void *r = _ZnwmRKSt9nothrow_t (sz, nt);
+  void *r = _ZnwXRKSt9nothrow_t (sz, nt);
   if (r)
     gtm_tx()->record_allocation (r, del_opnt);
   return r;
@@ -82,9 +99,9 @@ _ZGTtnwmRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
 
 /* Wrap: operator new[] (std::size_t sz)  */
 void *
-_ZGTtnam (size_t sz)
+_ZGTtnaX (size_t sz)
 {
-  void *r = _Znam (sz);
+  void *r = _ZnaX (sz);
   if (r)
     gtm_tx()->record_allocation (r, _ZdaPv);
   return r;
@@ -92,9 +109,9 @@ _ZGTtnam (size_t sz)
 
 /* Wrap: operator new[] (std::size_t sz, const std::nothrow_t& nothrow)  */
 void *
-_ZGTtnamRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
+_ZGTtnaXRKSt9nothrow_t (size_t sz, c_nothrow_p nt)
 {
-  void *r = _ZnamRKSt9nothrow_t (sz, nt);
+  void *r = _ZnaXRKSt9nothrow_t (sz, nt);
   if (r)
     gtm_tx()->record_allocation (r, del_opvnt);
   return r;
diff --git a/libitm/config.h.in b/libitm/config.h.in
index 3249872..af13264 100644
--- a/libitm/config.h.in
+++ b/libitm/config.h.in
@@ -91,6 +91,9 @@
    */
 #undef LT_OBJDIR
 
+/* Define to the letter to which size_t is mangled. */
+#undef MANGLE_SIZE_T
+
 /* Name of package */
 #undef PACKAGE
 
diff --git a/libitm/configure b/libitm/configure
index a0ff402..fe7f15b 100755
--- a/libitm/configure
+++ b/libitm/configure
@@ -629,7 +629,6 @@ NMEDIT
 DSYMUTIL
 OBJDUMP
 LN_S
-NM
 ac_ct_DUMPBIN
 DUMPBIN
 LD
@@ -642,6 +641,7 @@ BUILD_INFO_FALSE
 BUILD_INFO_TRUE
 PERL
 RANLIB
+NM
 AR
 am__fastdepCCAS_FALSE
 am__fastdepCCAS_TRUE
@@ -5009,6 +5009,98 @@ else
 fi
 
 if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nm; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  ac_cv_prog_NM="$NM" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NM="${ac_tool_prefix}nm"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+NM=$ac_cv_prog_NM
+if test -n "$NM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5
+$as_echo "$NM" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NM"; then
+  ac_ct_NM=$NM
+  # Extract the first word of "nm", so it can be a program name with args.
+set dummy nm; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_NM"; then
+  ac_cv_prog_ac_ct_NM="$ac_ct_NM" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NM="nm"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NM=$ac_cv_prog_ac_ct_NM
+if test -n "$ac_ct_NM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NM" >&5
+$as_echo "$ac_ct_NM" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_NM" = x; then
+    NM=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NM=$ac_ct_NM
+  fi
+else
+  NM="$ac_cv_prog_NM"
+fi
+
+if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -11719,7 +11811,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11722 "configure"
+#line 11814 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11825,7 +11917,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11828 "configure"
+#line 11920 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19706,6 +19798,99 @@ $as_echo "#define LIBITM_GNU_SYMBOL_VERSIONING 1" >>confdefs.h
 
 fi
 
+# Determine the proper ABI type for size_t.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how size_t is mangled" >&5
+$as_echo_n "checking how size_t is mangled... " >&6; }
+if test "${libitm_cv_size_t_mangling+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+extern __SIZE_TYPE__ x; extern unsigned long x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libitm_cv_size_t_mangling=m
+else
+
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+extern __SIZE_TYPE__ x; extern unsigned int x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libitm_cv_size_t_mangling=j
+else
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+extern __SIZE_TYPE__ x; extern unsigned long long x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libitm_cv_size_t_mangling=y
+else
+
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+extern __SIZE_TYPE__ x; extern unsigned short x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libitm_cv_size_t_mangling=t
+else
+  libitm_cv_size_t_mangling=x
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libitm_cv_size_t_mangling" >&5
+$as_echo "$libitm_cv_size_t_mangling" >&6; }
+  if test $libitm_cv_size_t_mangling = x; then
+    as_fn_error "Unknown underlying type for size_t" "$LINENO" 5
+  fi
+
+cat >>confdefs.h <<_ACEOF
+#define MANGLE_SIZE_T $libitm_cv_size_t_mangling
+_ACEOF
+
+
+
 # Get target configury.
 . ${srcdir}/configure.tgt
 CFLAGS="$save_CFLAGS $XCFLAGS"
diff --git a/libitm/configure.ac b/libitm/configure.ac
index 1059aa0..c6892d6 100644
--- a/libitm/configure.ac
+++ b/libitm/configure.ac
@@ -116,6 +116,7 @@ save_CFLAGS="$CFLAGS"
 
 # Find other programs we need.
 AC_CHECK_TOOL(AR, ar)
+AC_CHECK_TOOL(NM, nm)
 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
 AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
 AC_PROG_MAKE_SET
@@ -209,6 +210,9 @@ if test $enable_symvers = gnu; then
 	    [Define to 1 if GNU symbol versioning is used for libitm.])
 fi
 
+# Determine the proper ABI type for size_t.
+LIBITM_CHECK_SIZE_T_MANGLING
+
 # Get target configury.
 . ${srcdir}/configure.tgt
 CFLAGS="$save_CFLAGS $XCFLAGS"
diff --git a/libitm/libitm.map b/libitm/libitm.map
index 95e878e..0d52a7c8 100644
--- a/libitm/libitm.map
+++ b/libitm/libitm.map
@@ -169,12 +169,12 @@ LIBITM_1.0 {
 	_ITM_free;
 	_ITM_dropReferences;
 
-	_ZGTtnwm;
-	_ZGTtnam;
+	_ZGTtnw?;
+	_ZGTtna?;
 	_ZGTtdlPv;
 	_ZGTtdaPv;
-	_ZGTtnwmRKSt9nothrow_t;
-	_ZGTtnamRKSt9nothrow_t;
+	_ZGTtnw?RKSt9nothrow_t;
+	_ZGTtna?RKSt9nothrow_t;
 	_ZGTtdlPvRKSt9nothrow_t;
 	_ZGTtdaPvRKSt9nothrow_t;
 
