rtld-elf: Migrate from COMPAT_32BIT to generic COMPAT_libcompat/LIBCOMPAT

We still have a tiny amount of libcompat-specific code in rtld_paths.h,
but it's been deduplicated as much as possible, and in future we may
wish to just push these variables down to the few consumers of them and
make them use the double-underscore variants with a libcompat argument
rather than give them names here.

See commit 8fad2cda93 ("bsd.compat.mk: Provide new CPP and sub-make
variables") for the context behind this change.

Reviewed by:	kib, brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D40925
This commit is contained in:
Jessica Clarke 2023-07-09 18:49:07 +01:00
parent d3748fc0c2
commit f940929d41
2 changed files with 38 additions and 23 deletions

View File

@ -804,7 +804,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
aux_info[AT_STACKPROT]->a_un.a_val != 0)
stack_prot = aux_info[AT_STACKPROT]->a_un.a_val;
#ifndef COMPAT_32BIT
#ifndef COMPAT_libcompat
/*
* Get the actual dynamic linker pathname from the executable if
* possible. (It should always be possible.) That ensures that

View File

@ -31,53 +31,68 @@
#undef _PATH_ELF_HINTS
#ifndef _COMPAT32_BASENAME_RTLD
#define _COMPAT32_BASENAME_RTLD "ld-elf32.so.1"
#ifndef _RTLD_COMPAT_LIB_SUFFIX
#ifdef COMPAT_libcompat
#define _RTLD_COMPAT_LIB_SUFFIX COMPAT_libcompat
#else
#define _RTLD_COMPAT_LIB_SUFFIX ""
#endif
#endif
#ifndef _PATH_ELF32_HINTS
#define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints"
#ifndef _RTLD_COMPAT_ENV_SUFFIX
#ifdef COMPAT_LIBCOMPAT
#define _RTLD_COMPAT_ENV_SUFFIX COMPAT_LIBCOMPAT "_"
#else
#define _RTLD_COMPAT_ENV_SUFFIX ""
#endif
#endif
#ifdef COMPAT_32BIT
#define _PATH_ELF_HINTS _PATH_ELF32_HINTS
#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
#define _BASENAME_RTLD _COMPAT32_BASENAME_RTLD
#define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
#define LD_ "LD_32_"
#define TOKEN_LIB "lib32"
#ifndef __PATH_ELF_HINTS
#define __PATH_ELF_HINTS(_lc) "/var/run/ld-elf" _lc ".so.hints"
#endif
#ifndef _PATH_ELF_HINTS
#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
#define _PATH_ELF_HINTS __PATH_ELF_HINTS(_RTLD_COMPAT_LIB_SUFFIX)
#endif
#ifndef _PATH_LIBMAP_CONF
#define _PATH_LIBMAP_CONF "/etc/libmap.conf"
#define _PATH_LIBMAP_CONF "/etc/libmap" _RTLD_COMPAT_LIB_SUFFIX ".conf"
#endif
#ifndef __BASENAME_RTLD
#define __BASENAME_RTLD(_lc) "ld-elf" _lc ".so.1"
#endif
#ifndef _BASENAME_RTLD
#define _BASENAME_RTLD "ld-elf.so.1"
#define _BASENAME_RTLD __BASENAME_RTLD(_RTLD_COMPAT_LIB_SUFFIX)
#endif
#ifndef __PATH_RTLD
#define __PATH_RTLD(_lc) "/libexec/" __BASENAME_RTLD(_lc)
#endif
#ifndef _PATH_RTLD
#define _PATH_RTLD "/libexec/" _BASENAME_RTLD
#endif
#ifndef _COMPAT32_PATH_RTLD
#define _COMPAT32_PATH_RTLD "/libexec/" _COMPAT32_BASENAME_RTLD
#define _PATH_RTLD __PATH_RTLD(_RTLD_COMPAT_LIB_SUFFIX)
#endif
#ifndef STANDARD_LIBRARY_PATH
#define STANDARD_LIBRARY_PATH "/lib:/usr/lib"
#define STANDARD_LIBRARY_PATH "/lib" _RTLD_COMPAT_LIB_SUFFIX ":/usr/lib" _RTLD_COMPAT_LIB_SUFFIX
#endif
#ifndef LD_
#define LD_ "LD_"
#define LD_ "LD_" _RTLD_COMPAT_ENV_SUFFIX
#endif
#ifndef TOKEN_LIB
#define TOKEN_LIB "lib"
#define TOKEN_LIB "lib" _RTLD_COMPAT_LIB_SUFFIX
#endif
#ifndef _PATH_ELF32_HINTS
#define _PATH_ELF32_HINTS __PATH_ELF_HINTS("32")
#endif
#ifndef _COMPAT32_PATH_RTLD
#define _COMPAT32_PATH_RTLD __PATH_RTLD("32")
#endif
#ifdef IN_RTLD