summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-close.c15
-rw-r--r--elf/dl-deps.c24
-rw-r--r--elf/dl-error.c11
-rw-r--r--elf/dl-fini.c5
-rw-r--r--elf/dl-init.c10
-rw-r--r--elf/dl-load.c67
-rw-r--r--elf/dl-lookup.c61
-rw-r--r--elf/dl-minimal.c24
-rw-r--r--elf/dl-open.c36
-rw-r--r--elf/dl-profile.c27
-rw-r--r--elf/dl-reloc.c18
-rw-r--r--elf/dl-version.c7
-rw-r--r--elf/do-lookup.h5
-rw-r--r--elf/rtld.c113
14 files changed, 163 insertions, 260 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 723a9702fd..7dce7d0f48 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -27,8 +27,6 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 
-#include <stdio-common/_itoa.h>
-
 
 /* Type of the constructor functions.  */
 typedef void (*fini_t) (void);
@@ -76,11 +74,8 @@ _dl_close (void *_map)
 
 	  buf[sizeof buf - 1] = '\0';
 
-	  _dl_debug_message (1, "\nclosing file=", map->l_name,
-			     "; opencount == ",
-			     _itoa_word (map->l_opencount,
-					 buf + sizeof buf - 1, 10, 0),
-			     "\n", NULL);
+	  _dl_debug_printf ("\nclosing file=%s; opencount == %u\n",
+			    map->l_name, map->l_opencount);
 	}
 
       /* One decrement the object itself, not the dependencies.  */
@@ -134,10 +129,8 @@ _dl_close (void *_map)
 	  && imap->l_init_called)
 	{
 	  /* When debugging print a message first.  */
-	  if (//__builtin_expect (_dl_debug_impcalls, 0))
-	      __builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
-	    _dl_debug_message (1, "\ncalling fini: ", imap->l_name,
-			       "\n\n", NULL);
+	  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
+	    _dl_debug_printf ("\ncalling fini: %s\n\n", imap->l_name);
 
 	  /* Call its termination function.  */
 	  if (imap->l_info[DT_FINI_ARRAY] != NULL)
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 7d0c1808e8..c886ca8b18 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -121,9 +121,9 @@ empty dynamics string token substitution"));				      \
 	      {								      \
 		/* This is for DT_AUXILIARY.  */			      \
 		if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))     \
-		  _dl_debug_message (1, "cannot load auxiliary `", __str,     \
-				     "' because of empty dynamic string"      \
-				     " token substitution\n", NULL);	      \
+		  _dl_debug_printf ("cannot load auxiliary `%s' because of"   \
+				    "empty dynamic string token "	      \
+				    "substitution\n", __str);		      \
 		continue;						      \
 	      }								      \
 	  }								      \
@@ -294,11 +294,10 @@ _dl_map_object_deps (struct link_map *map,
 		  {
 		    /* Say that we are about to load an auxiliary library.  */
 		    if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
-		      _dl_debug_message (1, "load auxiliary object=",
-					 name, " requested by file=",
-					 l->l_name[0]
-					 ? l->l_name : _dl_argv[0],
-					 "\n", NULL);
+		      _dl_debug_printf ("load auxiliary object=%s"
+					" requested by file=%s\n", name,
+					l->l_name[0]
+					? l->l_name : _dl_argv[0]);
 
 		    /* We must be prepared that the addressed shared
 		       object is not available.  */
@@ -317,11 +316,10 @@ _dl_map_object_deps (struct link_map *map,
 		  {
 		    /* Say that we are about to load an auxiliary library.  */
 		    if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
-		      _dl_debug_message (1, "load filtered object=", name,
-					 " requested by file=",
-					 l->l_name[0]
-					 ? l->l_name : _dl_argv[0],
-					 "\n", NULL);
+		      _dl_debug_printf ("load filtered object=%s"
+					" requested by file=%s\n", name,
+					l->l_name[0]
+					? l->l_name : _dl_argv[0]);
 
 		    /* For filter objects the dependency must be available.  */
 		    if (_dl_catch_error (&objname, &errstring, openaux, &args))
diff --git a/elf/dl-error.c b/elf/dl-error.c
index 83d984f045..1cd4cc3852 100644
--- a/elf/dl-error.c
+++ b/elf/dl-error.c
@@ -1,5 +1,5 @@
 /* Error handling for runtime dynamic linker.
-   Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -97,13 +97,14 @@ _dl_signal_error (int errcode, const char *objname, const char *errstring)
     {
       /* Lossage while resolving the program's own symbols is always fatal.  */
       char buffer[1024];
-      _dl_sysdep_fatal (_dl_argv[0] ?: "<program name unknown>",
-			": error while loading shared libraries: ",
+      _dl_fatal_printf ("\
+%s: error while loading shared libraries: %s%s%s%s%s\n",
+			_dl_argv[0] ?: "<program name unknown>",
 			objname ?: "", objname && *objname ? ": " : "",
 			errstring, errcode ? ": " : "",
 			(errcode
 			 ? __strerror_r (errcode, buffer, sizeof buffer)
-			 : ""), "\n", NULL);
+			 : ""));
     }
 }
 
@@ -143,7 +144,7 @@ _dl_catch_error (const char **objname, const char **errstring,
 
   old = tsd_getspecific ();
   errcode = setjmp (c.env);
-  if (errcode == 0)
+  if (__builtin_expect (errcode, 0) == 0)
     {
       tsd_setspecific (&c);
       (*operate) (args);
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
index 37b1f5238f..c7cc8d9555 100644
--- a/elf/dl-fini.c
+++ b/elf/dl-fini.c
@@ -147,9 +147,8 @@ _dl_fini (void)
 
 	  /* When debugging print a message first.  */
 	  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
-	    _dl_debug_message (1, "\ncalling fini: ",
-			       l->l_name[0] ? l->l_name : _dl_argv[0],
-			       "\n\n", NULL);
+	    _dl_debug_printf ("\ncalling fini: %s\n\n",
+			      l->l_name[0] ? l->l_name : _dl_argv[0]);
 
 	  /* First see whether an array is given.  */
 	  if (l->l_info[DT_FINI_ARRAY] != NULL)
diff --git a/elf/dl-init.c b/elf/dl-init.c
index 502518728e..fbb7b32e3e 100644
--- a/elf/dl-init.c
+++ b/elf/dl-init.c
@@ -54,8 +54,8 @@ call_init (struct link_map *l, int argc, char **argv, char **env)
 
   /* Print a debug message if wanted.  */
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
-    _dl_debug_message (1, "\ncalling init: ",
-		       l->l_name[0] ? l->l_name : _dl_argv[0], "\n\n", NULL);
+    _dl_debug_printf ("\ncalling init: %s\n\n",
+		      l->l_name[0] ? l->l_name : _dl_argv[0]);
 
   /* Now run the local constructors.  There are two forms of them:
      - the one named by DT_INIT
@@ -109,9 +109,9 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env)
       unsigned int cnt;
 
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_IMPCALLS, 0))
-	_dl_debug_message (1, "\ncalling preinit: ",
-			   main_map->l_name[0]
-			   ? main_map->l_name : _dl_argv[0], "\n\n", NULL);
+	_dl_debug_printf ("\ncalling preinit: %s\n\n",
+			  main_map->l_name[0]
+			  ? main_map->l_name : _dl_argv[0]);
 
       addrs = (ElfW(Addr) *) (main_map->l_info[DT_PREINIT_ARRAY]->d_un.d_ptr
 			      + main_map->l_addr);
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 315ea41e26..2e4d2d8d98 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -30,7 +30,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include "dynamic-link.h"
-#include <stdio-common/_itoa.h>
 
 #include <dl-dst.h>
 
@@ -802,7 +801,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
 
   /* Print debugging message.  */
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-    _dl_debug_message (1, "file=", name, ";  generating link map\n", NULL);
+    _dl_debug_printf ("file=%s;  generating link map\n", name);
 
   /* This is the ELF header.  We read it in `open_verify'.  */
   header = (void *) fbp->buf;
@@ -1060,34 +1059,14 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
   l->l_entry += l->l_addr;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-    {
-      const size_t nibbles = sizeof (void *) * 2;
-      char buf1[nibbles + 1];
-      char buf2[nibbles + 1];
-      char buf3[nibbles + 1];
-
-      buf1[nibbles] = '\0';
-      buf2[nibbles] = '\0';
-      buf3[nibbles] = '\0';
-
-      memset (buf1, '0', nibbles);
-      memset (buf2, '0', nibbles);
-      memset (buf3, '0', nibbles);
-      _itoa_word ((unsigned long int) l->l_ld, &buf1[nibbles], 16, 0);
-      _itoa_word ((unsigned long int) l->l_addr, &buf2[nibbles], 16, 0);
-      _itoa_word (maplength, &buf3[nibbles], 16, 0);
-
-      _dl_debug_message (1, "  dynamic: 0x", buf1, "  base: 0x", buf2,
-			 "   size: 0x", buf3, "\n", NULL);
-      memset (buf1, '0', nibbles);
-      memset (buf2, '0', nibbles);
-      memset (buf3, ' ', nibbles);
-      _itoa_word ((unsigned long int) l->l_entry, &buf1[nibbles], 16, 0);
-      _itoa_word ((unsigned long int) l->l_phdr, &buf2[nibbles], 16, 0);
-      _itoa_word (l->l_phnum, &buf3[nibbles], 10, 0);
-      _dl_debug_message (1, "    entry: 0x", buf1, "  phdr: 0x", buf2,
-			 "  phnum:   ", buf3, "\n\n", NULL);
-    }
+    _dl_debug_printf ("  dynamic: 0x%0*lx  base: 0x%0*lx   size: 0x%0*Zx\n"
+		      "    entry: 0x%0*lx  phdr: 0x%0*lx  phnum:   %*u\n\n",
+		      sizeof (void *) * 2, (unsigned long int) l->l_ld,
+		      sizeof (void *) * 2, (unsigned long int) l->l_addr,
+		      sizeof (void *) * 2, maplength,
+		      sizeof (void *) * 2, (unsigned long int) l->l_entry,
+		      sizeof (void *) * 2, (unsigned long int) l->l_phdr,
+		      sizeof (void *) * 2, l->l_phnum);
 
   elf_get_dynamic_info (l);
 
@@ -1172,7 +1151,7 @@ print_search_path (struct r_search_path_elem **list,
   char buf[max_dirnamelen + max_capstrlen];
   int first = 1;
 
-  _dl_debug_message (1, " search path=", NULL);
+  _dl_debug_printf (" search path=");
 
   while (*list != NULL && (*list)->what == what) /* Yes, ==.  */
     {
@@ -1187,18 +1166,23 @@ print_search_path (struct r_search_path_elem **list,
 	      cp[0] = '\0';
 	    else
 	      cp[-1] = '\0';
-	    _dl_debug_message (0, first ? "" : ":", buf, NULL);
-	    first = 0;
+	    if (first)
+	      {
+		_dl_debug_printf_c ("%s", buf);
+		first = 0;
+	      }
+	    else
+	      _dl_debug_printf_c (":%s", buf);
 	  }
 
       ++list;
     }
 
   if (name != NULL)
-    _dl_debug_message (0, "\t\t(", what, " from file ",
-			name[0] ? name : _dl_argv[0], ")\n", NULL);
+    _dl_debug_printf_c ("\t\t(%s from file %s)\n", what,
+			name[0] ? name : _dl_argv[0]);
   else
-    _dl_debug_message (0, "\t\t(", what, ")\n", NULL);
+    _dl_debug_printf_c ("\t\t(%s)\n", what);
 }
 
 /* Open a file and verify it is an ELF file for this architecture.  We
@@ -1373,7 +1357,7 @@ open_path (const char *name, size_t namelen, int preloaded,
 
 	  /* Print name we try if this is wanted.  */
 	  if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
-	    _dl_debug_message (1, "  trying file=", buf, "\n", NULL);
+	    _dl_debug_printf ("  trying file=%s\n", buf);
 
 	  fd = open_verify (buf, fbp);
 	  if (this_dir->status[cnt] == unknown)
@@ -1507,9 +1491,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
 
   /* Display information if we are debugging.  */
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0) && loader != NULL)
-    _dl_debug_message (1, "\nfile=", name, ";  needed by ",
-		       loader->l_name[0] ? loader->l_name : _dl_argv[0],
-		       "\n", NULL);
+    _dl_debug_printf ("\nfile=%s;  needed by %s\n", name,
+		      loader->l_name[0] ? loader->l_name : _dl_argv[0]);
 
   if (strchr (name, '/') == NULL)
     {
@@ -1518,7 +1501,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
       size_t namelen = strlen (name) + 1;
 
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
-	_dl_debug_message (1, "find library=", name, "; searching\n", NULL);
+	_dl_debug_printf ("find library=%s; searching\n", name);
 
       fd = -1;
 
@@ -1655,7 +1638,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
 
       /* Add another newline when we a tracing the library loading.  */
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_LIBS, 0))
-        _dl_debug_message (1, "\n", NULL);
+        _dl_debug_printf ("\n");
     }
   else
     {
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 5ef9345287..f8bb9e17ca 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -162,12 +162,11 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
 
 	      /* Display information if we are debugging.  */
 	      if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-		_dl_debug_message (1, "\nfile=",
-				   map->l_name[0] ? map->l_name : _dl_argv[0],
-				   ";  needed by ",
-				   undef_map->l_name[0]
-				   ? undef_map->l_name : _dl_argv[0],
-				   " (relocation dependency)\n\n", NULL);
+		_dl_debug_printf ("\
+\nfile=%s;  needed by %s (relocation dependency)\n\n",
+				  map->l_name[0] ? map->l_name : _dl_argv[0],
+				  undef_map->l_name[0]
+				  ? undef_map->l_name : _dl_argv[0]);
 	    }
 	  else
 	    /* Whoa, that was bad luck.  We have to search again.  */
@@ -243,14 +242,12 @@ _dl_lookup_symbol (const char *undef_name, struct link_map *undef_map,
   protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
-    _dl_debug_message (1, "binding file ",
-		       (reference_name && reference_name[0]
-			? reference_name
-			: (_dl_argv[0] ?: "<main program>")),
-		       " to ", current_value.m->l_name[0]
+    _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
+		      (reference_name && reference_name[0]
+		       ? reference_name : (_dl_argv[0] ?: "<main program>")),
+		       current_value.m->l_name[0]
 		       ? current_value.m->l_name : _dl_argv[0],
-		       ": ", protected ? "protected" : "normal",
-		       " symbol `", undef_name, "'\n", NULL);
+		       protected ? "protected" : "normal", undef_name);
 
   if (__builtin_expect (protected == 0, 1))
     {
@@ -322,14 +319,12 @@ _dl_lookup_symbol_skip (const char *undef_name,
   protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
-    _dl_debug_message (1, "binding file ",
+    _dl_debug_printf ("binding file %s to %s: %s symbol `%s'\n",
 		       (reference_name && reference_name[0]
-			? reference_name
-			: (_dl_argv[0] ?: "<main program>")),
-		       " to ", current_value.m->l_name[0]
+			? reference_name : (_dl_argv[0] ?: "<main program>")),
+		       current_value.m->l_name[0]
 		       ? current_value.m->l_name : _dl_argv[0],
-		       ": ", protected ? "protected" : "normal",
-		       " symbol `", undef_name, "'\n", NULL);
+		       protected ? "protected" : "normal", undef_name);
 
   if (__builtin_expect (protected == 0, 1))
     {
@@ -450,15 +445,13 @@ _dl_lookup_versioned_symbol (const char *undef_name,
   protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
-    _dl_debug_message (1, "binding file ",
+    _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
 		       (reference_name && reference_name[0]
-			? reference_name
-			: (_dl_argv[0] ?: "<main program>")),
-		       " to ", current_value.m->l_name[0]
+			? reference_name : (_dl_argv[0] ?: "<main program>")),
+		       current_value.m->l_name[0]
 		       ? current_value.m->l_name : _dl_argv[0],
-		       ": ", protected ? "protected" : "normal",
-		       " symbol `", undef_name, "' [", version->name,
-		       "]\n", NULL);
+		       protected ? "protected" : "normal",
+		      undef_name, version->name);
 
   if (__builtin_expect (protected == 0, 1))
     {
@@ -541,15 +534,13 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
   protected = *ref && ELFW(ST_VISIBILITY) ((*ref)->st_other) == STV_PROTECTED;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_BINDINGS, 0))
-    _dl_debug_message (1, "binding file ",
-		       (reference_name && reference_name[0]
-			? reference_name
-			: (_dl_argv[0] ?: "<main program>")),
-		       " to ", current_value.m->l_name[0]
-		       ? current_value.m->l_name : _dl_argv[0],
-		       ": ", protected ? "protected" : "normal",
-		       " symbol `", undef_name, "' [", version->name,
-		       "]\n", NULL);
+    _dl_debug_printf ("binding file %s to %s: %s symbol `%s' [%s]\n",
+		      (reference_name && reference_name[0]
+		       ? reference_name : (_dl_argv[0] ?: "<main program>")),
+		      current_value.m->l_name[0]
+		      ? current_value.m->l_name : _dl_argv[0],
+		      protected ? "protected" : "normal",
+		      undef_name, version->name);
 
   if (__builtin_expect (protected == 0, 1))
     {
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index 994b56c3d9..5184c1136c 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -187,13 +187,10 @@ void weak_function
 __assert_fail (const char *assertion,
 	       const char *file, unsigned int line, const char *function)
 {
-  char buf[64];
-  buf[sizeof buf - 1] = '\0';
-  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
-		    file, ": ", _itoa_word (line, buf + sizeof buf - 1, 10, 0),
-		    ": ", function ?: "", function ? ": " : "",
-		    "Assertion `", assertion, "' failed!\n",
-		    NULL);
+  _dl_fatal_printf ("\
+BUG IN DYNAMIC LINKER ld.so: %s: %u: %s%sAssertion `%s' failed!\n",
+		    file, line, function ?: "", function ? ": " : "",
+		    assertion);
 
 }
 
@@ -203,15 +200,10 @@ __assert_perror_fail (int errnum,
 		      const char *function)
 {
   char errbuf[64];
-  char buf[64];
-  buf[sizeof buf - 1] = '\0';
-  _dl_sysdep_fatal ("BUG IN DYNAMIC LINKER ld.so: ",
-		    file, ": ", _itoa_word (line, buf + sizeof buf - 1, 10, 0),
-		    ": ", function ?: "", function ? ": " : "",
-		    "Unexpected error: ",
-		    __strerror_r (errnum, errbuf, sizeof (errbuf)), "\n",
-		    NULL);
-
+  _dl_fatal_printf ("\
+BUG IN DYNAMIC LINKER ld.so: %s: %u: %s%sUnexpected error: %s\n",
+		    file, line, function ?: "", function ? ": " : "",
+		    __strerror_r (errnum, errbuf, sizeof (errbuf)));
 }
 
 #endif
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 76276df080..440da67d0d 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -243,17 +243,8 @@ dl_open_worker (void *a)
     {
       /* Let the user know about the opencount.  */
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-	{
-	  char buf[20];
-
-	  buf[sizeof buf - 1] = '\0';
-
-	  _dl_debug_message (1, "opening file=", new->l_name,
-			     "; opencount == ",
-			     _itoa_word (new->l_opencount,
-					 buf + sizeof buf - 1, 10, 0),
-			     "\n\n", NULL);
-	}
+	_dl_debug_printf ("opening file=%s; opencount == %u\n\n",
+			  new->l_name, new->l_opencount);
 
       /* If the user requested the object to be in the global namespace
 	 but it is not so far, add it now.  */
@@ -343,17 +334,8 @@ dl_open_worker (void *a)
 
   /* Let the user know about the opencount.  */
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-    {
-      char buf[20];
-
-      buf[sizeof buf - 1] = '\0';
-
-      _dl_debug_message (1, "opening file=", new->l_name,
-			 "; opencount == ",
-			 _itoa_word (new->l_opencount,
-				     buf + sizeof buf - 1, 10, 0),
-			 "\n\n", NULL);
-    }
+    _dl_debug_printf ("opening file=%s; opencount == %u\n\n",
+		      new->l_name, new->l_opencount);
 }
 
 
@@ -453,17 +435,15 @@ show_scope (struct link_map *new)
 
       numbuf[0] = '0' + scope_cnt;
       numbuf[1] = '\0';
-      _dl_sysdep_message ("scope ", numbuf, ":", NULL);
+      _dl_printf ("scope %s:", numbuf);
 
       for (cnt = 0; cnt < new->l_scope[scope_cnt]->r_nlist; ++cnt)
 	if (*new->l_scope[scope_cnt]->r_list[cnt]->l_name)
-	  _dl_sysdep_message (" ",
-			      new->l_scope[scope_cnt]->r_list[cnt]->l_name,
-			      NULL);
+	  _dl_printf (" %s", new->l_scope[scope_cnt]->r_list[cnt]->l_name)
 	else
-	  _dl_sysdep_message (" <main>", NULL);
+	  _dl_printf (" <main>", NULL);
 
-      _dl_sysdep_message ("\n", NULL);
+      _dl_printf ("\n", NULL);
     }
 }
 #endif
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 031de2569f..f1479dea3f 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -266,9 +266,8 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
     {
       /* We cannot write the profiling data so don't do anything.  */
       char buf[400];
-      _dl_sysdep_message (filename, ": cannot open file: ",
-			  __strerror_r (errno, buf, sizeof buf),
-			  "\n", NULL);
+      _dl_error_printf ("%s: cannot open file: %s\n", filename,
+			__strerror_r (errno, buf, sizeof buf));
       return;
     }
 
@@ -278,9 +277,8 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
       char buf[400];
       int errnum = errno;
       __close (fd);
-      _dl_sysdep_message (filename, ": cannot stat file: ",
-			  __strerror_r (errnum, buf, sizeof buf),
-			  "\n", NULL);
+      _dl_error_printf ("%s: cannot stat file: %s\n", filename,
+			__strerror_r (errnum, buf, sizeof buf));
       return;
     }
 
@@ -300,9 +298,8 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
 	cannot_create:
 	  errnum = errno;
 	  __close (fd);
-	  _dl_sysdep_message (filename, ": cannot create file: ",
-			      __strerror_r (errnum, buf, sizeof buf),
-			      "\n", NULL);
+	  _dl_error_printf ("%s: cannot create file: %s\n", filename,
+			    __strerror_r (errnum, buf, sizeof buf));
 	  return;
 	}
 
@@ -319,9 +316,8 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
       if (addr != NULL)
 	__munmap ((void *) addr, expected_size);
 
-      _dl_sysdep_message (filename,
-			  ": file is no correct profile data file for `",
-			  _dl_profile, "'\n", NULL);
+      _dl_error_printf ("%s: file is no correct profile data file for `%s'\n",
+			filename, _dl_profile);
       return;
     }
 
@@ -332,9 +328,8 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
       char buf[400];
       int errnum = errno;
       __close (fd);
-      _dl_sysdep_message (filename, ": cannot map file: ",
-			  __strerror_r (errnum, buf, sizeof buf),
-			  "\n", NULL);
+      _dl_error_printf ("%s: cannot map file: %s\n", filename,
+			__strerror_r (errnum, buf, sizeof buf));
       return;
     }
 
@@ -377,7 +372,7 @@ _dl_start_profile (struct link_map *map, const char *output_dir)
   if (tos == NULL)
     {
       __munmap ((void *) addr, expected_size);
-      _dl_sysdep_fatal ("Out of memory while initializing profiler\n", NULL);
+      _dl_fatal_printf ("Out of memory while initializing profiler\n");
       /* NOTREACHED */
     }
 
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index a82a1cb9e1..cf149f5b8e 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -41,9 +41,8 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
     lazy = 0;
 
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_RELOC, 0))
-    _dl_debug_message (1, "\nrelocation processing: ",
-		       l->l_name[0] ? l->l_name : _dl_argv[0],
-		       lazy ? " (lazy)\n" : "\n", NULL);
+    _dl_printf ("\nrelocation processing: %s%s\n",
+		l->l_name[0] ? l->l_name : _dl_argv[0], lazy ? " (lazy)" : "");
 
   if (__builtin_expect (l->l_info[DT_TEXTREL] != NULL, 0))
     {
@@ -99,17 +98,18 @@ cannot make segment writable for relocation"));
 	   if it only contains lead function) the l_info[DT_PLTRELSZ]
 	   will be NULL.  */
 	if (l->l_info[DT_PLTRELSZ] == NULL)
-	  _dl_sysdep_fatal (_dl_argv[0] ?: "<program name unknown>",
-			    ": profiler found no PLTREL in object ",
-			    l->l_name, "\n", NULL);
+	  _dl_fatal_printf ("%s: profiler found no PLTREL in object %s\n",
+			    _dl_argv[0] ?: "<program name unknown>",
+			    l->l_name);
 
 	l->l_reloc_result =
 	  (ElfW(Addr) *) calloc (sizeof (ElfW(Addr)),
 				 l->l_info[DT_PLTRELSZ]->d_un.d_val);
 	if (l->l_reloc_result == NULL)
-	  _dl_sysdep_fatal (_dl_argv[0] ?: "<program name unknown>",
-			    ": profiler out of memory shadowing PLTREL of ",
-			    l->l_name, "\n", NULL);
+	  _dl_fatal_printf ("\
+%s: profiler out of memory shadowing PLTREL of %s\n",
+			    _dl_argv[0] ?: "<program name unknown>",
+			    l->l_name);
       }
   }
 
diff --git a/elf/dl-version.c b/elf/dl-version.c
index 88bc4b6be8..0a44a3f029 100644
--- a/elf/dl-version.c
+++ b/elf/dl-version.c
@@ -84,9 +84,10 @@ match_symbol (const char *name, ElfW(Word) hash, const char *string,
 
   /* Display information about what we are doing while debugging.  */
   if (__builtin_expect (_dl_debug_mask & DL_DEBUG_VERSIONS, 0))
-    _dl_debug_message (1, "checking for version `", string, "' in file ",
-		       map->l_name[0] ? map->l_name : _dl_argv[0],
-		       " required by file ", name, "\n", NULL);
+    _dl_debug_printf ("\
+checking for version `%s' in file %s required by file %s\n",
+		      string, map->l_name[0] ? map->l_name : _dl_argv[0],
+		      name);
 
   if (__builtin_expect (map->l_info[VERSYMIDX (DT_VERDEF)] == NULL, 0))
     {
diff --git a/elf/do-lookup.h b/elf/do-lookup.h
index 8f6c6c07eb..c0f9b67ae3 100644
--- a/elf/do-lookup.h
+++ b/elf/do-lookup.h
@@ -61,9 +61,8 @@ FCT (const char *undef_name, unsigned long int hash, const ElfW(Sym) *ref,
 
       /* Print some debugging info if wanted.  */
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_SYMBOLS, 0))
-	_dl_debug_message (1, "symbol=", undef_name, ";  lookup in file=",
-			   map->l_name[0] ? map->l_name : _dl_argv[0],
-			   "\n", NULL);
+	_dl_debug_printf ("symbol=%s;  lookup in file=%s\n", undef_name,
+			  map->l_name[0] ? map->l_name : _dl_argv[0]);
 
       symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
       strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
diff --git a/elf/rtld.c b/elf/rtld.c
index 0d4911c52d..70634927f5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -452,7 +452,7 @@ dl_main (const ElfW(Phdr) *phdr,
       /* If we have no further argument the program was called incorrectly.
 	 Grant the user some education.  */
       if (_dl_argc < 2)
-	_dl_sysdep_fatal ("\
+	_dl_fatal_printf ("\
 Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
 You have invoked `ld.so', the helper program for shared library executables.\n\
 This program usually lives in the file `/lib/ld.so', and special directives\n\
@@ -472,8 +472,7 @@ of this helper program; chances are you did not intend to run this program.\n\
   --library-path PATH   use given PATH instead of content of the environment\n\
                         variable LD_LIBRARY_PATH\n\
   --inhibit-rpath LIST  ignore RUNPATH and RPATH information in object names\n\
-                        in LIST\n",
-			  NULL);
+                        in LIST\n");
 
       ++_dl_skip_args;
       --_dl_argc;
@@ -522,7 +521,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	 This will be what dlopen on "" returns.  */
       _dl_new_object ((char *) "", "", lt_executable, NULL);
       if (_dl_loaded == NULL)
-	_dl_sysdep_fatal ("cannot allocate memory for link map\n", NULL);
+	_dl_fatal_printf ("cannot allocate memory for link map\n");
       _dl_loaded->l_phdr = phdr;
       _dl_loaded->l_phnum = phnum;
       _dl_loaded->l_entry = *user_entry;
@@ -865,7 +864,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	 functions we call below for output may no longer work properly
 	 after relocation.  */
       if (! _dl_loaded->l_info[DT_NEEDED])
-	_dl_sysdep_message ("\t", "statically linked\n", NULL);
+	_dl_printf ("\tstatically linked\n");
       else
 	{
 	  struct link_map *l;
@@ -873,19 +872,10 @@ of this helper program; chances are you did not intend to run this program.\n\
 	  for (l = _dl_loaded->l_next; l; l = l->l_next)
 	    if (l->l_faked)
 	      /* The library was not found.  */
-	      _dl_sysdep_message ("\t", l->l_libname->name, " => not found\n",
-				  NULL);
+	      _dl_printf ("\t%s => not found\n", l->l_libname->name);
 	    else
-	      {
-		char buf[20], *bp;
-		buf[sizeof buf - 1] = '\0';
-		bp = _itoa_word (l->l_addr, &buf[sizeof buf - 1], 16, 0);
-		while ((size_t) (&buf[sizeof buf - 1] - bp)
-		       < sizeof l->l_addr * 2)
-		  *--bp = '0';
-		_dl_sysdep_message ("\t", l->l_libname->name, " => ",
-				    l->l_name, " (0x", bp, ")\n", NULL);
-	      }
+	      _dl_printf ("\t%s => %s (0x%0*Zx)\n", l->l_libname->name,
+			  l->l_name, sizeof l->l_addr * 2, l->l_addr);
 	}
 
       if (__builtin_expect (mode, trace) != trace)
@@ -894,7 +884,6 @@ of this helper program; chances are you did not intend to run this program.\n\
 	    const ElfW(Sym) *ref = NULL;
 	    ElfW(Addr) loadbase;
 	    lookup_t result;
-	    char buf[20], *bp;
 
 	    result = _dl_lookup_symbol (_dl_argv[i], _dl_loaded,
 					&ref, _dl_loaded->l_scope,
@@ -902,16 +891,9 @@ of this helper program; chances are you did not intend to run this program.\n\
 
 	    loadbase = LOOKUP_VALUE_ADDRESS (result);
 
-	    buf[sizeof buf - 1] = '\0';
-	    bp = _itoa_word (ref->st_value, &buf[sizeof buf - 1], 16, 0);
-	    while ((size_t) (&buf[sizeof buf - 1] - bp) < sizeof loadbase * 2)
-	      *--bp = '0';
-	    _dl_sysdep_message (_dl_argv[i], " found at 0x", bp, NULL);
-	    buf[sizeof buf - 1] = '\0';
-	    bp = _itoa_word (loadbase, &buf[sizeof buf - 1], 16, 0);
-	    while ((size_t) (&buf[sizeof buf - 1] - bp) < sizeof loadbase * 2)
-	      *--bp = '0';
-	    _dl_sysdep_message (" in object at 0x", bp, "\n", NULL);
+	    _dl_printf ("%s found at 0x%0*Zd in object at 0x%0*Zd\n",
+			_dl_argv[i], sizeof ref->st_value * 2, ref->st_value,
+			sizeof loadbase * 2, loadbase);
 	  }
       else
 	{
@@ -961,13 +943,12 @@ of this helper program; chances are you did not intend to run this program.\n\
 
 		  if (first)
 		    {
-		      _dl_sysdep_message ("\n\tVersion information:\n", NULL);
+		      _dl_printf ("\n\tVersion information:\n");
 		      first = 0;
 		    }
 
-		  _dl_sysdep_message ("\t", (map->l_name[0]
-					     ? map->l_name : _dl_argv[0]),
-				      ":\n", NULL);
+		  _dl_printf ("\t%s:\n",
+			      map->l_name[0] ? map->l_name : _dl_argv[0]);
 
 		  while (1)
 		    {
@@ -981,22 +962,17 @@ of this helper program; chances are you did not intend to run this program.\n\
 			{
 			  const char *fname = NULL;
 
-			  _dl_sysdep_message ("\t\t",
-					      strtab + ent->vn_file,
-					      " (", strtab + aux->vna_name,
-					      ") ",
-					      (aux->vna_flags
-					       & VER_FLG_WEAK
-					       ? "[WEAK] " : ""),
-					      "=> ", NULL);
-
 			  if (needed != NULL
 			      && match_version (strtab + aux->vna_name,
 						needed))
 			    fname = needed->l_name;
 
-			  _dl_sysdep_message (fname ?: "not found", "\n",
-					      NULL);
+			  _dl_printf ("\t\t%s (%s) %s=> %s\n",
+				      strtab + ent->vn_file,
+				      strtab + aux->vna_name,
+				      aux->vna_flags & VER_FLG_WEAK
+				      ? "[WEAK] " : "",
+				      fname ?: "not found");
 
 			  if (aux->vna_next == 0)
 			    /* No more symbols.  */
@@ -1155,7 +1131,7 @@ print_unresolved (int errcode __attribute__ ((unused)), const char *objname,
 {
   if (objname[0] == '\0')
     objname = _dl_argv[0] ?: "<main program>";
-  _dl_sysdep_error (errstring, "	(", objname, ")\n", NULL);
+  _dl_error_printf ("%s	(%s)\n", errstring, objname);
 }
 
 /* This is a little helper function for resolving symbols while
@@ -1164,8 +1140,8 @@ static void
 print_missing_version (int errcode __attribute__ ((unused)),
 		       const char *objname, const char *errstring)
 {
-  _dl_sysdep_error (_dl_argv[0] ?: "<program name unknown>", ": ",
-		    objname, ": ", errstring, "\n", NULL);
+  _dl_error_printf ("%s: %s: %s\n", _dl_argv[0] ?: "<program name unknown>",
+		    objname, errstring);
 }
 
 /* Nonzero if any of the debugging options is enabled.  */
@@ -1206,7 +1182,7 @@ process_dl_debug (const char *dl_debug)
 	    case 4:
 	      if (memcmp (dl_debug, "help", 4) == 0)
 		{
-		  _dl_sysdep_message ("\
+		  _dl_printf ("\
 Valid options for the LD_DEBUG environment variable are:\n\
 \n\
   bindings   display information about symbol binding\n\
@@ -1219,8 +1195,7 @@ Valid options for the LD_DEBUG environment variable are:\n\
   versions   display version dependencies\n\
 \n\
 To direct the debugging output into a file instead of standard output\n\
-a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n",
-				  NULL);
+a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n");
 		  _exit (0);
 		}
 
@@ -1288,8 +1263,8 @@ a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n",
 	  {
 	    /* Display a warning and skip everything until next separator.  */
 	    char *startp = strndupa (dl_debug, len);
-	    _dl_sysdep_error ("warning: debug option `", startp,
-			      "' unknown; try LD_DEBUG=help\n", NULL);
+	    _dl_error_printf ("\
+warning: debug option `%s' unknown; try LD_DEBUG=help\n", startp);
 	    break;
 	  }
 	}
@@ -1511,21 +1486,19 @@ print_statistics (void)
   if (HP_TIMING_AVAIL)
     {
       HP_TIMING_PRINT (buf, sizeof (buf), rtld_total_time);
-      _dl_debug_message (1, "\nruntime linker statistics:\n"
-			 "  total startup time in dynamic loader: ",
-			 buf, "\n", NULL);
+      _dl_debug_printf ("\nruntime linker statistics:\n"
+			"  total startup time in dynamic loader: %s\n", buf);
     }
 
   /* Print relocation statistics.  */
   if (HP_TIMING_AVAIL)
     {
+      char pbuf[30];
       HP_TIMING_PRINT (buf, sizeof (buf), relocate_time);
-      _dl_debug_message (1, "            time needed for relocation: ", buf,
-			 NULL);
       cp = _itoa_word ((1000 * relocate_time) / rtld_total_time,
-		       buf + sizeof (buf), 10, 0);
-      wp = buf;
-      switch (buf + sizeof (buf) - cp)
+		       pbuf + sizeof (pbuf), 10, 0);
+      wp = pbuf;
+      switch (pbuf + sizeof (pbuf) - cp)
 	{
 	case 3:
 	  *wp++ = *cp++;
@@ -1536,26 +1509,23 @@ print_statistics (void)
 	  *wp++ = *cp++;
 	}
       *wp = '\0';
-      _dl_debug_message (0, " (", buf, "%)\n", NULL);
+      _dl_debug_printf ("            time needed for relocation: %s (%s)\n",
+			buf, pbuf);
     }
 #endif
-  buf[sizeof (buf) - 1] = '\0';
-  _dl_debug_message (1, "                 number of relocations: ",
-		     _itoa_word (_dl_num_relocations,
-				 buf + sizeof (buf) - 1, 10, 0),
-		     "\n", NULL);
+  _dl_debug_printf ("                 number of relocations: %lu\n",
+		    _dl_num_relocations);
 
 #ifndef HP_TIMING_NONAVAIL
   /* Time spend while loading the object and the dependencies.  */
   if (HP_TIMING_AVAIL)
     {
+      char pbuf[30];
       HP_TIMING_PRINT (buf, sizeof (buf), load_time);
-      _dl_debug_message (1, "           time needed to load objects: ", buf,
-			 NULL);
       cp = _itoa_word ((1000 * load_time) / rtld_total_time,
-		       buf + sizeof (buf), 10, 0);
-      wp = buf;
-      switch (buf + sizeof (buf) - cp)
+		       pbuf + sizeof (pbuf), 10, 0);
+      wp = pbuf;
+      switch (pbuf + sizeof (pbuf) - cp)
 	{
 	case 3:
 	  *wp++ = *cp++;
@@ -1566,7 +1536,8 @@ print_statistics (void)
 	  *wp++ = *cp++;
 	}
       *wp = '\0';
-      _dl_debug_message (0, " (", buf, "%)\n", NULL);
+      _dl_debug_printf ("           time needed to load objects: %s (%s)\n",
+			buf, pbuf);
     }
 #endif
 }