about summary refs log tree commit diff
path: root/elf/dl-error.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-10 04:01:36 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-10 04:01:36 +0000
commit8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51 (patch)
treede81e2ebf2b5b32510d511caa07c2496e3d540ba /elf/dl-error.c
parentf3863621f617b040c66d635109203c29f35f7331 (diff)
downloadglibc-8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51.tar.gz
glibc-8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51.tar.xz
glibc-8e17ea58173d35e2e5dabfeb9fa5abf2609cfc51.zip
Update.
2000-06-09  Ulrich Drepper  <drepper@redhat.com>

	Rewrite error message handling.
	* elf/dl-deps.c (_dl_map_object_deps): Pass new parameter to
	_dl_catch_error.
	* elf/dl-error (struct catch): Add objname member.
	(_dl_signal_error): Take new parameter with object name.  When
	passing message on simply store object name and duplicate error
	message.
	(_dl_catch_error): Take new parameter.  Store object name in the
	place pointed to.
	* include/dlfcn.h: Adjust _dl_catch_error prototype.
	* sysdeps/generic/ldsodefs.h: Adjust _dl_signal_error prototype.
	* elf/dl-libc.c (dlerror_run): Pass new parameter to _dl_catch_error.
	* elf/dl-open.c (_dl_open): Likewise.
	* elf/rtld.c (dl_main): Likewise.
	* elf/dl-close.c: Mark error messages with N_().
	* elf/dl-deps.c: Likewise.
	* elf/dl-error.c: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-support.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-version.c: Likewise.
	* elf/dl-lookup.c: Add comments about problems with error message
	translations.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-version.c: Likewise.
Diffstat (limited to 'elf/dl-error.c')
-rw-r--r--elf/dl-error.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/elf/dl-error.c b/elf/dl-error.c
index fbf5fce04f..88ab8e9519 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <libintl.h>
 #include <setjmp.h>
 #include <stdlib.h>
 #include <string.h>
@@ -28,7 +29,8 @@
    _dl_signal_error.  */
 struct catch
   {
-    char *errstring;		/* Error detail filled in here.  */
+    const char *objname;	/* Object/File name.  */
+    const char *errstring;	/* Error detail filled in here.  */
     jmp_buf env;		/* longjmp here on error.  */
   };
 
@@ -55,34 +57,21 @@ static receiver_fct receiver;
 
 void
 internal_function
-_dl_signal_error (int errcode,
-		  const char *objname,
-		  const char *errstring)
+_dl_signal_error (int errcode, const char *objname, const char *errstring)
 {
   struct catch *lcatch;
 
   if (! errstring)
-    errstring = "DYNAMIC LINKER BUG!!!";
+    errstring = N_("DYNAMIC LINKER BUG!!!");
 
   lcatch = tsd_getspecific ();
   if (lcatch != NULL)
     {
       /* We are inside _dl_catch_error.  Return to it.  We have to
 	 duplicate the error string since it might be allocated on the
-	 stack.  */
-      size_t objname_len = objname ? strlen (objname) + 2 : 0;
-      size_t errstring_len = strlen (errstring) + 1;
-      lcatch->errstring = malloc (objname_len + errstring_len);
-      if (lcatch->errstring != NULL)
-	{
-	  char *cp = lcatch->errstring;
-	  if (objname_len > 0)
-	    {
-	      cp = __mempcpy (cp, objname, objname_len - 2);
-	      cp = __mempcpy (cp, ": ", 2);
-	    }
-	  memcpy (cp, errstring, errstring_len);
-	}
+	 stack.  The object name is always a string constant.  */
+      lcatch->objname = objname;
+      lcatch->errstring = strdup (errstring);
       longjmp (lcatch->env, errcode ?: -1);
     }
   else
@@ -120,9 +109,8 @@ _dl_signal_cerror (int errcode,
 
 int
 internal_function
-_dl_catch_error (char **errstring,
-		 void (*operate) (void *),
-		 void *args)
+_dl_catch_error (const char **objname, const char **errstring,
+		 void (*operate) (void *), void *args)
 {
   int errcode;
   struct catch *volatile old;
@@ -141,12 +129,14 @@ _dl_catch_error (char **errstring,
       tsd_setspecific (&c);
       (*operate) (args);
       tsd_setspecific (old);
+      *objname = NULL;
       *errstring = NULL;
       return 0;
     }
 
   /* We get here only if we longjmp'd out of OPERATE.  */
   tsd_setspecific (old);
+  *objname = c.objname;
   *errstring = c.errstring;
   return errcode == -1 ? 0 : errcode;
 }