[PATCH 5/5][v2][BZ #15022] Remove dead DL_DST_REQ_STATIC code

Maciej W. Rozycki macro@codesourcery.com
Wed Jun 19 15:17:00 GMT 2013


Roland,

 Here's the final change in this series.  While looking into the 
elf/tst-leaks1-static-mem regression I noticed this DL_DST_REQ_STATIC code 
that by all means looks dead to me, because all the call sites either make 
sure the pointer passed down here as the L argument is non-NULL or 
indirectly rely on it being such by dereferencing it earlier on to access 
one of the structure's members.  Therefore I have concluded it is safe to 
remove this code.  The change caused no regressions in mips-linux testing 
either.

 This code is already dead in our tree as it is, before any of the changes 
from this series, and particularly 3/5, have been applied, hence I'm 
posting it as a separate fix.  OK to apply?

 NB this code leaks memory, the allocation obtained by _dl_get_origin is 
only assigned to this block-scope automatic ORIGIN variable and never 
freed once all processing of this variable has ended.

2013-06-19  Maciej W. Rozycki  <macro@codesourcery.com>

	* elf/dl-dst.h (DL_DST_REQUIRED): Remove call to 
	DL_DST_REQ_STATIC.
	(DL_DST_REQ_STATIC): Remove macro.

  Maciej

glibc-static-dst-required-null.diff
Index: glibc-fsf-trunk-quilt/elf/dl-dst.h
===================================================================
--- glibc-fsf-trunk-quilt.orig/elf/dl-dst.h	2013-01-16 00:04:04.000000000 +0000
+++ glibc-fsf-trunk-quilt/elf/dl-dst.h	2013-06-18 14:01:00.182642715 +0100
@@ -55,7 +55,6 @@
 	   First get the origin string if it is not available yet.	      \
 	   This can only happen for the map of the executable or, when	      \
 	   auditing, in ld.so.  */					      \
-	DL_DST_REQ_STATIC (l)						      \
 	if ((l)->l_origin == NULL)					      \
 	  {								      \
 	    assert ((l)->l_name[0] == '\0' || IS_RTLD (l));		      \
@@ -73,15 +72,3 @@
       }									      \
 									      \
     __len; })
-
-#ifdef SHARED
-# define DL_DST_REQ_STATIC(l) /* nothing */
-#else
-# define DL_DST_REQ_STATIC(l) \
-  if ((l) == NULL)							      \
-    {									      \
-      const char *origin = _dl_get_origin ();				      \
-      dst_len = (origin && origin != (char *) -1 ? strlen (origin) : 0);      \
-    }									      \
-  else
-#endif



More information about the Libc-alpha mailing list