about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-08-16 01:33:20 +0000
committerUlrich Drepper <drepper@redhat.com>1996-08-16 01:33:20 +0000
commit2de99474c3d4278fb874bbbc12c24c388f786c21 (patch)
treef0622a362f5ec61739b9e6a8ae25b0e6cdf4fccf /elf/rtld.c
parentad86485dcf2a4391fbc92e2d8f7c8d44d334ff0d (diff)
downloadglibc-2de99474c3d4278fb874bbbc12c24c388f786c21.tar.gz
glibc-2de99474c3d4278fb874bbbc12c24c388f786c21.tar.xz
glibc-2de99474c3d4278fb874bbbc12c24c388f786c21.zip
update from main archive 960815 cvs/libc-960816
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 308c2f4d6d..b8aa7311ab 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -126,10 +126,12 @@ dl_main (const ElfW(Phdr) *phdr,
   const ElfW(Phdr) *ph;
   struct link_map *l;
   int lazy;
-  enum { normal, list, verify } mode = normal;
+  enum { normal, list, verify, trace } mode;
   struct link_map **preloads;
   unsigned int npreloads;
 
+  mode = getenv ("LD_TRACE_LOADED_OBJECTS") != NULL ? trace : normal;
+
   if (*user_entry == (ElfW(Addr)) &_start)
     {
       /* Ho ho.  We are not the program interpreter!  We are the program
@@ -187,7 +189,22 @@ of this helper program; chances are you did not intend to run this program.\n",
       --_dl_argc;
       ++_dl_argv;
 
-      l = _dl_map_object (NULL, _dl_argv[0], lt_library);
+      if (mode == verify)
+	{
+	  void doit (void)
+	    {
+	      l = _dl_map_object (NULL, _dl_argv[0], lt_library);
+	    }
+	  const char *err_str = NULL;
+	  const char *obj_name __attribute__ ((unused));
+
+	  (void) _dl_catch_error (&err_str, &obj_name, doit);
+	  if (err_str != NULL)
+	    _exit (EXIT_FAILURE);
+	}
+      else
+	l = _dl_map_object (NULL, _dl_argv[0], lt_library);
+
       phdr = l->l_phdr;
       phent = l->l_phnum;
       l->l_name = (char *) "";
@@ -197,7 +214,7 @@ of this helper program; chances are you did not intend to run this program.\n",
     {
       /* Create a link_map for the executable itself.
 	 This will be what dlopen on "" returns.  */
-      l = _dl_new_object ((char *) "", "", lt_library);
+      l = _dl_new_object ((char *) "", "", lt_executable);
       l->l_phdr = phdr;
       l->l_phnum = phent;
       l->l_entry = *user_entry;
@@ -340,7 +357,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 	}
     }
 
-  if (mode != normal || getenv ("LD_TRACE_LOADED_OBJECTS") != NULL)
+  if (mode != normal)
     {
       /* We were run just to list the shared libraries.  It is
 	 important that we do this before real relocation, because the
@@ -363,7 +380,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 				" (0x", bp, ")\n", NULL);
 	  }
 
-      if (mode != normal)
+      if (mode != trace)
 	for (i = 1; i < _dl_argc; ++i)
 	  {
 	    const ElfW(Sym) *ref = NULL;