1  /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
       2     Copyright (C) 2003-2023 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     <https://www.gnu.org/licenses/>.  */
      18  
      19  #include <ldconfig.h>
      20  
      21  #if ((defined __mips_nan2008 && !defined HAVE_MIPS_NAN2008) \
      22       || (!defined __mips_nan2008 && defined HAVE_MIPS_NAN2008))
      23  # error "Configuration inconsistency: __mips_nan2008 != HAVE_MIPS_NAN2008, overridden CFLAGS?"
      24  #endif
      25  
      26  /* Redefine the cache ID for new ABIs and 2008 NaN support; legacy o32
      27     keeps using the generic check.  */
      28  #ifdef __mips_nan2008
      29  # if _MIPS_SIM == _ABIO32
      30  #  define _DL_CACHE_DEFAULT_ID	(FLAG_MIPS_LIB32_NAN2008 | FLAG_ELF_LIBC6)
      31  # elif _MIPS_SIM == _ABI64
      32  #  define _DL_CACHE_DEFAULT_ID	(FLAG_MIPS64_LIBN64_NAN2008 | FLAG_ELF_LIBC6)
      33  # elif _MIPS_SIM == _ABIN32
      34  #  define _DL_CACHE_DEFAULT_ID	(FLAG_MIPS64_LIBN32_NAN2008 | FLAG_ELF_LIBC6)
      35  # endif
      36  #else
      37  # if _MIPS_SIM == _ABI64
      38  #  define _DL_CACHE_DEFAULT_ID	(FLAG_MIPS64_LIBN64 | FLAG_ELF_LIBC6)
      39  # elif _MIPS_SIM == _ABIN32
      40  #  define _DL_CACHE_DEFAULT_ID	(FLAG_MIPS64_LIBN32 | FLAG_ELF_LIBC6)
      41  # endif
      42  #endif
      43  
      44  #ifdef _DL_CACHE_DEFAULT_ID
      45  # define _dl_cache_check_flags(flags) \
      46    ((flags) == _DL_CACHE_DEFAULT_ID)
      47  #endif
      48  
      49  #define add_system_dir(dir) \
      50    do								\
      51      {								\
      52        size_t len = strlen (dir);				\
      53        char path[len + 3];					\
      54        memcpy (path, dir, len + 1);				\
      55        if (len >= 6						\
      56  	  && (! memcmp (path + len - 6, "/lib64", 6)		\
      57  	      || ! memcmp (path + len - 6, "/lib32", 6)))	\
      58  	{							\
      59  	  len -= 2;						\
      60  	  path[len] = '\0';					\
      61  	}							\
      62        add_dir (path);						\
      63        if (len >= 4 && ! memcmp (path + len - 4, "/lib", 4))	\
      64  	{							\
      65  	  memcpy (path + len, "32", 3);				\
      66  	  add_dir (path);					\
      67  	  memcpy (path + len, "64", 3);				\
      68  	  add_dir (path);					\
      69  	}							\
      70      } while (0)
      71  
      72  #include_next <dl-cache.h>