From ab8d58e25af7a41bdd08ffe26017783064f30797 Mon Sep 17 00:00:00 2001 From: GNU Libc Maintainers Date: Tue, 4 Aug 2020 16:02:38 +0100 Subject: [PATCH] submitted-ld.so-cache-new-format 2018-09-16 Josh Triplett * 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 | 16 ++++++++-------- elf/ldconfig.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/elf/dl-cache.c b/elf/dl-cache.c index 9ed21579f..a1a94c3d7 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -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) diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 0da7fcc90..76d8c9386 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -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 } }; -- 2.30.2