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]

[PATCH] Add --print-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-dirs option to ldconfig for printing the linker
search directories. Here is sample output from a Fedora 16 x86_64
system:

$ ./elf/ldconfig -P
/usr/lib64/llvm
/usr/lib64/tracker-0.12
/usr/lib64/xulrunner-2
/lib
/lib64
/usr/lib
/usr/lib64
---
 ChangeLog      |    4 ++++
 elf/ldconfig.c |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ba7b2cd..6eacf90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-28  Dan Nicholson  <dbn.lists@gmail.com>
+
+	* elf/ldconfig.c: Add option to print linker path.
+
 2012-02-22  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
 	[BZ #13760]
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index aa97213..99702ec 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_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-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_dirs = 1;
+      break;
     case 'r':
       opt_chroot = arg;
       break;
@@ -1359,6 +1366,15 @@ main (int argc, char **argv)
 	add_system_dir (LIBDIR);
     }
 
+  if (opt_print_dirs)
+    {
+      struct dir_entry *entry;
+
+      for (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


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