submitted-ld.so-cache-new-format
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 5 May 2020 18:12:38 +0000 (19:12 +0100)
committerAurelien Jarno <aurel32@debian.org>
Tue, 5 May 2020 18:12:38 +0000 (19:12 +0100)
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 2ade100bba54a269e3c7bb60b84081c9d7bd95cc..1b1002152232a607f19117016a6f8c5d5276e417 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 a97490cf97888087ef8d5beb91f7aea8a31c3c3b..e3126789d9a789ae250b8e19f6896f20187cb30b 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 }
 };