dl-cache.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
  2. Copyright (C) 1999-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 <stdint.h>
  16. #ifndef _DL_CACHE_DEFAULT_ID
  17. # define _DL_CACHE_DEFAULT_ID 3
  18. #endif
  19. #ifndef _dl_cache_check_flags
  20. # define _dl_cache_check_flags(flags) \
  21. ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
  22. #endif
  23. #ifndef LD_SO_CACHE
  24. # define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
  25. #endif
  26. #ifndef add_system_dir
  27. # define add_system_dir(dir) add_dir (dir)
  28. #endif
  29. #define CACHEMAGIC "ld.so-1.7.0"
  30. /* libc5 and glibc 2.0/2.1 use the same format. For glibc 2.2 another
  31. format has been added in a compatible way:
  32. The beginning of the string table is used for the new table:
  33. old_magic
  34. nlibs
  35. libs[0]
  36. ...
  37. libs[nlibs-1]
  38. pad, new magic needs to be aligned
  39. - this is string[0] for the old format
  40. new magic - this is string[0] for the new format
  41. newnlibs
  42. ...
  43. newlibs[0]
  44. ...
  45. newlibs[newnlibs-1]
  46. string 1
  47. string 2
  48. ...
  49. */
  50. struct file_entry
  51. {
  52. int flags; /* This is 1 for an ELF library. */
  53. unsigned int key, value; /* String table indices. */
  54. };
  55. struct cache_file
  56. {
  57. char magic[sizeof CACHEMAGIC - 1];
  58. unsigned int nlibs;
  59. struct file_entry libs[0];
  60. };
  61. #define CACHEMAGIC_NEW "glibc-ld.so.cache"
  62. #define CACHE_VERSION "1.1"
  63. #define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION
  64. struct file_entry_new
  65. {
  66. int32_t flags; /* This is 1 for an ELF library. */
  67. uint32_t key, value; /* String table indices. */
  68. uint32_t osversion; /* Required OS version. */
  69. uint64_t hwcap; /* Hwcap entry. */
  70. };
  71. struct cache_file_new
  72. {
  73. char magic[sizeof CACHEMAGIC_NEW - 1];
  74. char version[sizeof CACHE_VERSION - 1];
  75. uint32_t nlibs; /* Number of entries. */
  76. uint32_t len_strings; /* Size of string table. */
  77. uint32_t unused[5]; /* Leave space for future extensions
  78. and align to 8 byte boundary. */
  79. struct file_entry_new libs[0]; /* Entries describing libraries. */
  80. /* After this the string table of size len_strings is found. */
  81. };
  82. /* Used to align cache_file_new. */
  83. #define ALIGN_CACHE(addr) \
  84. (((addr) + __alignof__ (struct cache_file_new) -1) \
  85. & (~(__alignof__ (struct cache_file_new) - 1)))
  86. extern int _dl_cache_libcmp (const char *p1, const char *p2) attribute_hidden;