about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile5
-rw-r--r--elf/dl-load.c2
-rw-r--r--elf/dl-support.c3
-rw-r--r--elf/rtld.c49
4 files changed, 27 insertions, 32 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 44c510ac43..a19a8b42ba 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -21,14 +21,15 @@
 subdir		:= elf
 
 headers		= elf.h elfclass.h link.h dlfcn.h
-routines	= $(dl-routines) dl-open dl-close dl-symbol dl-support
+routines	= $(dl-routines) dl-open dl-close dl-symbol dl-support \
+		  enbl-secure
 
 # The core dynamic linking functions are in libc for the static and
 # profiled libraries.
 dl-routines	= $(addprefix dl-,load cache lookup object reloc deps \
 			          runtime error init fini debug)
 # But they are absent from the shared libc, because that code is in ld.so.
-elide-routines.so = $(dl-routines) dl-support
+elide-routines.so = $(dl-routines) dl-support enbl-secure
 
 # ld.so uses those routines, plus some special stuff for being the program
 # interpreter and operating independent of libc.
diff --git a/elf/dl-load.c b/elf/dl-load.c
index fc2733252a..8ccc838b2b 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -511,7 +511,7 @@ _dl_map_object (struct link_map *loader, const char *name, int type)
 				 l->l_info[DT_STRTAB]->d_un.d_ptr +
 				 l->l_info[DT_RPATH]->d_un.d_val));
       /* Try an environment variable (unless setuid).  */
-      if (fd == -1 && ! _dl_secure)
+      if (fd == -1 && ! __libc_enable_secure)
 	trypath (getenv ("LD_LIBRARY_PATH"));
       if (fd == -1)
 	{
diff --git a/elf/dl-support.c b/elf/dl-support.c
index b85d470770..50ebfbfe5a 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -24,8 +24,6 @@ Cambridge, MA 02139, USA.  */
 /* This file defines some things that for the dynamic linker are defined in
    rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking.  */
 
-int _dl_secure;			/* Always honor LD_LIBRARY_PATH.  */
-
 extern char *__progname;
 char **_dl_argv = &__progname;	/* This is checked for some error messages.  */
 
@@ -48,4 +46,3 @@ _dl_sysdep_fatal (void)
 {
   assert (! "_dl_sysdep_fatal called");
 }
-
diff --git a/elf/rtld.c b/elf/rtld.c
index 35a94b24cc..3657efdc61 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -30,7 +30,7 @@ Cambridge, MA 02139, USA.  */
 
 /* System-specific function to do initial startup for the dynamic linker.
    After this, file access calls and getenv must work.  This is responsible
-   for setting _dl_secure if we need to be secure (e.g. setuid),
+   for setting __libc_enable_secure if we need to be secure (e.g. setuid),
    and for setting _dl_argc and _dl_argv, and then calling _dl_main.  */
 extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
 				    void (*dl_main) (const ElfW(Phdr) *phdr,
@@ -38,7 +38,6 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
 						     ElfW(Addr) *user_entry));
 extern void _dl_sysdep_start_cleanup (void);
 
-int _dl_secure;
 int _dl_argc;
 char **_dl_argv;
 const char *_dl_rpath;
@@ -269,7 +268,7 @@ of this helper program; chances are you did not intend to run this program.\n",
 
   preloads = NULL;
   npreloads = 0;
-  if (! _dl_secure)
+  if (! __libc_enable_secure)
     {
       const char *preloadlist = getenv ("LD_PRELOAD");
       if (preloadlist)
@@ -340,10 +339,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)
-    mode = list;
-
-  if (mode != normal)
+  if (mode != normal || getenv ("LD_TRACE_LOADED_OBJECTS") != NULL)
     {
       /* We were run just to list the shared libraries.  It is
 	 important that we do this before real relocation, because the
@@ -366,29 +362,30 @@ of this helper program; chances are you did not intend to run this program.\n",
 				" (0x", bp, ")\n", NULL);
 	  }
 
-      for (i = 1; i < _dl_argc; ++i)
-	{
-	  const ElfW(Sym) *ref = NULL;
-	  ElfW(Addr) loadbase = _dl_lookup_symbol (_dl_argv[i], &ref,
-						   &_dl_default_scope[2],
-						   "argument", 0, 0);
-	  char buf[20], *bp;
-	  buf[sizeof buf - 1] = '\0';
-	  bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);
-	  while (&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 (loadbase, &buf[sizeof buf - 1], 16, 0);
-	  while (&buf[sizeof buf - 1] - bp < sizeof loadbase * 2)
-	    *--bp = '0';
-	  _dl_sysdep_message (" in object at 0x", bp, "\n", NULL);
-	}
+      if (mode != normal)
+	for (i = 1; i < _dl_argc; ++i)
+	  {
+	    const ElfW(Sym) *ref = NULL;
+	    ElfW(Addr) loadbase = _dl_lookup_symbol (_dl_argv[i], &ref,
+						     &_dl_default_scope[2],
+						     "argument", 0, 0);
+	    char buf[20], *bp;
+	    buf[sizeof buf - 1] = '\0';
+	    bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);
+	    while (&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 (loadbase, &buf[sizeof buf - 1], 16, 0);
+	    while (&buf[sizeof buf - 1] - bp < sizeof loadbase * 2)
+	      *--bp = '0';
+	    _dl_sysdep_message (" in object at 0x", bp, "\n", NULL);
+	  }
 
       _exit (0);
     }
 
-  lazy = !_dl_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0';
+  lazy = !__libc_enable_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0';
 
   {
     /* Now we have all the objects loaded.  Relocate them all except for