about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-06 17:21:43 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-06 17:21:43 +0000
commit7dea968e78d0903e5f6069f2bf72a9961f49465f (patch)
tree20dd8ba18cd1960f9c60d8ae73adea86de2a253e /elf/rtld.c
parent4b7814cf8a55c034f34e02c14207bb271b3aee50 (diff)
downloadglibc-7dea968e78d0903e5f6069f2bf72a9961f49465f.tar.gz
glibc-7dea968e78d0903e5f6069f2bf72a9961f49465f.tar.xz
glibc-7dea968e78d0903e5f6069f2bf72a9961f49465f.zip
Update.
1998-03-06 17:04  Ulrich Drepper  <drepper@cygnus.com>

	* libc.map: Add _dl_debug_impcalls, _dl_debug_fd, _dl_sysdep_output,
	__libc_start_main.
	* csu/Makefile (routines): Add libc-start.
	* elf/dl-error.c: Remove declaration of _dl_argv.  Include <unitsd.h>.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-version.c: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* elf/link.h: Declare _dl_argv, _dl_debug_fd.
	Declare _dl_sysdep_output.  Make _dl_sysdep_fatal, _dl_sysdep_error and
	_dl_sysdep_message macros which use _dl_sysdep_output.
	* elf/dl-fini.c: Write out which destructor is called while debugging.
	* elf/dl-init.c: Likewise for constructor.
	* elf/dl-load.c: Use _dl_debug_message instead of _dl_sysdep_message.
	* elf/dl-misc.c: Remove _dl_sysdep_fatal, _dl_sysdep_error and
	_dl_sysdep_message.  Add _dl_sysdep_output.
	* elf/rtld.c: Recognize LD_DEBUG_OUTPUT.  Set _dl_debug_fd if
	this file can be opened.
	For LD_DEBUG=libs also set _dl_debug_impcalls.
	* sysdeps/generic/dl-cache.c: Include unistd.h.
	* sysdeps/generic/libc-start.c: New file.
	* sysdeps/i386/elf/start.S: Don't call main directly, call
	* sysdeps/unix/sysv/linux/libc-start.c: New file.
	__libc_start_main instead.

	* elf/Makefile ($(objpfx)ld.so): Add $(load-map-file) as dependency.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index fe45f1bb9b..c80fe2740e 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <fcntl.h>
 #include <link.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -74,6 +75,7 @@ const char *_dl_profile;
 const char *_dl_profile_output;
 struct link_map *_dl_profile_map;
 int _dl_debug_libs;
+int _dl_debug_impcalls;
 
 /* Set nonzero during loading and initialization of executable and
    libraries, cleared before the executable's entry point runs.  This
@@ -907,6 +909,9 @@ print_missing_version (int errcode __attribute__ ((unused)),
 		    objname, ": ", errstring, "\n", NULL);
 }
 
+/* Nonzero if any of the debugging options is enabled.  */
+static int any_debug;
+
 /* Process the string given as the parameter which explains which debugging
    options are enabled.  */
 static void
@@ -924,6 +929,8 @@ process_dl_debug (char *dl_debug)
 	      && (issep (dl_debug[4]) || dl_debug[4] == '\0'))
 	    {
 	      _dl_debug_libs = 1;
+	      _dl_debug_impcalls = 1;
+	      any_debug = 1;
 	      dl_debug += 4;
 	    }
 	  else if (strncmp (dl_debug, "help", 4) == 0
@@ -956,6 +963,7 @@ process_envvars (enum mode *modep, int *lazyp)
   char *envline;
   enum mode mode = normal;
   int bind_now = 0;
+  char *debug_output = NULL;
 
   /* This is the default place for profiling data file.  */
   _dl_profile_output = "/var/tmp";
@@ -984,6 +992,16 @@ process_envvars (enum mode *modep, int *lazyp)
       if (result < 0)
 	continue;
 
+      /* Where to place the profiling data file.  */
+      result = strncmp (&envline[3], "DEBUG_OUTPUT=", 13);
+      if (result == 0)
+	{
+	  debug_output = &envline[16];
+	  continue;
+	}
+      if (result < 0)
+	continue;
+
       /* Which shared object shall be profiled.  */
       result = strncmp (&envline[3], "PROFILE=", 8);
       if (result == 0)
@@ -1038,6 +1056,18 @@ process_envvars (enum mode *modep, int *lazyp)
 	}
     }
 
+  /* If we have to run the dynamic linker in debugging mode and the
+     LD_DEBUG_OUTPUT environment variable is given, we write the debug
+     messages to this file.  */
+  if (any_debug && debug_output != NULL)
+    {
+      _dl_debug_fd = __open (debug_output, O_WRONLY | O_APPEND | O_CREAT,
+			     0666);
+      if (_dl_debug_fd == -1)
+	/* We use standard output if opening the file failed.  */
+	_dl_debug_fd = STDOUT_FILENO;
+    }
+
   /* LAZY is determined by the environment variable LD_WARN and
      LD_BIND_NOW if we trace the binary.  */
   if (mode == trace)