submitted-ld.so-cache-new-format
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Wed, 16 Dec 2020 21:33:25 +0000 (21:33 +0000)
committerSamuel Thibault <sthibault@debian.org>
Wed, 16 Dec 2020 21:33:25 +0000 (21:33 +0000)
2018-09-16  Josh Triplett  <josh@joshtriplett.org>

        * elf/ldconfig.c: Default to the new format for ld.so.cache. glibc has
        supported this format for 18+ years.
        * elf/dl-cache.c (_dl_load_cache_lookup): Reorder conditionals to look
        for the new format first.

Gbp-Pq: Topic any
Gbp-Pq: Name submitted-ld.so-cache-new-format.diff

elf/dl-cache.c
elf/ldconfig.c

index 9ed21579f028034d348630a29496e8fb50e0d8c9..a1a94c3d70ffdecc95668443e23bb115df32e560 100644 (file)
@@ -206,7 +206,14 @@ _dl_load_cache_lookup (const char *name)
         - the old format with the new format in it
         - only the new format
         The following checks if the cache contains any of these formats.  */
-      if (file != MAP_FAILED && cachesize > sizeof *cache
+      if (file != MAP_FAILED && cachesize > sizeof *cache_new
+              && memcmp (file, CACHEMAGIC_VERSION_NEW,
+                         sizeof CACHEMAGIC_VERSION_NEW - 1) == 0)
+       {
+         cache_new = file;
+         cache = file;
+       }
+      else if (file != MAP_FAILED && cachesize > sizeof *cache
          && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0
          /* Check for corruption, avoiding overflow.  */
          && ((cachesize - sizeof *cache) / sizeof (struct file_entry)
@@ -226,13 +233,6 @@ _dl_load_cache_lookup (const char *name)
                         sizeof CACHEMAGIC_VERSION_NEW - 1) != 0)
            cache_new = (void *) -1;
        }
-      else if (file != MAP_FAILED && cachesize > sizeof *cache_new
-              && memcmp (file, CACHEMAGIC_VERSION_NEW,
-                         sizeof CACHEMAGIC_VERSION_NEW - 1) == 0)
-       {
-         cache_new = file;
-         cache = file;
-       }
       else
        {
          if (file != MAP_FAILED)
index 0da7fcc90308052328f07b6b16fcd0fbe44e1157..76d8c938634b69945a5926824c6931513c72efdb 100644 (file)
@@ -110,7 +110,7 @@ int opt_verbose;
 
 /* Format to support.  */
 /* 0: only libc5/glibc2; 1: both; 2: only glibc 2.2.  */
-int opt_format = 1;
+int opt_format = 2;
 
 /* Build cache.  */
 static int opt_build_cache = 1;
@@ -163,7 +163,7 @@ static const struct argp_option options[] =
   { NULL, 'f', N_("CONF"), 0, N_("Use CONF as configuration file"), 0},
   { NULL, 'n', NULL, 0, N_("Only process directories specified on the command line.  Don't build cache."), 0},
   { NULL, 'l', NULL, 0, N_("Manually link individual libraries."), 0},
-  { "format", 'c', N_("FORMAT"), 0, N_("Format to use: new, old or compat (default)"), 0},
+  { "format", 'c', N_("FORMAT"), 0, N_("Format to use: new (default), old, or compat"), 0},
   { "ignore-aux-cache", 'i', NULL, 0, N_("Ignore auxiliary cache file"), 0},
   { NULL, 0, NULL, 0, NULL, 0 }
 };