|
Packit |
6c4009 |
/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
|
|
Packit |
6c4009 |
Copyright (C) 2003-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 <ldconfig.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* For now we only support the natural XLEN ABI length on all targets, so the
|
|
Packit |
6c4009 |
only bits that need to go into ld.so.cache are the FLEG ABI length. */
|
|
Packit |
6c4009 |
#if defined __riscv_float_abi_double
|
|
Packit |
6c4009 |
# define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_DOUBLE | FLAG_ELF_LIBC6)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_SOFT | FLAG_ELF_LIBC6)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _dl_cache_check_flags(flags) \
|
|
Packit |
6c4009 |
((flags) == _DL_CACHE_DEFAULT_ID)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* If given a path to one of our library directories, adds every library
|
|
Packit |
6c4009 |
directory via add_dir (), otherwise just adds the giver directory. On
|
|
Packit |
6c4009 |
RISC-V, libraries can be found in paths ending in:
|
|
Packit |
6c4009 |
- /lib64/lp64d
|
|
Packit |
6c4009 |
- /lib64/lp64
|
|
Packit |
6c4009 |
- /lib (only ld.so)
|
|
Packit |
6c4009 |
so this will add all of those paths.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
According to Joseph Myers:
|
|
Packit |
6c4009 |
My reasoning for that would be: generic autoconf-configured (etc.)
|
|
Packit |
6c4009 |
software may only know about using the lib directory, so you want the
|
|
Packit |
6c4009 |
lib directory to be searched regardless of the ABI - but it's also
|
|
Packit |
6c4009 |
useful to be able to e.g. list /usr/local/lib in /etc/ld.so.conf for all
|
|
Packit |
6c4009 |
architectures and have that automatically imply /usr/local/lib64/lp64d
|
|
Packit |
6c4009 |
etc. so that libraries can be found that come from software that does
|
|
Packit |
6c4009 |
use the ABI-specific directories. */
|
|
Packit |
6c4009 |
#define add_system_dir(dir) \
|
|
Packit |
6c4009 |
do \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
size_t len = strlen (dir); \
|
|
Packit |
6c4009 |
char path[len + 9]; \
|
|
Packit |
6c4009 |
memcpy (path, dir, len + 1); \
|
|
Packit |
6c4009 |
if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12)) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
len -= 8; \
|
|
Packit |
6c4009 |
path[len] = '\0'; \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11)) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
len -= 7; \
|
|
Packit |
6c4009 |
path[len] = '\0'; \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
add_dir (path); \
|
|
Packit |
6c4009 |
if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4)) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
memcpy (path + len, "64/lp64d", 9); \
|
|
Packit |
6c4009 |
add_dir (path); \
|
|
Packit |
6c4009 |
memcpy (path + len, "64/lp64", 8); \
|
|
Packit |
6c4009 |
add_dir (path); \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
} while (0)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include_next <dl-cache.h>
|