about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--iconv/gconv.c19
-rw-r--r--iconv/gconv_db.c71
-rw-r--r--iconv/gconv_dl.c11
-rw-r--r--iconv/skeleton.c13
-rw-r--r--libio/iofwide.c39
-rw-r--r--wcsmbs/btowc.c22
-rw-r--r--wcsmbs/mbrtowc.c13
-rw-r--r--wcsmbs/mbsnrtowcs.c15
-rw-r--r--wcsmbs/mbsrtowcs_l.c18
-rw-r--r--wcsmbs/wcrtomb.c15
-rw-r--r--wcsmbs/wcsnrtombs.c22
-rw-r--r--wcsmbs/wcsrtombs.c22
-rw-r--r--wcsmbs/wctob.c9
14 files changed, 228 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index 3c186d7953..16b7122072 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2005-12-18  Ulrich Drepper  <drepper@redhat.com>
 
+	* iconv/gconv.c: Demangle pointers before use if necessary.
+	* iconv/gconv_cache.c: Likewise.
+	* iconv/skeleton.c: Likewise.
+	* libio/iofwide.c: Likewise.
+	* wcsmbs/btowc.c: Likewise.
+	* wcsmbs/mbrtowc.c: Likewise.
+	* wcsmbs/mbsnrtowcs.c: Likewise.
+	* wcsmbs/mbsrtowcs_l.c: Likewise.
+	* wcsmbs/wcrtomb.c: Likewise.
+	* wcsmbs/wcsnrtombs.c: Likewise.
+	* wcsmbs/wcsrtombs.c: Likewise.
+	* wcsmbs/wctob.c: Likewise.
+	* iconv_gconv_db.c: Likewise.  After init functions returns mangle
+	btowc pointer if necessary.
+	* iconv/gconv_dl.c: Mangle function pointers retrieved from dlsym.
+
 	* iconv/gconv_builtin.c (builtin_map): Change type of size
 	information fields to int8_t.
 
diff --git a/iconv/gconv.c b/iconv/gconv.c
index f3f49b7db3..cd43d3d6fb 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -1,6 +1,6 @@
 /* Convert characters in input buffer using conversion descriptor to
    output buffer.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997-2001, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -20,10 +20,13 @@
    02111-1307 USA.  */
 
 #include <assert.h>
-#include <gconv_int.h>
-#include <sys/param.h>
 #include <dlfcn.h>
 #include <stddef.h>
+#include <sys/param.h>
+
+#include <gconv_int.h>
+#include <sysdep.h>
+
 
 int
 internal_function
@@ -45,9 +48,15 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
   cd->__data[last_step].__outbuf = outbuf != NULL ? *outbuf : NULL;
   cd->__data[last_step].__outbufend = outbufend;
 
+  __gconv_fct fct = cd->__steps->__fct;
+#ifdef PTR_DEMANGLE
+  if (cd->__steps->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
   if (inbuf == NULL || *inbuf == NULL)
     /* We just flush.  */
-    result = DL_CALL_FCT (cd->__steps->__fct,
+    result = DL_CALL_FCT (fct,
 			  (cd->__steps, cd->__data, NULL, NULL, NULL,
 			   irreversible,
 			   cd->__data[last_step].__outbuf == NULL ? 2 : 1, 0));
@@ -60,7 +69,7 @@ __gconv (__gconv_t cd, const unsigned char **inbuf,
       do
 	{
 	  last_start = *inbuf;
-	  result = DL_CALL_FCT (cd->__steps->__fct,
+	  result = DL_CALL_FCT (fct,
 				(cd->__steps, cd->__data, inbuf, inbufend,
 				 NULL, irreversible, 0, 0));
 	}
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index 8dc6b14d25..3431ce0812 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -1,5 +1,5 @@
 /* Provide access to the collection of available transformation modules.
-   Copyright (C) 1997-2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1997-2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -18,6 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <limits.h>
 #include <search.h>
 #include <stdlib.h>
@@ -28,6 +29,7 @@
 
 #include <dlfcn.h>
 #include <gconv_int.h>
+#include <sysdep.h>
 
 
 /* Simple data structure for alias mapping.  We have two names, `from'
@@ -180,7 +182,15 @@ free_derivation (void *p)
   for (cnt = 0; cnt < deriv->nsteps; ++cnt)
     if (deriv->steps[cnt].__counter > 0
 	&& deriv->steps[cnt].__end_fct != NULL)
-      DL_CALL_FCT (deriv->steps[cnt].__end_fct, (&deriv->steps[cnt]));
+      {
+	assert (deriv->steps[cnt].__shlib_handle != NULL);
+
+	__gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
+#ifdef PTR_DEMANGLE
+	PTR_DEMANGLE (end_fct);
+#endif
+	DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
+      }
 
   /* Free the name strings.  */
   free ((char *) deriv->steps[0].__from_name);
@@ -196,22 +206,30 @@ void
 internal_function
 __gconv_release_step (struct __gconv_step *step)
 {
-  if (--step->__counter == 0)
+  /* Skip builtin modules; they are not reference counted.  */
+  if (step->__shlib_handle != NULL && --step->__counter == 0)
     {
       /* Call the destructor.  */
       if (step->__end_fct != NULL)
-	DL_CALL_FCT (step->__end_fct, (step));
-
-#ifndef STATIC_GCONV
-      /* Skip builtin modules; they are not reference counted.  */
-      if (step->__shlib_handle != NULL)
 	{
-	  /* Release the loaded module.  */
-	  __gconv_release_shlib (step->__shlib_handle);
-	  step->__shlib_handle = NULL;
+	  assert (step->__shlib_handle != NULL);
+
+	  __gconv_end_fct end_fct = step->__end_fct;
+#ifdef PTR_DEMANGLE
+	  PTR_DEMANGLE (end_fct);
+#endif
+	  DL_CALL_FCT (end_fct, (step));
 	}
+
+#ifndef STATIC_GCONV
+      /* Release the loaded module.  */
+      __gconv_release_shlib (step->__shlib_handle);
+      step->__shlib_handle = NULL;
 #endif
     }
+  else
+    /* Builtin modules should not have end functions.  */
+    assert (step->__end_fct == NULL);
 }
 
 static int
@@ -272,10 +290,15 @@ gen_steps (struct derivation_step *best, const char *toset,
 	      result[step_cnt].__btowc_fct = NULL;
 
 	      /* Call the init function.  */
-	      if (result[step_cnt].__init_fct != NULL)
+	      __gconv_init_fct init_fct = result[step_cnt].__init_fct;
+	      if (init_fct != NULL)
 		{
-		  status = DL_CALL_FCT (result[step_cnt].__init_fct,
-					(&result[step_cnt]));
+		  assert (result[step_cnt].__shlib_handle != NULL);
+
+# ifdef PTR_DEMANGLE
+		  PTR_DEMANGLE (init_fct);
+# endif
+		  status = DL_CALL_FCT (init_fct, (&result[step_cnt]));
 
 		  if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
 		    {
@@ -285,6 +308,11 @@ gen_steps (struct derivation_step *best, const char *toset,
 		      result[step_cnt].__end_fct = NULL;
 		      break;
 		    }
+
+# ifdef PTR_MANGLE
+		  if (result[step_cnt].__btowc_fct != NULL)
+		    PTR_MANGLE (result[step_cnt].__btowc_fct);
+# endif
 		}
 	    }
 	  else
@@ -362,8 +390,19 @@ increment_counter (struct __gconv_step *steps, size_t nsteps)
 	    }
 
 	  /* Call the init function.  */
-	  if (step->__init_fct != NULL)
-	    DL_CALL_FCT (step->__init_fct, (step));
+	  __gconv_init_fct init_fct = step->__init_fct;
+	  if (init_fct != NULL)
+	    {
+#ifdef PTR_DEMANGLE
+	      PTR_DEMANGLE (init_fct);
+#endif
+	      DL_CALL_FCT (init_fct, (step));
+
+#ifdef PTR_MANGLE
+	      if (step->__btowc_fct != NULL)
+		PTR_MANGLE (step->__btowc_fct);
+#endif
+	    }
 	}
     }
   return result;
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 9504017210..8217b7e553 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -1,5 +1,5 @@
 /* Handle loading/unloading of shared object for transformation.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -29,6 +29,7 @@
 #include <sys/param.h>
 
 #include <gconv_int.h>
+#include <sysdep.h>
 
 
 #ifdef DEBUG
@@ -130,6 +131,14 @@ __gconv_find_shlib (const char *name)
 		  found->init_fct = __libc_dlsym (found->handle, "gconv_init");
 		  found->end_fct = __libc_dlsym (found->handle, "gconv_end");
 
+#ifdef PTR_MANGLE
+		  PTR_MANGLE (found->fct);
+		  if (found->init_fct != NULL)
+		    PTR_MANGLE (found->init_fct);
+		  if (found->end_fct !=  NULL)
+		    PTR_MANGLE (found->end_fct);
+#endif
+
 		  /* We have succeeded in loading the shared object.  */
 		  found->counter = 1;
 		}
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index c74935693f..baace6b3fb 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -144,6 +144,8 @@
 # include <dlfcn.h>
 #endif
 
+#include <sysdep.h>
+
 #ifndef DL_CALL_FCT
 # define DL_CALL_FCT(fct, args) fct args
 #endif
@@ -393,10 +395,17 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
 {
   struct __gconv_step *next_step = step + 1;
   struct __gconv_step_data *next_data = data + 1;
-  __gconv_fct fct;
+  __gconv_fct fct = NULL;
   int status;
 
-  fct = (data->__flags & __GCONV_IS_LAST) ? NULL : next_step->__fct;
+  if ((data->__flags & __GCONV_IS_LAST) == 0)
+    {
+      fct = next_step->__fct;
+#ifdef PTR_DEMANGLE
+      if (next_step->__shlib_handle != NULL)
+	PTR_DEMANGLE (fct);
+#endif
+    }
 
   /* If the function is called with no input this means we have to reset
      to the initial state.  The possibly partly converted input is
diff --git a/libio/iofwide.c b/libio/iofwide.c
index be3627ca99..a9936687dd 100644
--- a/libio/iofwide.c
+++ b/libio/iofwide.c
@@ -40,6 +40,7 @@
 # include <wcsmbs/wcsmbsload.h>
 # include <iconv/gconv_int.h>
 # include <shlib-compat.h>
+# include <sysdep.h>
 #endif
 
 
@@ -126,12 +127,11 @@ _IO_fwide (fp, mode)
 	 selected locale for LC_CTYPE.  */
 #ifdef _LIBC
       {
-	struct gconv_fcts fcts;
-
 	/* Clear the state.  We start all over again.  */
 	memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
 	memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t));
 
+	struct gconv_fcts fcts;
 	__wcsmbs_clone_conv (&fcts);
 	assert (fcts.towc_nsteps == 1);
 	assert (fcts.tomb_nsteps == 1);
@@ -159,7 +159,8 @@ _IO_fwide (fp, mode)
 	cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
 
 	/* And now the transliteration.  */
-	cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
+	cc->__cd_out.__cd.__data[0].__trans
+	  = (struct __gconv_trans_data  *) &__libio_translit;
       }
 #else
 # ifdef _GLIBCPP_USE_WCHAR_T
@@ -232,7 +233,13 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_out.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_out.__cd.__data, &from_start_copy,
 			 (const unsigned char *) from_end, NULL,
 			 &dummy, 0, 0));
@@ -298,7 +305,13 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_out.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_out.__cd.__data, NULL, NULL,
 			 NULL, &dummy, 1, 0));
 
@@ -361,7 +374,13 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_in.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_in.__cd.__data, &from_start_copy,
 			 (const unsigned char *) from_end, NULL,
 			 &dummy, 0, 0));
@@ -459,7 +478,13 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) &to_buf[max];
   codecvt->__cd_in.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  __gconv_fct fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_in.__cd.__data, &cp,
 			 (const unsigned char *) from_end, NULL,
 			 &dummy, 0, 0));
diff --git a/wcsmbs/btowc.c b/wcsmbs/btowc.c
index 6add7ed8bb..6517d4f635 100644
--- a/wcsmbs/btowc.c
+++ b/wcsmbs/btowc.c
@@ -26,6 +26,8 @@
 #include <wcsmbsload.h>
 #include <limits.h>
 
+#include <sysdep.h>
+
 
 wint_t
 __btowc (c)
@@ -45,13 +47,17 @@ __btowc (c)
 
   /* Get the conversion functions.  */
   fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+  __gconv_btowc_fct btowc_fct = fcts->towc->__btowc_fct;
 
   if (__builtin_expect (fcts->towc_nsteps == 1, 1)
-      && __builtin_expect (fcts->towc->__btowc_fct != NULL, 1))
+      && __builtin_expect (btowc_fct != NULL, 1))
     {
       /* Use the shortcut function.  */
-      return DL_CALL_FCT (fcts->towc->__btowc_fct,
-			  (fcts->towc, (unsigned char) c));
+#ifdef PTR_DEMANGLE
+      if (fcts->towc->__shlib_handle != NULL)
+	PTR_DEMANGLE (btowc_fct);
+#endif
+      return DL_CALL_FCT (btowc_fct, (fcts->towc, (unsigned char) c));
     }
   else
     {
@@ -78,9 +84,13 @@ __btowc (c)
       /* Create the input string.  */
       inbuf[0] = c;
 
-      status = DL_CALL_FCT (fcts->towc->__fct,
-			    (fcts->towc, &data, &inptr, inptr + 1,
-			     NULL, &dummy, 0, 1));
+      __gconv_fct fct = fcts->towc->__fct;
+#ifdef PTR_DEMANGLE
+      if (fcts->towc->__shlib_handle != NULL)
+	PTR_DEMANGLE (fct);
+#endif
+      status = DL_CALL_FCT (fct, (fcts->towc, &data, &inptr, inptr + 1,
+				  NULL, &dummy, 0, 1));
 
       if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
 	  && status != __GCONV_EMPTY_INPUT)
diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c
index eb2a312b7c..b534571736 100644
--- a/wcsmbs/mbrtowc.c
+++ b/wcsmbs/mbrtowc.c
@@ -18,13 +18,14 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <gconv.h>
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -73,9 +74,13 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
   endbuf = inbuf + n;
   if (__builtin_expect (endbuf < inbuf, 0))
     endbuf = (const unsigned char *) ~(uintptr_t) 0;
-  status = DL_CALL_FCT (fcts->towc->__fct,
-			(fcts->towc, &data, &inbuf, endbuf,
-			 NULL, &dummy, 0, 1));
+  __gconv_fct fct = fcts->towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+  status = DL_CALL_FCT (fct, (fcts->towc, &data, &inbuf, endbuf,
+			      NULL, &dummy, 0, 1));
 
   /* There must not be any problems with the conversion but illegal input
      characters.  The output buffer must be large enough, otherwise the
diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c
index ef5ca06e2f..8d0b9d3609 100644
--- a/wcsmbs/mbsnrtowcs.c
+++ b/wcsmbs/mbsnrtowcs.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <gconv.h>
@@ -24,7 +25,7 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -69,6 +70,11 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
 
   /* Get the structure with the function pointers.  */
   towc = fcts->towc;
+  __gconv_fct fct = towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
 
   /* We have to handle DST == NULL special.  */
   if (dst == NULL)
@@ -82,9 +88,8 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
 	{
 	  data.__outbuf = (unsigned char *) buf;
 
-	  status = DL_CALL_FCT (towc->__fct,
-				(towc, &data, &inbuf, srcend, NULL,
-				 &dummy, 0, 1));
+	  status = DL_CALL_FCT (fct, (towc, &data, &inbuf, srcend, NULL,
+				      &dummy, 0, 1));
 
 	  result += (wchar_t *) data.__outbuf - buf;
 	}
@@ -103,7 +108,7 @@ __mbsnrtowcs (dst, src, nmc, len, ps)
       data.__outbuf = (unsigned char *) dst;
       data.__outbufend = data.__outbuf + len * sizeof (wchar_t);
 
-      status = DL_CALL_FCT (towc->__fct,
+      status = DL_CALL_FCT (fct,
 			    (towc, &data, (const unsigned char **) src, srcend,
 			     NULL, &dummy, 0, 1));
 
diff --git a/wcsmbs/mbsrtowcs_l.c b/wcsmbs/mbsrtowcs_l.c
index c44c8e5066..264c410c92 100644
--- a/wcsmbs/mbsrtowcs_l.c
+++ b/wcsmbs/mbsrtowcs_l.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <ctype.h>
 #include <string.h>
 #include "wcsmbsload.h"
@@ -28,7 +29,7 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -63,6 +64,11 @@ __mbsrtowcs_l (dst, src, len, ps, l)
 
   /* Get the structure with the function pointers.  */
   towc = fcts->towc;
+  __gconv_fct fct = towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
 
   /* We have to handle DST == NULL special.  */
   if (dst == NULL)
@@ -81,9 +87,8 @@ __mbsrtowcs_l (dst, src, len, ps, l)
 	{
 	  data.__outbuf = (unsigned char *) buf;
 
-	  status = DL_CALL_FCT (towc->__fct,
-				(towc, &data, &inbuf, srcend, NULL,
-				 &non_reversible, 0, 1));
+	  status = DL_CALL_FCT (fct, (towc, &data, &inbuf, srcend, NULL,
+				      &non_reversible, 0, 1));
 
 	  result += (wchar_t *) data.__outbuf - buf;
 	}
@@ -116,9 +121,8 @@ __mbsrtowcs_l (dst, src, len, ps, l)
 	     worst case we need one input byte for one output wchar_t.  */
 	  srcend = srcp + __strnlen ((const char *) srcp, len) + 1;
 
-	  status = DL_CALL_FCT (towc->__fct,
-				(towc, &data, &srcp, srcend, NULL,
-				 &non_reversible, 0, 1));
+	  status = DL_CALL_FCT (fct, (towc, &data, &srcp, srcend, NULL,
+				      &non_reversible, 0, 1));
 	  if ((status != __GCONV_EMPTY_INPUT
 	       && status != __GCONV_INCOMPLETE_INPUT)
 	      /* Not all input read.  */
diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c
index f7971e704b..aa51b6891b 100644
--- a/wcsmbs/wcrtomb.c
+++ b/wcsmbs/wcrtomb.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <gconv.h>
@@ -24,7 +25,7 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -65,15 +66,19 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
 
   /* Get the conversion functions.  */
   fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+  __gconv_fct fct = fcts->tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
 
   /* If WC is the NUL character we write into the output buffer the byte
      sequence necessary for PS to get into the initial state, followed
      by a NUL byte.  */
   if (wc == L'\0')
     {
-      status = DL_CALL_FCT (fcts->tomb->__fct,
-			    (fcts->tomb, &data, NULL, NULL,
-			     NULL, &dummy, 1, 1));
+      status = DL_CALL_FCT (fct, (fcts->tomb, &data, NULL, NULL,
+				  NULL, &dummy, 1, 1));
 
       if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
 	*data.__outbuf++ = '\0';
@@ -83,7 +88,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
       /* Do a normal conversion.  */
       const unsigned char *inbuf = (const unsigned char *) &wc;
 
-      status = DL_CALL_FCT (fcts->tomb->__fct,
+      status = DL_CALL_FCT (fct,
 			    (fcts->tomb, &data, &inbuf,
 			     inbuf + sizeof (wchar_t), NULL, &dummy, 0, 1));
     }
diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c
index 0252b7fa23..171fc3c227 100644
--- a/wcsmbs/wcsnrtombs.c
+++ b/wcsmbs/wcsnrtombs.c
@@ -17,13 +17,14 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <gconv.h>
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -67,6 +68,11 @@ __wcsnrtombs (dst, src, nwc, len, ps)
 
   /* Get the structure with the function pointers.  */
   tomb = fcts->tomb;
+  __gconv_fct fct = tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
 
   /* We have to handle DST == NULL special.  */
   if (dst == NULL)
@@ -82,10 +88,9 @@ __wcsnrtombs (dst, src, nwc, len, ps)
 	{
 	  data.__outbuf = buf;
 
-	  status = DL_CALL_FCT (tomb->__fct,
-				(tomb, &data, &inbuf,
-				 (const unsigned char *) srcend, NULL,
-				 &dummy, 0, 1));
+	  status = DL_CALL_FCT (fct, (tomb, &data, &inbuf,
+				      (const unsigned char *) srcend, NULL,
+				      &dummy, 0, 1));
 
 	  /* Count the number of bytes.  */
 	  result += data.__outbuf - buf;
@@ -107,10 +112,9 @@ __wcsnrtombs (dst, src, nwc, len, ps)
       data.__outbuf = (unsigned char *) dst;
       data.__outbufend = (unsigned char *) dst + len;
 
-      status = DL_CALL_FCT (tomb->__fct,
-			    (tomb, &data, (const unsigned char **) src,
-			     (const unsigned char *) srcend, NULL,
-			     &dummy, 0, 1));
+      status = DL_CALL_FCT (fct, (tomb, &data, (const unsigned char **) src,
+				  (const unsigned char *) srcend, NULL,
+				  &dummy, 0, 1));
 
       /* Count the number of bytes.  */
       result = data.__outbuf - (unsigned char *) dst;
diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c
index d41ca5366b..5973fd9303 100644
--- a/wcsmbs/wcsrtombs.c
+++ b/wcsmbs/wcsrtombs.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -24,7 +25,7 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
-#include <assert.h>
+#include <sysdep.h>
 
 #ifndef EILSEQ
 # define EILSEQ EINVAL
@@ -59,6 +60,11 @@ __wcsrtombs (dst, src, len, ps)
 
   /* Get the structure with the function pointers.  */
   tomb = fcts->tomb;
+  __gconv_fct fct = tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
 
   /* We have to handle DST == NULL special.  */
   if (dst == NULL)
@@ -79,10 +85,9 @@ __wcsrtombs (dst, src, len, ps)
 	{
 	  data.__outbuf = buf;
 
-	  status = DL_CALL_FCT (tomb->__fct,
-				(tomb, &data, &inbuf,
-				 (const unsigned char *) srcend, NULL,
-				 &dummy, 0, 1));
+	  status = DL_CALL_FCT (fct, (tomb, &data, &inbuf,
+				      (const unsigned char *) srcend, NULL,
+				      &dummy, 0, 1));
 
 	  /* Count the number of bytes.  */
 	  result += data.__outbuf - buf;
@@ -108,10 +113,9 @@ __wcsrtombs (dst, src, len, ps)
       data.__outbuf = (unsigned char *) dst;
       data.__outbufend = (unsigned char *) dst + len;
 
-      status = DL_CALL_FCT (tomb->__fct,
-			    (tomb, &data, (const unsigned char **) src,
-			     (const unsigned char *) srcend, NULL,
-			     &dummy, 0, 1));
+      status = DL_CALL_FCT (fct, (tomb, &data, (const unsigned char **) src,
+				  (const unsigned char *) srcend, NULL,
+				  &dummy, 0, 1));
 
       /* Count the number of bytes.  */
       result = data.__outbuf - (unsigned char *) dst;
diff --git a/wcsmbs/wctob.c b/wcsmbs/wctob.c
index 0f241577a4..cbaac53367 100644
--- a/wcsmbs/wctob.c
+++ b/wcsmbs/wctob.c
@@ -24,6 +24,8 @@
 #include <wchar.h>
 #include <wcsmbsload.h>
 
+#include <sysdep.h>
+
 
 int
 wctob (c)
@@ -64,7 +66,12 @@ wctob (c)
   inbuf[0] = c;
 
   const unsigned char *argptr = (const unsigned char *) inptr;
-  status = DL_CALL_FCT (fcts->tomb->__fct,
+  __gconv_fct fct = fcts->tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+  status = DL_CALL_FCT (fct,
 			(fcts->tomb, &data, &argptr,
 			 argptr + sizeof (inbuf[0]), NULL, &dummy, 0, 1));