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]

Re: DL_DEBUG_UNUSED buggy, especially with vdso


From: David Miller <davem@davemloft.net>
Date: Tue, 03 Apr 2012 23:59:32 -0400 (EDT)

> 2) Dealing with the PLT lazy eval issue.  We can't just pretend
>    LD_BIND_NOW is set because in this test case testobj1.so also
>    references a symbol 'foo' via the PLT which will be undefined

And this addresses the PLT lazy eval issue.

Any objections?

2012-04-04  David S. Miller  <davem@davemloft.net>

	* elf/rtld.c (dl_main): If DL_DEBUG_UNUSED is enabled, turn off
	lazy binding.
	* elf/dl-lookup (_dl_lookup_symbol_x): If DL_DEBUG_UNUSED, ignore
	undefined symbol errors.

diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 839dd3a..a2a699b 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -769,7 +769,8 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
   if (__builtin_expect (current_value.s == NULL, 0))
     {
       if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
-	  && skip_map == NULL)
+	  && skip_map == NULL
+	  && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED))
 	{
 	  /* We could find no value for a strong reference.  */
 	  const char *reference_name = undef_map ? undef_map->l_name : "";
diff --git a/elf/rtld.c b/elf/rtld.c
index 1cc9cf3..0362b14 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2500,6 +2505,14 @@ warning: debug option `%s' unknown; try LD_DEBUG=help\n", copy);
       ++dl_debug;
     }
 
+  if (GLRO(dl_debug_mask) & DL_DEBUG_UNUSED)
+    {
+      /* In order to get an accurate picture of whether a particular
+	 DT_NEEDED entry is actually used we have to process both
+	 the PLT and non-PLT relocation entries.  */
+      GLRO(dl_lazy) = 0;
+    }
+
   if (GLRO(dl_debug_mask) & DL_DEBUG_HELP)
     {
       size_t cnt;


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