2011-08-13 Ulrich Drepper <drepper@gmail.com>
+ * elf/dl-open.c: Rename show_scope to _dl_schow_scope and export.
+ (dl_open_worker): Call _dl_show_scope when DL_DEBUG_SCOPES is set.
+ * elf/rtld.c (dl_main): Set l_name of vDSO.
+ Call _dl_show_scope when DL_DEBUG_SCOPES.
+ (process_dl_debug): Recognize scopes flag and also set it for all.
+ * sysdeps/generic/ldsodefs.h: Define DL_DEBUG_SCOPES.
+ Declare _dl_show_scope.
+
* elf/dl-libc.c (do_dlopen_args): Add caller_dlopen.
(do_dlopen): Pass caller_dlopen to dl_open.
(__libc_dlopen_mode): Initialize caller_dlopen.
extern int __libc_multiple_libcs; /* Defined in init-first.c. */
-/* Undefine the following for debugging. */
-/* #define SCOPE_DEBUG 1 */
-#ifdef SCOPE_DEBUG
-static void show_scope (struct link_map *new);
-#endif
-
/* We must be carefull not to leave us in an inconsistent state. Thus we
catch any error and re-raise it after cleaning up. */
(void) _dl_check_map_versions (new->l_searchlist.r_list[i]->l_real,
0, 0);
-#ifdef SCOPE_DEBUG
- show_scope (new);
-#endif
-
#ifdef SHARED
/* Auditing checkpoint: we have added all objects. */
if (__builtin_expect (GLRO(dl_naudit) > 0, 0))
imap->l_scope[cnt + 1] = NULL;
atomic_write_barrier ();
imap->l_scope[cnt] = &new->l_searchlist;
+
+ /* Print scope information. */
+ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0))
+ _dl_show_scope (imap);
}
/* Only add TLS memory if this object is loaded now and
therefore is not yet initialized. */
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
_dl_debug_printf ("opening file=%s [%lu]; direct_opencount=%u\n\n",
new->l_name, new->l_ns, new->l_direct_opencount);
+
+ /* Print scope information. */
+ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0))
+ _dl_show_scope (new);
}
}
-#ifdef SCOPE_DEBUG
-#include <unistd.h>
-
-static void
-show_scope (struct link_map *new)
+void
+_dl_show_scope (struct link_map *l)
{
- int scope_cnt;
-
- for (scope_cnt = 0; new->l_scope[scope_cnt] != NULL; ++scope_cnt)
- {
- char numbuf[2];
- unsigned int cnt;
-
- numbuf[0] = '0' + scope_cnt;
- numbuf[1] = '\0';
- _dl_printf ("scope %s:", numbuf);
-
- for (cnt = 0; cnt < new->l_scope[scope_cnt]->r_nlist; ++cnt)
- if (*new->l_scope[scope_cnt]->r_list[cnt]->l_name)
- _dl_printf (" %s", new->l_scope[scope_cnt]->r_list[cnt]->l_name);
- else
- _dl_printf (" <main>");
+ _dl_debug_printf ("object=%s [%lu]\n",
+ *l->l_name ? l->l_name : rtld_progname, l->l_ns);
+ if (l->l_scope != NULL)
+ for (int scope_cnt = 0; l->l_scope[scope_cnt] != NULL; ++scope_cnt)
+ {
+ char numbuf[2];
+ unsigned int cnt;
+
+ numbuf[0] = '0' + scope_cnt;
+ numbuf[1] = '\0';
+ _dl_debug_printf (" scope %s:", numbuf);
+
+ for (cnt = 0; cnt < l->l_scope[scope_cnt]->r_nlist; ++cnt)
+ if (*l->l_scope[scope_cnt]->r_list[cnt]->l_name)
+ _dl_debug_printf_c (" %s",
+ l->l_scope[scope_cnt]->r_list[cnt]->l_name);
+ else
+ _dl_debug_printf_c (" %s", rtld_progname);
- _dl_printf ("\n");
- }
+ _dl_debug_printf_c ("\n");
+ }
+ _dl_debug_printf ("\n");
}
-#endif
#ifdef IS_IN_rtld
/* Return non-zero if ADDR lies within one of L's segments. */
char *copy = malloc (len);
if (copy == NULL)
_dl_fatal_printf ("out of memory\n");
- l->l_libname->name = memcpy (copy, dsoname, len);
+ l->l_name = l->l_libname->name = memcpy (copy, dsoname, len);
}
/* Add the vDSO to the object list. */
malloc will no longer be the one from dl-minimal.c. */
GLRO(dl_init_all_dirs) = GL(dl_all_dirs);
+ /* Print scope information. */
+ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES, 0))
+ {
+ _dl_debug_printf ("\nInitial object scopes\n");
+
+ for (struct link_map *l = main_map; l != NULL; l = l->l_next)
+ _dl_show_scope (l);
+ }
+
if (prelinked)
{
if (main_map->l_info [ADDRIDX (DT_GNU_CONFLICT)] != NULL)
DL_DEBUG_BINDINGS | DL_DEBUG_IMPCALLS },
{ LEN_AND_STR ("versions"), "display version dependencies",
DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
+ { LEN_AND_STR ("scopes"), "display scope information",
+ DL_DEBUG_SCOPES },
{ LEN_AND_STR ("all"), "all previous options combined",
DL_DEBUG_LIBS | DL_DEBUG_RELOC | DL_DEBUG_FILES | DL_DEBUG_SYMBOLS
- | DL_DEBUG_BINDINGS | DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS },
+ | DL_DEBUG_BINDINGS | DL_DEBUG_VERSIONS | DL_DEBUG_IMPCALLS
+ | DL_DEBUG_SCOPES },
{ LEN_AND_STR ("statistics"), "display relocation statistics",
DL_DEBUG_STATISTICS },
{ LEN_AND_STR ("unused"), "determined unused DSOs",
#define DL_DEBUG_FILES (1 << 6)
#define DL_DEBUG_STATISTICS (1 << 7)
#define DL_DEBUG_UNUSED (1 << 8)
+#define DL_DEBUG_SCOPES (1 << 9)
/* These two are used only internally. */
-#define DL_DEBUG_HELP (1 << 9)
-#define DL_DEBUG_PRELINK (1 << 10)
+#define DL_DEBUG_HELP (1 << 10)
+#define DL_DEBUG_PRELINK (1 << 11)
/* OS version. */
EXTERN unsigned int _dl_osversion;
extern int _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr)
internal_function attribute_hidden;
+/* Show show of an object. */
+extern void _dl_show_scope (struct link_map *new);
+
__END_DECLS
#endif /* ldsodefs.h */