[PATCH] Add --print-dirs option for ldconfig
Dan Nicholson
dbn.lists@gmail.com
Mon Apr 2 17:28:00 GMT 2012
On Mon, Apr 02, 2012 at 09:45:41AM -0700, Roland McGrath wrote:
> > --- a/ChangeLog
> > +++ b/ChangeLog
>
> The ChangeLog portion is not included in the diff, but the fragment
> separately as simple text in your message.
I see. I'd noticed Dave had done that and it does seem better to not
have the ChangeLog be part of the diff since it's easy to conflict. Is
there a tool you guys use to generate the ChangeLog entry for the
patch text and/or merge the entry into the actual ChangeLog when
applying patches?
> > @@ -1,3 +1,9 @@
> > +2012-03-28 Dan Nicholson <dbn.lists@gmail.com>
> > +
> > + * elf/ldconfig.c (opt_print_dirs): New option enabled with -P or
> > + --print-search-dirs.
> > + (main): Use it to print the linker search path.
>
> * elf/ldconfig.c (opt_print_dirs): New variable.
> (options, parse_opt): Add --print-search-dirs/-P to set it.
> (main): just When set, print the linker search path.
>
> But you might as well name the variable opt_print_search_dirs for
> consistency with the option name.
Makes sense. See attached update.
--
Dan
-------------- next part --------------
>From 30a15a4ae5f16b8c2bdd410f1b9def35090cd3ff Mon Sep 17 00:00:00 2001
From: Dan Nicholson <dbn.lists@gmail.com>
Date: Wed, 28 Mar 2012 09:48:32 -0700
Subject: [PATCH v3] Add --print-search-dirs option for ldconfig
In order to debug linking issues, it's often beneficial to know the
current linker path. This can be difficult since the platform's trusted
directories may not be known, and parsing the ld.so.conf entries is
error prone. Fortunately, ldconfig already does this.
Add a -P|--print-search-dirs option to ldconfig for printing the linker
search directories. Here is sample output from a Fedora 16 x86_64
system:
$ ./elf/ldconfig --print-search-dirs
/usr/lib64/llvm
/usr/lib64/tracker-0.12
/usr/lib64/xulrunner-2
/lib
/lib64
/usr/lib
/usr/lib64
2012-03-28 Dan Nicholson <dbn.lists@gmail.com>
* elf/ldconfig.c (opt_print_search_dirs): New variable.
(options, parse_opt): Add -P|--print-search-dirs to set it.
(main): When set, print the linker search path.
---
elf/ldconfig.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index aa97213..3af5bf7 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -89,6 +89,9 @@ static struct dir_entry *dir_entries;
/* Print Cache. */
static int opt_print_cache;
+/* Print search directories. */
+static int opt_print_search_dirs;
+
/* Be verbose. */
int opt_verbose;
@@ -138,6 +141,7 @@ static char *more_help (int key, const char *text, void *input);
static const struct argp_option options[] =
{
{ "print-cache", 'p', NULL, 0, N_("Print cache"), 0},
+ { "print-search-dirs", 'P', NULL, 0, N_("Print search directories"), 0},
{ "verbose", 'v', NULL, 0, N_("Generate verbose messages"), 0},
{ NULL, 'N', NULL, 0, N_("Don't build cache"), 0},
{ NULL, 'X', NULL, 0, N_("Don't generate links"), 0},
@@ -266,6 +270,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'p':
opt_print_cache = 1;
break;
+ case 'P':
+ opt_print_search_dirs = 1;
+ break;
case 'r':
opt_chroot = arg;
break;
@@ -1359,6 +1366,14 @@ main (int argc, char **argv)
add_system_dir (LIBDIR);
}
+ if (opt_print_search_dirs)
+ {
+ for (struct dir_entry *entry = dir_entries; entry != NULL;
+ entry = entry->next)
+ puts (entry->path);
+ exit (0);
+ }
+
const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE;
if (opt_chroot)
aux_cache_file = chroot_canon (opt_chroot, aux_cache_file);
--
1.7.7.6
More information about the Libc-alpha
mailing list