Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jul 2023 17:52:04 GMT
From:      Jessica Clarke <jrtc27@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f940929d4111 - main - rtld-elf: Migrate from COMPAT_32BIT to generic COMPAT_libcompat/LIBCOMPAT
Message-ID:  <202307091752.369Hq4At098705@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=f940929d411102d6925e158de90d8d23b3774df6

commit f940929d411102d6925e158de90d8d23b3774df6
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-07-09 17:49:07 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-07-09 17:49:07 +0000

    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 8fad2cda93c7 ("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
---
 libexec/rtld-elf/rtld.c       |  2 +-
 libexec/rtld-elf/rtld_paths.h | 57 +++++++++++++++++++++++++++----------------
 2 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 9a522bf721c5..5c96405be62c 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -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
diff --git a/libexec/rtld-elf/rtld_paths.h b/libexec/rtld-elf/rtld_paths.h
index 759a610e6469..fd61da4507ee 100644
--- a/libexec/rtld-elf/rtld_paths.h
+++ b/libexec/rtld-elf/rtld_paths.h
@@ -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		"/libexec/" _BASENAME_RTLD
+#ifndef __PATH_RTLD
+#define	__PATH_RTLD(_lc)	"/libexec/" __BASENAME_RTLD(_lc)
 #endif
 
-#ifndef _COMPAT32_PATH_RTLD
-#define	_COMPAT32_PATH_RTLD	"/libexec/" _COMPAT32_BASENAME_RTLD
+#ifndef _PATH_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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307091752.369Hq4At098705>