diff options
author | maxim <maxim@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-02-04 21:06:08 +0000 |
---|---|---|
committer | maxim <maxim@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-02-04 21:06:08 +0000 |
commit | 3b289e20aa9fa02a85745547a976b824bc66d096 (patch) | |
tree | 9bde0ec3a8d33032b03b3534294ac6d2845877b2 | |
parent | 289bec6245a7b25a42667894cbad32312f3ee4d2 (diff) | |
download | eglibc2-3b289e20aa9fa02a85745547a976b824bc66d096.tar.gz |
EGLIBC_RTLD_DEBUG option group
* option-groups.def (OPTION_EGLIBC_RTLD_DEBUG): Define new option
group.
* option-groups.defaults: Set the default.
* sysdeps/generic/ldsodefs.h (GLRO_dl_debug_mask): Define to either
`GLRO(dl_debug_mask)' or to `0' depending on RTLD_DEBUG option group.
(_dl_debug_mask): Declare only if RTLD_DEBUG is enabled.
* elf/dl-support.c (_dl_debug_mask): Define only if RTLD_DEBUG is
enabled.
* elf/rtld.c: Replace GLRO(dl_debug_mask) with GLRO_dl_debug_mask
throughout the file.
(process_dl_debug): Compile only if RTLD_DEBUG is enabled.
(process_envvars): Update.
* csu/libc-start.c, elf/dl-cache.c, elf/dl-close.c, elf/dl-conflict.c,
* elf/dl-deps.c, elf/dl-error.c, elf/dl-fini.c, elf/dl-init.c,
* elf/dl-load.c, elf/dl-lookup.c, elf/dl-object.c, elf/dl-open.c,
* elf/dl-reloc.c, elf/dl-version.c: Replace GLRO(dl_debug_mask) with
GLRO_dl_debug_mask throughout the file.
git-svn-id: svn://svn.eglibc.org/trunk@9803 7b3dc134-2b1b-0410-93df-9e9f96275f8d
-rw-r--r-- | libc/ChangeLog.eglibc | 22 | ||||
-rw-r--r-- | libc/csu/libc-start.c | 4 | ||||
-rw-r--r-- | libc/elf/dl-cache.c | 4 | ||||
-rw-r--r-- | libc/elf/dl-close.c | 6 | ||||
-rw-r--r-- | libc/elf/dl-conflict.c | 2 | ||||
-rw-r--r-- | libc/elf/dl-deps.c | 8 | ||||
-rw-r--r-- | libc/elf/dl-error.c | 2 | ||||
-rw-r--r-- | libc/elf/dl-fini.c | 4 | ||||
-rw-r--r-- | libc/elf/dl-init.c | 4 | ||||
-rw-r--r-- | libc/elf/dl-load.c | 16 | ||||
-rw-r--r-- | libc/elf/dl-lookup.c | 10 | ||||
-rw-r--r-- | libc/elf/dl-object.c | 2 | ||||
-rw-r--r-- | libc/elf/dl-open.c | 4 | ||||
-rw-r--r-- | libc/elf/dl-reloc.c | 2 | ||||
-rw-r--r-- | libc/elf/dl-support.c | 2 | ||||
-rw-r--r-- | libc/elf/dl-version.c | 2 | ||||
-rw-r--r-- | libc/elf/rtld.c | 28 | ||||
-rw-r--r-- | libc/option-groups.def | 11 | ||||
-rw-r--r-- | libc/option-groups.defaults | 1 | ||||
-rw-r--r-- | libc/sysdeps/generic/ldsodefs.h | 8 |
20 files changed, 98 insertions, 44 deletions
diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc index 4d51eb4c6..716992ca3 100644 --- a/libc/ChangeLog.eglibc +++ b/libc/ChangeLog.eglibc @@ -1,3 +1,25 @@ +2010-02-04 Maxim Kuvyrkov <maxim@codesourcery.com> + + EGLIBC_RTLD_DEBUG option group + + * option-groups.def (OPTION_EGLIBC_RTLD_DEBUG): Define new option + group. + * option-groups.defaults: Set the default. + * sysdeps/generic/ldsodefs.h (GLRO_dl_debug_mask): Define to either + `GLRO(dl_debug_mask)' or to `0' depending on RTLD_DEBUG option group. + (_dl_debug_mask): Declare only if RTLD_DEBUG is enabled. + * elf/dl-support.c (_dl_debug_mask): Define only if RTLD_DEBUG is + enabled. + * elf/rtld.c: Replace GLRO(dl_debug_mask) with GLRO_dl_debug_mask + throughout the file. + (process_dl_debug): Compile only if RTLD_DEBUG is enabled. + (process_envvars): Update. + * csu/libc-start.c, elf/dl-cache.c, elf/dl-close.c, elf/dl-conflict.c, + * elf/dl-deps.c, elf/dl-error.c, elf/dl-fini.c, elf/dl-init.c, + * elf/dl-load.c, elf/dl-lookup.c, elf/dl-object.c, elf/dl-open.c, + * elf/dl-reloc.c, elf/dl-version.c: Replace GLRO(dl_debug_mask) with + GLRO_dl_debug_mask throughout the file. + 2009-11-20 Jakub Jelinek <jakub@redhat.com> PR libc/10103 diff --git a/libc/csu/libc-start.c b/libc/csu/libc-start.c index dc7ca55f0..9c068659d 100644 --- a/libc/csu/libc-start.c +++ b/libc/csu/libc-start.c @@ -178,7 +178,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), /* Call the initializer of the program, if any. */ #ifdef SHARED - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]); #endif if (init) @@ -201,7 +201,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), #endif #ifdef SHARED - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) GLRO(dl_debug_printf) ("\ntransferring control: %s\n\n", argv[0]); #endif diff --git a/libc/elf/dl-cache.c b/libc/elf/dl-cache.c index bbeba77e4..0961ee69f 100644 --- a/libc/elf/dl-cache.c +++ b/libc/elf/dl-cache.c @@ -187,7 +187,7 @@ _dl_load_cache_lookup (const char *name) const char *best; /* Print a message if the loading of libs is traced. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE); if (cache == NULL) @@ -283,7 +283,7 @@ _dl_load_cache_lookup (const char *name) } /* Print our result if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0) && best != NULL) _dl_debug_printf (" trying file=%s\n", best); diff --git a/libc/elf/dl-close.c b/libc/elf/dl-close.c index 865adce40..3d14dbe41 100644 --- a/libc/elf/dl-close.c +++ b/libc/elf/dl-close.c @@ -123,7 +123,7 @@ _dl_close_worker (struct link_map *map) dl_close_state = rerun; /* There are still references to this object. Do nothing more. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) _dl_debug_printf ("\nclosing file=%s; direct_opencount=%u\n", map->l_name, map->l_direct_opencount); @@ -249,7 +249,7 @@ _dl_close_worker (struct link_map *map) if (imap->l_init_called) { /* When debugging print a message first. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) _dl_debug_printf ("\ncalling fini: %s [%lu]\n\n", imap->l_name, nsid); @@ -628,7 +628,7 @@ _dl_close_worker (struct link_map *map) free (imap->l_reldeps); /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) _dl_debug_printf ("\nfile=%s [%lu]; destroying link map\n", imap->l_name, imap->l_ns); diff --git a/libc/elf/dl-conflict.c b/libc/elf/dl-conflict.c index b73010562..a01e2a9a7 100644 --- a/libc/elf/dl-conflict.c +++ b/libc/elf/dl-conflict.c @@ -33,7 +33,7 @@ _dl_resolve_conflicts (struct link_map *l, ElfW(Rela) *conflict, ElfW(Rela) *conflictend) { #if ! ELF_MACHINE_NO_RELA - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_RELOC, 0)) _dl_debug_printf ("\nconflict processing: %s\n", l->l_name[0] ? l->l_name : rtld_progname); diff --git a/libc/elf/dl-deps.c b/libc/elf/dl-deps.c index 34c6024ef..ba6cd04ee 100644 --- a/libc/elf/dl-deps.c +++ b/libc/elf/dl-deps.c @@ -129,7 +129,7 @@ empty dynamic string token substitution")); \ else \ { \ /* This is for DT_AUXILIARY. */ \ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0))\ + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))\ _dl_debug_printf (N_("\ cannot load auxiliary `%s' because of empty dynamic string token " \ "substitution\n"), __str); \ @@ -298,7 +298,7 @@ _dl_map_object_deps (struct link_map *map, if (d->d_tag == DT_AUXILIARY) { /* Say that we are about to load an auxiliary library. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf ("load auxiliary object=%s" " requested by file=%s\n", @@ -325,7 +325,7 @@ _dl_map_object_deps (struct link_map *map, else { /* Say that we are about to load an auxiliary library. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf ("load filtered object=%s" " requested by file=%s\n", @@ -526,7 +526,7 @@ _dl_map_object_deps (struct link_map *map, runp->map->l_reserved = 0; } - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK, 0) != 0 + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_PRELINK, 0) != 0 && map == GL(dl_ns)[LM_ID_BASE]._ns_loaded) { /* If we are to compute conflicts, we have to build local scope diff --git a/libc/elf/dl-error.c b/libc/elf/dl-error.c index 79ebaaf01..a65e286b2 100644 --- a/libc/elf/dl-error.c +++ b/libc/elf/dl-error.c @@ -136,7 +136,7 @@ internal_function _dl_signal_cerror (int errcode, const char *objname, const char *occation, const char *errstring) { - if (__builtin_expect (GLRO(dl_debug_mask) + if (__builtin_expect (GLRO_dl_debug_mask & ~(DL_DEBUG_STATISTICS|DL_DEBUG_PRELINK), 0)) _dl_debug_printf ("%s: error: %s: %s (%s)\n", objname, occation, errstring, receiver ? "continued" : "fatal"); diff --git a/libc/elf/dl-fini.c b/libc/elf/dl-fini.c index ff4c33e80..dfd55c9da 100644 --- a/libc/elf/dl-fini.c +++ b/libc/elf/dl-fini.c @@ -225,7 +225,7 @@ _dl_fini (void) || l->l_info[DT_FINI] != NULL) { /* When debugging print a message first. */ - if (__builtin_expect (GLRO(dl_debug_mask) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) _dl_debug_printf ("\ncalling fini: %s [%lu]\n\n", l->l_name[0] ? l->l_name : rtld_progname, @@ -277,7 +277,7 @@ _dl_fini (void) goto again; } - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_STATISTICS, 0)) _dl_debug_printf ("\nruntime linker statistics:\n" " final number of relocations: %lu\n" "final number of relocations from cache: %lu\n", diff --git a/libc/elf/dl-init.c b/libc/elf/dl-init.c index e7b67570f..e4d701ace 100644 --- a/libc/elf/dl-init.c +++ b/libc/elf/dl-init.c @@ -53,7 +53,7 @@ call_init (struct link_map *l, int argc, char **argv, char **env) return; /* Print a debug message if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) _dl_debug_printf ("\ncalling init: %s\n\n", l->l_name[0] ? l->l_name : rtld_progname); @@ -109,7 +109,7 @@ _dl_init (struct link_map *main_map, int argc, char **argv, char **env) ElfW(Addr) *addrs; unsigned int cnt; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_IMPCALLS, 0)) _dl_debug_printf ("\ncalling preinit: %s\n\n", main_map->l_name[0] ? main_map->l_name : rtld_progname); diff --git a/libc/elf/dl-load.c b/libc/elf/dl-load.c index 597193c04..0fa3dca56 100644 --- a/libc/elf/dl-load.c +++ b/libc/elf/dl-load.c @@ -911,7 +911,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } /* Print debugging message. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) _dl_debug_printf ("file=%s [%lu]; generating link map\n", name, nsid); /* This is the ELF header. We read it in `open_verify'. */ @@ -1440,7 +1440,7 @@ cannot enable executable stack as shared object requires"); l->l_entry += l->l_addr; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) _dl_debug_printf ("\ dynamic: 0x%0*lx base: 0x%0*lx size: 0x%0*Zx\n\ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u\n\n", @@ -1830,7 +1830,7 @@ open_path (const char *name, size_t namelen, int preloaded, /* If we are debugging the search for libraries print the path now if it hasn't happened now. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0) && current_what != this_dir->what) { current_what = this_dir->what; @@ -1851,7 +1851,7 @@ open_path (const char *name, size_t namelen, int preloaded, - buf); /* Print name we try if this is wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf (" trying file=%s\n", buf); fd = open_verify (buf, fbp, loader, whatcode, found_other_class, @@ -1997,7 +1997,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, } /* Display information if we are debugging. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0) && loader != NULL) _dl_debug_printf ("\nfile=%s [%lu]; needed by %s [%lu]\n", name, nsid, loader->l_name[0] @@ -2038,7 +2038,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, size_t namelen = strlen (name) + 1; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf ("find library=%s [%lu]; searching\n", name, nsid); fd = -1; @@ -2163,7 +2163,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, &realname, &fb, l, LA_SER_DEFAULT, &found_other_class); /* Add another newline when we are tracing the library loading. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf ("\n"); } else @@ -2196,7 +2196,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded, if (__builtin_expect (fd, 0) == -1) { if (trace_mode - && __builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK, 0) == 0) + && __builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_PRELINK, 0) == 0) { /* We haven't found an appropriate library. But since we are only interested in the list of libraries this isn't diff --git a/libc/elf/dl-lookup.c b/libc/elf/dl-lookup.c index 763ec16fa..c350f16ef 100644 --- a/libc/elf/dl-lookup.c +++ b/libc/elf/dl-lookup.c @@ -110,7 +110,7 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash, continue; /* Print some debugging info if wanted. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_SYMBOLS, 0)) _dl_debug_printf ("symbol=%s; lookup in file=%s [%lu]\n", undef_name, map->l_name[0] ? map->l_name : rtld_progname, @@ -646,7 +646,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map, int flags) } /* Display information if we are debugging. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0)) _dl_debug_printf ("\ \nfile=%s [%lu]; needed by %s [%lu] (relocation dependency)\n\n", map->l_name[0] ? map->l_name : rtld_progname, @@ -825,7 +825,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, if (__builtin_expect (current_value.m->l_used == 0, 0)) current_value.m->l_used = 1; - if (__builtin_expect (GLRO(dl_debug_mask) + if (__builtin_expect (GLRO_dl_debug_mask & (DL_DEBUG_BINDINGS|DL_DEBUG_PRELINK), 0)) _dl_debug_bindings (undef_name, undef_map, ref, ¤t_value, version, type_class, protected); @@ -890,7 +890,7 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, { const char *reference_name = undef_map->l_name; - if (GLRO(dl_debug_mask) & DL_DEBUG_BINDINGS) + if (GLRO_dl_debug_mask & DL_DEBUG_BINDINGS) { _dl_debug_printf ("binding file %s [%lu] to %s [%lu]: %s symbol `%s'", (reference_name[0] @@ -906,7 +906,7 @@ _dl_debug_bindings (const char *undef_name, struct link_map *undef_map, _dl_debug_printf_c ("\n"); } #ifdef SHARED - if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) + if (GLRO_dl_debug_mask & DL_DEBUG_PRELINK) { int conflict = 0; struct sym_val val = { NULL, NULL }; diff --git a/libc/elf/dl-object.c b/libc/elf/dl-object.c index 788e2c07b..d3517cecf 100644 --- a/libc/elf/dl-object.c +++ b/libc/elf/dl-object.c @@ -69,7 +69,7 @@ _dl_new_object (char *realname, const char *libname, int type, new->l_type = type; /* If we set the bit now since we know it is never used we avoid dirtying the cache line later. */ - if ((GLRO(dl_debug_mask) & DL_DEBUG_UNUSED) == 0) + if ((GLRO_dl_debug_mask & DL_DEBUG_UNUSED) == 0) new->l_used = 1; new->l_loader = loader; #if NO_TLS_OFFSET != 0 diff --git a/libc/elf/dl-open.c b/libc/elf/dl-open.c index 754a263fa..610ceaedb 100644 --- a/libc/elf/dl-open.c +++ b/libc/elf/dl-open.c @@ -274,7 +274,7 @@ dl_open_worker (void *a) if (__builtin_expect (new->l_searchlist.r_list != NULL, 0)) { /* Let the user know about the opencount. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + 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); @@ -511,7 +511,7 @@ TLS generation counter wrapped! Please report this.")); #endif /* Let the user know about the opencount. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) + 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); } diff --git a/libc/elf/dl-reloc.c b/libc/elf/dl-reloc.c index 206e81503..2754791eb 100644 --- a/libc/elf/dl-reloc.c +++ b/libc/elf/dl-reloc.c @@ -186,7 +186,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], && __builtin_expect (l->l_info[DT_BIND_NOW] != NULL, 0)) lazy = 0; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_RELOC, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_RELOC, 0)) _dl_debug_printf ("\nrelocation processing: %s%s\n", l->l_name[0] ? l->l_name : rtld_progname, lazy ? " (lazy)" : ""); diff --git a/libc/elf/dl-support.c b/libc/elf/dl-support.c index bcf0e2a56..a9b307d1f 100644 --- a/libc/elf/dl-support.c +++ b/libc/elf/dl-support.c @@ -40,7 +40,9 @@ char **_dl_argv = &__progname; /* This is checked for some error messages. */ const char *_dl_platform; size_t _dl_platformlen; +#if __OPTION_EGLIBC_RTLD_DEBUG int _dl_debug_mask; +#endif int _dl_lazy; ElfW(Addr) _dl_use_load_bias = -2; int _dl_dynamic_weak; diff --git a/libc/elf/dl-version.c b/libc/elf/dl-version.c index 9e881162a..51a940c83 100644 --- a/libc/elf/dl-version.c +++ b/libc/elf/dl-version.c @@ -88,7 +88,7 @@ match_symbol (const char *name, Lmid_t ns, ElfW(Word) hash, const char *string, int result = 0; /* Display information about what we are doing while debugging. */ - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_VERSIONS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_VERSIONS, 0)) _dl_debug_printf ("\ checking for version `%s' in file %s [%lu] required by file %s [%lu]\n", string, map->l_name[0] ? map->l_name : rtld_progname, diff --git a/libc/elf/rtld.c b/libc/elf/rtld.c index 3afb997f8..0ee0e4359 100644 --- a/libc/elf/rtld.c +++ b/libc/elf/rtld.c @@ -346,7 +346,7 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) } #endif - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_STATISTICS, 0)) { #ifndef HP_TIMING_NONAVAIL print_statistics (&rtld_total_time); @@ -1888,7 +1888,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", after relocation. */ struct link_map *l; - if (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) + if (GLRO_dl_debug_mask & DL_DEBUG_PRELINK) { struct r_scope_elem *scope = &main_map->l_searchlist; @@ -1920,7 +1920,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", _dl_printf ("\n"); } } - else if (GLRO(dl_debug_mask) & DL_DEBUG_UNUSED) + else if (GLRO_dl_debug_mask & DL_DEBUG_UNUSED) { /* Look through the dependencies of the main executable and determine which of them is not actually @@ -2024,7 +2024,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", } while (l != NULL); - if ((GLRO(dl_debug_mask) & DL_DEBUG_PRELINK) + if ((GLRO_dl_debug_mask & DL_DEBUG_PRELINK) && rtld_multiple_ref) { /* Mark the link map as not yet relocated again. */ @@ -2158,7 +2158,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (r_list == r_listend && liblist == liblistend) prelinked = true; - if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0)) + if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)) _dl_debug_printf ("\nprelink checking: %s\n", prelinked ? "ok" : "failed"); } @@ -2377,6 +2377,7 @@ print_missing_version (int errcode __attribute__ ((unused)), objname, errstring); } +#if __OPTION_EGLIBC_RTLD_DEBUG /* Nonzero if any of the debugging options is enabled. */ static int any_debug attribute_relro; @@ -2436,7 +2437,7 @@ process_dl_debug (const char *dl_debug) if (debopts[cnt].len == len && memcmp (dl_debug, debopts[cnt].name, len) == 0) { - GLRO(dl_debug_mask) |= debopts[cnt].mask; + GLRO_dl_debug_mask |= debopts[cnt].mask; any_debug = 1; break; } @@ -2457,7 +2458,7 @@ warning: debug option `%s' unknown; try LD_DEBUG=help\n", copy); ++dl_debug; } - if (GLRO(dl_debug_mask) & DL_DEBUG_HELP) + if (GLRO_dl_debug_mask & DL_DEBUG_HELP) { size_t cnt; @@ -2475,6 +2476,7 @@ a filename can be specified using the LD_DEBUG_OUTPUT environment variable.\n"); _exit (0); } } +#endif /* __OPTION_EGLIBC_RTLD_DEBUG */ static void process_dl_audit (char *str) @@ -2542,12 +2544,14 @@ process_envvars (enum mode *modep) break; case 5: +#if __OPTION_EGLIBC_RTLD_DEBUG /* Debugging of the dynamic linker? */ if (memcmp (envline, "DEBUG", 5) == 0) { process_dl_debug (&envline[6]); break; } +#endif if (memcmp (envline, "AUDIT", 5) == 0) process_dl_audit (&envline[6]); break; @@ -2656,7 +2660,9 @@ process_envvars (enum mode *modep) { mode = trace; GLRO(dl_verbose) = 1; - GLRO(dl_debug_mask) |= DL_DEBUG_PRELINK; +#if __OPTION_EGLIBC_RTLD_DEBUG + GLRO_dl_debug_mask |= DL_DEBUG_PRELINK; +#endif GLRO(dl_trace_prelink) = &envline[17]; } break; @@ -2703,12 +2709,15 @@ process_envvars (enum mode *modep) if (__access ("/etc/suid-debug", F_OK) != 0) { unsetenv ("MALLOC_CHECK_"); - GLRO(dl_debug_mask) = 0; +#if __OPTION_EGLIBC_RTLD_DEBUG + GLRO_dl_debug_mask = 0; +#endif } if (mode != normal) _exit (5); } +#if __OPTION_EGLIBC_RTLD_DEBUG /* If we have to run the dynamic linker in debugging mode and the LD_DEBUG_OUTPUT environment variable is given, we write the debug messages to this file. */ @@ -2733,6 +2742,7 @@ process_envvars (enum mode *modep) /* We use standard output if opening the file failed. */ GLRO(dl_debug_fd) = STDOUT_FILENO; } +#endif /* __OPTION_EGLIBC_RTLD_DEBUG */ } diff --git a/libc/option-groups.def b/libc/option-groups.def index 08115f3e5..5b278791e 100644 --- a/libc/option-groups.def +++ b/libc/option-groups.def @@ -635,6 +635,17 @@ config OPTION_EGLIBC_RCMD rresvport ruserpass rresvport_af +config OPTION_EGLIBC_RTLD_DEBUG + bool "Runtime linker debug print outs" + help + This option group enables debug output of the runtime linker + which is activated via LD_DEBUG and LD_TRACE_PRELINKING + environment variables. Disabling this option group yields + a smaller runtime linker binary. + BEWARE: Disabling this option group is likely to break + the `ldd' utility which may also be used by the prelinker. + In particular, the `--unused' ldd option will not work correctly. + config OPTION_EGLIBC_SPAWN bool "Support for POSIX posix_spawn functions" help diff --git a/libc/option-groups.defaults b/libc/option-groups.defaults index b188b158f..588fb50c7 100644 --- a/libc/option-groups.defaults +++ b/libc/option-groups.defaults @@ -35,6 +35,7 @@ OPTION_EGLIBC_MEMUSAGE = y OPTION_EGLIBC_NIS = y OPTION_EGLIBC_NSSWITCH = y OPTION_EGLIBC_RCMD = y +OPTION_EGLIBC_RTLD_DEBUG = y OPTION_EGLIBC_SPAWN = y OPTION_EGLIBC_STREAMS = y OPTION_EGLIBC_SUNRPC = y diff --git a/libc/sysdeps/generic/ldsodefs.h b/libc/sysdeps/generic/ldsodefs.h index 230c39a63..f6dedc49b 100644 --- a/libc/sysdeps/generic/ldsodefs.h +++ b/libc/sysdeps/generic/ldsodefs.h @@ -529,6 +529,12 @@ extern struct rtld_global _rtld_global __rtld_global_attribute__; # undef __rtld_global_attribute__ #endif +#if __OPTION_EGLIBC_RTLD_DEBUG +# define GLRO_dl_debug_mask GLRO(dl_debug_mask) +#else +# define GLRO_dl_debug_mask 0 +#endif + #ifndef SHARED # define GLRO(name) _##name #else @@ -541,8 +547,10 @@ struct rtld_global_ro { #endif +#if __OPTION_EGLIBC_RTLD_DEBUG /* If nonzero the appropriate debug information is printed. */ EXTERN int _dl_debug_mask; +#endif #define DL_DEBUG_LIBS (1 << 0) #define DL_DEBUG_IMPCALLS (1 << 1) #define DL_DEBUG_BINDINGS (1 << 2) |