]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/riscv/dl-cache.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / riscv / dl-cache.h
1 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
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
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.
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
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #include <ldconfig.h>
20
21 /* For now we only support the natural XLEN ABI length on all targets, so the
22 only bits that need to go into ld.so.cache are the FLEG ABI length. */
23 #if defined __riscv_float_abi_double
24 # define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_DOUBLE | FLAG_ELF_LIBC6)
25 #else
26 # define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_SOFT | FLAG_ELF_LIBC6)
27 #endif
28
29 #define _dl_cache_check_flags(flags) \
30 ((flags) == _DL_CACHE_DEFAULT_ID)
31
32 /* If given a path to one of our library directories, adds every library
33 directory via add_dir (), otherwise just adds the giver directory. On
34 RISC-V, libraries can be found in paths ending in:
35 - /lib64/lp64d
36 - /lib64/lp64
37 - /lib (only ld.so)
38 so this will add all of those paths.
39
40 According to Joseph Myers:
41 My reasoning for that would be: generic autoconf-configured (etc.)
42 software may only know about using the lib directory, so you want the
43 lib directory to be searched regardless of the ABI - but it's also
44 useful to be able to e.g. list /usr/local/lib in /etc/ld.so.conf for all
45 architectures and have that automatically imply /usr/local/lib64/lp64d
46 etc. so that libraries can be found that come from software that does
47 use the ABI-specific directories. */
48 #define add_system_dir(dir) \
49 do \
50 { \
51 size_t len = strlen (dir); \
52 char path[len + 9]; \
53 memcpy (path, dir, len + 1); \
54 if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12)) \
55 { \
56 len -= 8; \
57 path[len] = '\0'; \
58 } \
59 if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11)) \
60 { \
61 len -= 7; \
62 path[len] = '\0'; \
63 } \
64 add_dir (path); \
65 if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4)) \
66 { \
67 memcpy (path + len, "64/lp64d", 9); \
68 add_dir (path); \
69 memcpy (path + len, "64/lp64", 8); \
70 add_dir (path); \
71 } \
72 } while (0)
73
74
75 #include_next <dl-cache.h>