Blame sysdeps/unix/sysv/linux/riscv/dl-cache.h

Packit Service 82fcde
/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
Packit Service 82fcde
   Copyright (C) 2003-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library.  If not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <ldconfig.h>
Packit Service 82fcde
Packit Service 82fcde
/* For now we only support the natural XLEN ABI length on all targets, so the
Packit Service 82fcde
   only bits that need to go into ld.so.cache are the FLEG ABI length.  */
Packit Service 82fcde
#if defined __riscv_float_abi_double
Packit Service 82fcde
# define _DL_CACHE_DEFAULT_ID    (FLAG_RISCV_FLOAT_ABI_DOUBLE | FLAG_ELF_LIBC6)
Packit Service 82fcde
#else
Packit Service 82fcde
# define _DL_CACHE_DEFAULT_ID    (FLAG_RISCV_FLOAT_ABI_SOFT | FLAG_ELF_LIBC6)
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#define _dl_cache_check_flags(flags)		    			\
Packit Service 82fcde
  ((flags) == _DL_CACHE_DEFAULT_ID)
Packit Service 82fcde
Packit Service 82fcde
/* If given a path to one of our library directories, adds every library
Packit Service 82fcde
   directory via add_dir (), otherwise just adds the giver directory.  On
Packit Service 82fcde
   RISC-V, libraries can be found in paths ending in:
Packit Service 82fcde
     - /lib64/lp64d
Packit Service 82fcde
     - /lib64/lp64
Packit Service 82fcde
     - /lib (only ld.so)
Packit Service 82fcde
   so this will add all of those paths.
Packit Service 82fcde
Packit Service 82fcde
   According to Joseph Myers:
Packit Service 82fcde
       My reasoning for that would be: generic autoconf-configured (etc.)
Packit Service 82fcde
       software may only know about using the lib directory, so you want the
Packit Service 82fcde
       lib directory to be searched regardless of the ABI - but it's also
Packit Service 82fcde
       useful to be able to e.g. list /usr/local/lib in /etc/ld.so.conf for all
Packit Service 82fcde
       architectures and have that automatically imply /usr/local/lib64/lp64d
Packit Service 82fcde
       etc. so that libraries can be found that come from software that does
Packit Service 82fcde
       use the ABI-specific directories.  */
Packit Service 82fcde
#define add_system_dir(dir) 						\
Packit Service 82fcde
  do							    		\
Packit Service 82fcde
    {									\
Packit Service 82fcde
      size_t len = strlen (dir);					\
Packit Service 82fcde
      char path[len + 9];						\
Packit Service 82fcde
      memcpy (path, dir, len + 1);					\
Packit Service 82fcde
      if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12))	\
Packit Service 82fcde
	{								\
Packit Service 82fcde
	  len -= 8;							\
Packit Service 82fcde
	  path[len] = '\0';						\
Packit Service 82fcde
	}								\
Packit Service 82fcde
      if (len >= 11 && ! memcmp(path + len - 11, "/lib64/lp64", 11))	\
Packit Service 82fcde
	{								\
Packit Service 82fcde
	  len -= 7;							\
Packit Service 82fcde
	  path[len] = '\0';						\
Packit Service 82fcde
	}								\
Packit Service 82fcde
      add_dir (path);							\
Packit Service 82fcde
      if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4))		\
Packit Service 82fcde
	{								\
Packit Service 82fcde
	  memcpy (path + len, "64/lp64d", 9);				\
Packit Service 82fcde
	  add_dir (path);						\
Packit Service 82fcde
	  memcpy (path + len, "64/lp64", 8);				\
Packit Service 82fcde
	  add_dir (path);						\
Packit Service 82fcde
	}								\
Packit Service 82fcde
    } while (0)
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
#include_next <dl-cache.h>