|
Packit |
6c4009 |
/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
|
|
Packit |
6c4009 |
Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <stdint.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _DL_CACHE_DEFAULT_ID
|
|
Packit |
6c4009 |
# define _DL_CACHE_DEFAULT_ID 3
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _dl_cache_check_flags
|
|
Packit |
6c4009 |
# define _dl_cache_check_flags(flags) \
|
|
Packit |
6c4009 |
((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef LD_SO_CACHE
|
|
Packit |
6c4009 |
# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef add_system_dir
|
|
Packit |
6c4009 |
# define add_system_dir(dir) add_dir (dir)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define CACHEMAGIC "ld.so-1.7.0"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another
|
|
Packit |
6c4009 |
format has been added in a compatible way:
|
|
Packit |
6c4009 |
The beginning of the string table is used for the new table:
|
|
Packit |
6c4009 |
old_magic
|
|
Packit |
6c4009 |
nlibs
|
|
Packit |
6c4009 |
libs[0]
|
|
Packit |
6c4009 |
...
|
|
Packit |
6c4009 |
libs[nlibs-1]
|
|
Packit |
6c4009 |
pad, new magic needs to be aligned
|
|
Packit |
6c4009 |
- this is string[0] for the old format
|
|
Packit |
6c4009 |
new magic - this is string[0] for the new format
|
|
Packit |
6c4009 |
newnlibs
|
|
Packit |
6c4009 |
...
|
|
Packit |
6c4009 |
newlibs[0]
|
|
Packit |
6c4009 |
...
|
|
Packit |
6c4009 |
newlibs[newnlibs-1]
|
|
Packit |
6c4009 |
string 1
|
|
Packit |
6c4009 |
string 2
|
|
Packit |
6c4009 |
...
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
struct file_entry
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int flags; /* This is 1 for an ELF library. */
|
|
Packit |
6c4009 |
unsigned int key, value; /* String table indices. */
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct cache_file
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
char magic[sizeof CACHEMAGIC - 1];
|
|
Packit |
6c4009 |
unsigned int nlibs;
|
|
Packit |
6c4009 |
struct file_entry libs[0];
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define CACHEMAGIC_NEW "glibc-ld.so.cache"
|
|
Packit |
6c4009 |
#define CACHE_VERSION "1.1"
|
|
Packit |
6c4009 |
#define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct file_entry_new
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int32_t flags; /* This is 1 for an ELF library. */
|
|
Packit |
6c4009 |
uint32_t key, value; /* String table indices. */
|
|
Packit |
6c4009 |
uint32_t osversion; /* Required OS version. */
|
|
Packit |
6c4009 |
uint64_t hwcap; /* Hwcap entry. */
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct cache_file_new
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
char magic[sizeof CACHEMAGIC_NEW - 1];
|
|
Packit |
6c4009 |
char version[sizeof CACHE_VERSION - 1];
|
|
Packit |
6c4009 |
uint32_t nlibs; /* Number of entries. */
|
|
Packit |
6c4009 |
uint32_t len_strings; /* Size of string table. */
|
|
Packit |
6c4009 |
uint32_t unused[5]; /* Leave space for future extensions
|
|
Packit |
6c4009 |
and align to 8 byte boundary. */
|
|
Packit |
6c4009 |
struct file_entry_new libs[0]; /* Entries describing libraries. */
|
|
Packit |
6c4009 |
/* After this the string table of size len_strings is found. */
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Used to align cache_file_new. */
|
|
Packit |
6c4009 |
#define ALIGN_CACHE(addr) \
|
|
Packit |
6c4009 |
(((addr) + __alignof__ (struct cache_file_new) -1) \
|
|
Packit |
6c4009 |
& (~(__alignof__ (struct cache_file_new) - 1)))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extern int _dl_cache_libcmp (const char *p1, const char *p2) attribute_hidden;
|