This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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] Print number of relative relocations in LD_DEBUG=statistics output


Hi!

I think this is useful (although it is possible to dig it through
readelf on all of used libraries plus ldd (or LD_TRACE_PRELINKING) to see
what libraries are mapped at their desired locations).
Adds 160 bytes to ld.so's .text section and 64 bytes to .rodata in my i686
build.

2003-10-15  Jakub Jelinek  <jakub@redhat.com>

	* elf/rtld.c (print_statistics): Print also number of relative
	relocations.

--- libc/elf/rtld.c.jj	2003-10-02 21:51:05.000000000 +0200
+++ libc/elf/rtld.c	2003-10-15 00:57:09.000000000 +0200
@@ -2118,10 +2118,30 @@ print_statistics (void)
 				buf, pbuf);
     }
 #endif
+
+  unsigned long int num_relative_relocations = 0;
+  struct r_scope_elem *scope = &GL(dl_loaded)->l_searchlist;
+  unsigned int i;
+
+  for (i = 0; i < scope->r_nlist; i++)
+    {
+      struct link_map *l = scope->r_list [i];
+
+      if (!l->l_addr)
+	continue;
+
+      if (l->l_info[VERSYMIDX (DT_RELCOUNT)])
+	num_relative_relocations += l->l_info[VERSYMIDX (DT_RELCOUNT)]->d_un.d_val;
+      if (l->l_info[VERSYMIDX (DT_RELACOUNT)])
+	num_relative_relocations += l->l_info[VERSYMIDX (DT_RELACOUNT)]->d_un.d_val;
+    }
+
   INTUSE(_dl_debug_printf) ("                 number of relocations: %lu\n",
 			    GL(dl_num_relocations));
   INTUSE(_dl_debug_printf) ("      number of relocations from cache: %lu\n",
 			    GL(dl_num_cache_relocations));
+  INTUSE(_dl_debug_printf) ("        number of relative relocations: %lu\n",
+			    num_relative_relocations);
 
 #ifndef HP_TIMING_NONAVAIL
   /* Time spend while loading the object and the dependencies.  */

	Jakub


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