dl-cache.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <ldconfig.h>
  16. /* For now we only support the natural XLEN ABI length on all targets, so the
  17. only bits that need to go into ld.so.cache are the FLEG ABI length. */
  18. #if defined __riscv_float_abi_double
  19. # define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_DOUBLE | FLAG_ELF_LIBC6)
  20. #else
  21. # define _DL_CACHE_DEFAULT_ID (FLAG_RISCV_FLOAT_ABI_SOFT | FLAG_ELF_LIBC6)
  22. #endif
  23. #define _dl_cache_check_flags(flags) \
  24. ((flags) == _DL_CACHE_DEFAULT_ID)
  25. /* If given a path to one of our library directories, adds every library
  26. directory via add_dir (), otherwise just adds the giver directory. On
  27. RISC-V, libraries can be found in paths ending in:
  28. - /lib64/lp64d
  29. - /lib64/lp64
  30. - /lib (only ld.so)
  31. so this will add all of those paths.
  32. According to Joseph Myers:
  33. My reasoning for that would be: generic autoconf-configured (etc.)
  34. software may only know about using the lib directory, so you want the
  35. lib directory to be searched regardless of the ABI - but it's also
  36. useful to be able to e.g. list /usr/local/lib in /etc/ld.so.conf for all
  37. architectures and have that automatically imply /usr/local/lib64/lp64d
  38. etc. so that libraries can be found that come from software that does
  39. use the ABI-specific directories. */
  40. #define add_system_dir(dir) \
  41. do \
  42. { \
  43. size_t len = strlen (dir); \
  44. char path[len + 9]; \
  45. memcpy (path, dir, len + 1); \
  46. if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12)) \
  47. { \
  48. len -= 8; \
  49. path[len] = '\0'; \
  50. } \
  51. if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11)) \
  52. { \
  53. len -= 7; \
  54. path[len] = '\0'; \
  55. } \
  56. add_dir (path); \
  57. if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4)) \
  58. { \
  59. memcpy (path + len, "64/lp64d", 9); \
  60. add_dir (path); \
  61. memcpy (path + len, "64/lp64", 8); \
  62. add_dir (path); \
  63. } \
  64. } while (0)
  65. #include_next <dl-cache.h>