]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/generic/dl-cache.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / generic / dl-cache.h
CommitLineData
c41baa79 1/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
d614a753 2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
c41baa79
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
c41baa79
UD
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
c41baa79 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
c41baa79 18
a8fd59b0
AJ
19#include <stdint.h>
20
e25054c4
AJ
21#ifndef _DL_CACHE_DEFAULT_ID
22# define _DL_CACHE_DEFAULT_ID 3
23#endif
c41baa79 24
e25054c4
AJ
25#ifndef _dl_cache_check_flags
26# define _dl_cache_check_flags(flags) \
c41baa79 27 ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
e25054c4 28#endif
45eca4d1
UD
29
30#ifndef LD_SO_CACHE
8ca91b36 31# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
45eca4d1
UD
32#endif
33
bd89c0b5
UD
34#ifndef add_system_dir
35# define add_system_dir(dir) add_dir (dir)
36#endif
37
45eca4d1
UD
38#define CACHEMAGIC "ld.so-1.7.0"
39
40/* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another
41 format has been added in a compatible way:
42 The beginning of the string table is used for the new table:
e25054c4 43 old_magic
45eca4d1
UD
44 nlibs
45 libs[0]
46 ...
47 libs[nlibs-1]
e25054c4
AJ
48 pad, new magic needs to be aligned
49 - this is string[0] for the old format
50 new magic - this is string[0] for the new format
45eca4d1
UD
51 newnlibs
52 ...
53 newlibs[0]
54 ...
55 newlibs[newnlibs-1]
56 string 1
57 string 2
58 ...
59*/
60struct file_entry
61{
62 int flags; /* This is 1 for an ELF library. */
63 unsigned int key, value; /* String table indices. */
64};
65
66struct cache_file
67{
68 char magic[sizeof CACHEMAGIC - 1];
69 unsigned int nlibs;
70 struct file_entry libs[0];
71};
72
73#define CACHEMAGIC_NEW "glibc-ld.so.cache"
a8fd59b0 74#define CACHE_VERSION "1.1"
ea029468 75#define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
45eca4d1
UD
76
77
78struct file_entry_new
79{
a8fd59b0
AJ
80 int32_t flags; /* This is 1 for an ELF library. */
81 uint32_t key, value; /* String table indices. */
a986484f 82 uint32_t osversion; /* Required OS version. */
a8fd59b0 83 uint64_t hwcap; /* Hwcap entry. */
45eca4d1
UD
84};
85
86struct cache_file_new
87{
88 char magic[sizeof CACHEMAGIC_NEW - 1];
89 char version[sizeof CACHE_VERSION - 1];
a8fd59b0
AJ
90 uint32_t nlibs; /* Number of entries. */
91 uint32_t len_strings; /* Size of string table. */
92 uint32_t unused[5]; /* Leave space for future extensions
93 and align to 8 byte boundary. */
45eca4d1 94 struct file_entry_new libs[0]; /* Entries describing libraries. */
a8fd59b0 95 /* After this the string table of size len_strings is found. */
45eca4d1
UD
96};
97
e25054c4
AJ
98/* Used to align cache_file_new. */
99#define ALIGN_CACHE(addr) \
100(((addr) + __alignof__ (struct cache_file_new) -1) \
101 & (~(__alignof__ (struct cache_file_new) - 1)))
102
17e00cc6 103extern int _dl_cache_libcmp (const char *p1, const char *p2) attribute_hidden;