[PATCH] Fix LD_TRACE_PRELINKING

Jakub Jelinek jakub@redhat.com
Sat Feb 12 22:28:00 GMT 2005


Hi!

Without this patch LD_TRACE_PRELINKING doesn't report conflicts caused by
ld.so relocations (malloc, free, etc.).
This causes that prelinked binaries use ld.so's own malloc/free, which is
in itself bad, but especially bad when e.g. ld.so malloces something and
libc.so attempts to free it or the other way around.

2005-02-12  Jakub Jelinek  <jakub@redhat.com>

	* elf/rtld.c (dlmain): If LD_TRACE_PRELINKING, clear l_relocated flag
	before relocating ld.so again.

--- libc/elf/rtld.c.jj	2005-02-11 15:22:21.000000000 +0100
+++ libc/elf/rtld.c	2005-02-12 10:50:50.000000000 +0100
@@ -1919,10 +1919,13 @@ ERROR: ld.so: object '%s' from %s cannot
 
 	      if ((GLRO(dl_debug_mask) & DL_DEBUG_PRELINK)
 		  && GL(dl_rtld_map).l_opencount > 1)
-		_dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope,
-				     0, 0);
-	    }
-
+		{
+		  /* Mark the link map as not yet relocated again.  */
+		  GL(dl_rtld_map).l_relocated = 0;
+		  _dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope,
+				       0, 0);
+		}
+            }
 #define VERNEEDTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (DT_VERNEED))
 	  if (version_info)
 	    {

	Jakub



More information about the Libc-hacker mailing list