summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2000-05-17 11:04:21 +0000
committerAndreas Jaeger <aj@suse.de>2000-05-17 11:04:21 +0000
commite25054c49c92587a07de4badfe4b7e01ceb99858 (patch)
tree1ad481eff77aa0310a5b5c664917467b450bce6c /elf
parent7626e16ceb26772b82ae4ef32e8e4b027cd79ed0 (diff)
downloadglibc-e25054c49c92587a07de4badfe4b7e01ceb99858.tar.gz
Update.
2000-05-17 Jakub Jelinek <jakub@redhat.com> * sysdeps/generic/dl-cache.h (_DL_CACHE_DEFAULT_ID): Only define if not yet defined. (_dl_cache_check_flags): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/dl-cache.h: include_next dl-cache.h. 2000-05-17 Andreas Jaeger <aj@suse.de> * manual/creature.texi (Feature Test Macros): Remove paragraph since the description is wrong. Closes PR libc/1691, reported by Geoff Clare <gwc@unisoft.com>. 2000-05-17 Andreas Jaeger <aj@suse.de> * time/test_time.args: Removed. * time/Makefile (test_time-ARGS): Added contents here instead. * posix/tstgetopt.args: Removed. * posix/Makefile (tstgetopt-ARGS): Added contents here instead. * Rules: Allow arguments for test files to be specified in Makefile with testname-ARGS; remove rules with .args in it. * dirent/Makefile (opendir-tst1-ARGS): Use this for opendir-tst1, remove old bogus rule for opendir-tst1.args. * stdlib/test-canon.c: Rewrite to use test-skeleton.c. * stdlib/Makefile (test-canon-ARGS): New, supply argument to chdir into objdir. This allows a readonly sourcetree. Reported by lrgallardo@yahoo.com, closes PR libc/1421. 2000-05-16 Andreas Jaeger <aj@suse.de>, David Huggins-Daines <dhd@linuxcare.com> * sysdeps/generic/dl-cache.c (_dl_load_cache_lookup): Set cache_data in case of only new cache format correctly. * sysdeps/generic/dl-cache.c (_dl_load_cache_lookup): Align struct cache_file_new. * sysdeps/generic/dl-cache.h (ALIGN_CACHE): New macro to align struct cache_file_new. * elf/cache.c (save_cache): Fix str_offset if only new cache is present. * elf/cache.c (save_cache): Align struct new_file_cache. (print_cache): Likewise.
Diffstat (limited to 'elf')
-rw-r--r--elf/cache.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/elf/cache.c b/elf/cache.c
index fbbc426268..08cb5f373b 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -49,7 +49,6 @@ static struct cache_entry *entries;
static const char *flag_descr[] =
{ "libc4", "ELF", "libc5", "libc6"};
-
/* Print a single entry. */
static void
print_entry (const char *lib, int flag, unsigned long int hwcap, const char *key)
@@ -130,25 +129,29 @@ print_cache (const char *cache_name)
error (EXIT_FAILURE, 0, _("File is not a cache file.\n"));
format = 1;
/* This is where the strings start. */
- cache_data = (const char *) cache;
+ cache_data = (const char *) cache_new;
}
else
{
+ size_t offset = ALIGN_CACHE (sizeof (struct cache_file)
+ + cache->nlibs * sizeof (struct file_entry));
/* This is where the strings start. */
cache_data = (const char *) &cache->libs[cache->nlibs];
/* Check for a new cache embedded in the old format. */
if (cache_size >
- (sizeof (struct cache_file)
- + cache->nlibs * sizeof (struct file_entry)
- + sizeof (struct cache_file_new)))
+ (offset + sizeof (struct cache_file_new)))
{
- cache_new = (struct cache_file_new *) cache_data;
+
+ cache_new = (struct cache_file_new *) ((void *)cache + offset);
if (!memcmp (cache_new->magic, CACHEMAGIC_NEW, sizeof CACHEMAGIC_NEW - 1)
&& !memcmp (cache_new->version, CACHE_VERSION,
sizeof CACHE_VERSION - 1))
- format = 1;
+ {
+ cache_data = (const char *) cache_new;
+ format = 1;
+ }
}
}
@@ -230,6 +233,8 @@ save_cache (const char *cache_name)
int cache_entry_count = 0;
/* Number of normal cache entries. */
int cache_entry_old_count = 0;
+ /* Pad for alignment of cache_file_new. */
+ size_t pad;
/* The cache entries are sorted already, save them in this order. */
@@ -280,11 +285,13 @@ save_cache (const char *cache_name)
file_entries_new->nlibs = cache_entry_count;
file_entries_new->len_strings = total_strlen;
}
-
+
+ pad = ALIGN_CACHE (file_entries_size) - file_entries_size;
+
/* If we have both formats, we hide the new format in the strings
table, we have to adjust all string indices for this so that
old libc5/glibc 2 dynamic linkers just ignore them. */
- if (opt_format == 1)
+ if (opt_format != 0)
str_offset = file_entries_new_size;
else
str_offset = 0;
@@ -298,7 +305,7 @@ save_cache (const char *cache_name)
{
file_entries->libs[idx_old].flags = entry->flags;
/* XXX: Actually we can optimize here and remove duplicates. */
- file_entries->libs[idx_old].key = str_offset;
+ file_entries->libs[idx_old].key = str_offset + pad;
}
if (opt_format != 0)
{
@@ -317,7 +324,7 @@ save_cache (const char *cache_name)
str_offset += len + 1;
/* Then the path. */
if (opt_format != 2)
- file_entries->libs[idx_old].value = str_offset;
+ file_entries->libs[idx_old].value = str_offset + pad;
if (opt_format != 0)
file_entries_new->libs[idx_new].value = str_offset;
len = strlen (entry->path);
@@ -354,6 +361,13 @@ save_cache (const char *cache_name)
}
if (opt_format != 0)
{
+ /* Align cache. */
+ if (opt_format != 2)
+ {
+ char zero [pad];
+ if (write (fd, zero, pad) != (ssize_t)pad)
+ error (EXIT_FAILURE, errno, _("Writing of cache data failed"));
+ }
if (write (fd, file_entries_new, file_entries_new_size)
!= (ssize_t)file_entries_new_size)
error (EXIT_FAILURE, errno, _("Writing of cache data failed"));