Back to index

glibc  2.9
dl-cache.h
Go to the documentation of this file.
00001 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
00002    Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <stdint.h>
00021 
00022 #ifndef _DL_CACHE_DEFAULT_ID
00023 # define _DL_CACHE_DEFAULT_ID      3
00024 #endif
00025 
00026 #ifndef _dl_cache_check_flags
00027 # define _dl_cache_check_flags(flags)                   \
00028   ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
00029 #endif
00030 
00031 #ifndef LD_SO_CACHE
00032 # define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
00033 #endif
00034 
00035 #ifndef add_system_dir
00036 # define add_system_dir(dir) add_dir (dir)
00037 #endif
00038 
00039 #define CACHEMAGIC "ld.so-1.7.0"
00040 
00041 /* libc5 and glibc 2.0/2.1 use the same format.  For glibc 2.2 another
00042    format has been added in a compatible way:
00043    The beginning of the string table is used for the new table:
00044        old_magic
00045        nlibs
00046        libs[0]
00047        ...
00048        libs[nlibs-1]
00049        pad, new magic needs to be aligned
00050             - this is string[0] for the old format
00051        new magic - this is string[0] for the new format
00052        newnlibs
00053        ...
00054        newlibs[0]
00055        ...
00056        newlibs[newnlibs-1]
00057        string 1
00058        string 2
00059        ...
00060 */
00061 struct file_entry
00062 {
00063   int flags;         /* This is 1 for an ELF library.  */
00064   unsigned int key, value; /* String table indices.  */
00065 };
00066 
00067 struct cache_file
00068 {
00069   char magic[sizeof CACHEMAGIC - 1];
00070   unsigned int nlibs;
00071   struct file_entry libs[0];
00072 };
00073 
00074 #define CACHEMAGIC_NEW "glibc-ld.so.cache"
00075 #define CACHE_VERSION "1.1"
00076 #define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
00077 
00078 
00079 struct file_entry_new
00080 {
00081   int32_t flags;            /* This is 1 for an ELF library.  */
00082   uint32_t key, value;             /* String table indices.  */
00083   uint32_t osversion;              /* Required OS version.      */
00084   uint64_t hwcap;           /* Hwcap entry.       */
00085 };
00086 
00087 struct cache_file_new
00088 {
00089   char magic[sizeof CACHEMAGIC_NEW - 1];
00090   char version[sizeof CACHE_VERSION - 1];
00091   uint32_t nlibs;           /* Number of entries.  */
00092   uint32_t len_strings;            /* Size of string table. */
00093   uint32_t unused[5];              /* Leave space for future extensions
00094                                and align to 8 byte boundary.  */
00095   struct file_entry_new libs[0]; /* Entries describing libraries.  */
00096   /* After this the string table of size len_strings is found. */
00097 };
00098 
00099 /* Used to align cache_file_new.  */
00100 #define ALIGN_CACHE(addr)                        \
00101 (((addr) + __alignof__ (struct cache_file_new) -1)      \
00102  & (~(__alignof__ (struct cache_file_new) - 1)))
00103 
00104 extern int _dl_cache_libcmp (const char *p1, const char *p2)
00105      internal_function;