diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-12-04 09:13:43 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-12-04 09:16:30 +0100 |
commit | 84ba719b260551918965d0a433914de683087645 (patch) | |
tree | 2a3e5e634f104e0ef2f8592f1925955d8ce63db4 /elf/cache.c | |
parent | dad90d528259b669342757c37dedefa8577e2636 (diff) | |
download | glibc-84ba719b260551918965d0a433914de683087645.tar.gz glibc-84ba719b260551918965d0a433914de683087645.tar.xz glibc-84ba719b260551918965d0a433914de683087645.zip |
elf: Add endianness markup to ld.so.cache (bug 27008)
Use a reserved byte in the new format cache header to indicate whether the file is in little endian or big endian format. Eventually, this information could be used to provide a unified cache for qemu-user and similiar scenarios. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/cache.c')
-rw-r--r-- | elf/cache.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/elf/cache.c b/elf/cache.c index c241c17ef9..ffecbe6d82 100644 --- a/elf/cache.c +++ b/elf/cache.c @@ -152,6 +152,14 @@ print_entry (const char *lib, int flag, unsigned int osversion, printf (") => %s\n", key); } +/* Print an error and exit if the new-file cache is internally + inconsistent. */ +static void +check_new_cache (struct cache_file_new *cache) +{ + if (! cache_file_new_matches_endian (cache)) + error (EXIT_FAILURE, 0, _("Cache file has wrong endianness.\n")); +} /* Print the whole cache file, if a file contains the new cache format hidden in the old one, print the contents of the new format. */ @@ -193,6 +201,7 @@ print_cache (const char *cache_name) || memcmp (cache_new->version, CACHE_VERSION, sizeof CACHE_VERSION - 1)) error (EXIT_FAILURE, 0, _("File is not a cache file.\n")); + check_new_cache (cache_new); format = 1; /* This is where the strings start. */ cache_data = (const char *) cache_new; @@ -222,6 +231,7 @@ print_cache (const char *cache_name) && memcmp (cache_new->version, CACHE_VERSION, sizeof CACHE_VERSION - 1) == 0) { + check_new_cache (cache_new); cache_data = (const char *) cache_new; format = 1; } @@ -361,6 +371,7 @@ save_cache (const char *cache_name) file_entries_new->nlibs = cache_entry_count; file_entries_new->len_strings = total_strlen; + file_entries_new->flags = cache_file_new_flags_endian_current; } /* Pad for alignment of cache_file_new. */ |