This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix up LD_* vars behaviour


While playing with LD_DYNAMIC_WEAK I've found an inconsistency in
processing LD_* vars.  There are some variables which are switched
on only when the part after `=' is non-null, e.g.:

$ LD_DEBUG=statistics LD_BIND_NOW= elf/ld-linux-x86-64.so.2 --library-path . /bin/ed <<< q
     31275:	runtime linker statistics:
     31275:	           final number of relocations: 103
     31275:	final number of relocations from cache: 3

$ LD_DEBUG=statistics LD_BIND_NOW=1 elf/ld-linux-x86-64.so.2 --library-path . /bin/ed <<< q
     31276:	runtime linker statistics:
     31276:	           final number of relocations: 147
     31276:	final number of relocations from cache: 3

On the other hand, some are enabled even though they're null:

$ LD_SHOW_AUXV= elf/ld-linux-x86-64.so.2 --library-path . /bin/true
AT_SYSINFO_EHDR: 0x7fff329ff000
AT_HWCAP:        bfebfbff
AT_PAGESZ:       4096
...

So, if this isn't actually wanted for some reason, I propose following
patch.  Regtested on x86_64-linux, ok for trunk?

2012-04-08  Marek Polacek  <polacek@redhat.com>

	* elf/rtld.c (process_envvars): Ignore null LD_SHOW_AUXV,
	LD_DYNAMIC_WEAK and LD_TRACE_LOADED_OBJECTS envvars.

--- libc/elf/rtld.c.mp	2012-04-08 22:07:38.670607197 +0200
+++ libc/elf/rtld.c	2012-04-08 23:49:35.169531256 +0200
@@ -2643,7 +2643,8 @@ process_envvars (enum mode *modep)
 	  /* Test whether we want to see the content of the auxiliary
 	     array passed up from the kernel.  */
 	  if (!INTUSE(__libc_enable_secure)
-	      && memcmp (envline, "SHOW_AUXV", 9) == 0)
+	      && memcmp (envline, "SHOW_AUXV", 9) == 0
+	      && envline[10] != '\0')
 	    _dl_show_auxv ();
 	  break;
 
@@ -2678,7 +2679,7 @@ process_envvars (enum mode *modep)
 
 	  if (!INTUSE(__libc_enable_secure)
 	      && memcmp (envline, "DYNAMIC_WEAK", 12) == 0)
-	    GLRO(dl_dynamic_weak) = 1;
+	    GLRO(dl_dynamic_weak) = envline[13] != '\0';
 	  break;
 
 	case 13:
@@ -2719,7 +2720,8 @@ process_envvars (enum mode *modep)
 
 	case 20:
 	  /* The mode of the dynamic linker can be set.  */
-	  if (memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0)
+	  if (memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0
+	      && envline[21] != '\0')
 	    mode = trace;
 	  break;
 
	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]