diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -52,8 +52,19 @@ PRECIOUSPROG= BINDIR= /libexec SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG} +.if !defined(NEED_COMPAT) MLINKS?= ld-elf.so.1.1 ld.so.1 \ ld-elf.so.1.1 rtld.1 +.endif + +${PROG}.1: ld-elf.so.1.1.in + sed ${MAN_SUB} ${.ALLSRC} >${.TARGET} + +CLEANFILES+= ${PROG}.1 +MAN_SUB= -e 's|%%TITLE%%|${PROG:tu}|g' \ + -e 's|%%PROG%%|${PROG}|g' \ + -e 's|%%libcompat%%|${libcompat:U}|g' \ + -e 's|%%LD_%%|LD_${_LIBCOMPAT:U:C/.+$/&_/}|g' CFLAGS+= -fpic -DPIC $(DEBUG) diff --git a/libexec/rtld-elf/ld-elf.so.1.1 b/libexec/rtld-elf/ld-elf.so.1.1.in rename from libexec/rtld-elf/ld-elf.so.1.1 rename to libexec/rtld-elf/ld-elf.so.1.1.in --- a/libexec/rtld-elf/ld-elf.so.1.1 +++ b/libexec/rtld-elf/ld-elf.so.1.1.in @@ -28,11 +28,11 @@ .\" .\" $FreeBSD$ .\" -.Dd November 10, 2022 -.Dt LD-ELF.SO.1 1 +.Dd July 27, 2023 +.Dt %%TITLE%% 1 .Os .Sh NAME -.Nm ld-elf.so.1 , +.Nm %%PROG%% , .Nm ld.so , .Nm rtld .Nd run-time link-editor @@ -77,13 +77,8 @@ .It Pa $PLATFORM Translated to the machine hardware platform. .It Pa $LIB -Translated to the system library path component on the platform. -It is -.Pa lib -for native binaries, and typically -.Pa lib32 -for compat32 binaries. -Other translations might exist for other ABIs supported on the platform. +Translated to the system library path component on the platform, +lib%%libcompat%%. .El .Pp The @@ -110,7 +105,7 @@ tag .It Path indicated by -.Ev LD_LIBRARY_PATH +.Ev %%LD_%%LIBRARY_PATH environment variable .It .Dv DT_RUNPATH @@ -121,9 +116,9 @@ utility .It The -.Pa /lib +.Pa /lib%%libcompat%% and -.Pa /usr/lib +.Pa /usr/lib%%libcompat%% directories, unless the referencing object was linked using the .Dq Fl z Ar nodefaultlib option @@ -134,24 +129,19 @@ utility recognizes a number of environment variables that can be used to modify its behaviour. -On 64-bit architectures, the linker for 32-bit objects recognizes -all the environment variables listed below, but is being prefixed with -.Ev LD_32_ , -for example: -.Ev LD_32_TRACE_LOADED_OBJECTS . If the activated image is setuid or setgid, the variables are ignored. -.Bl -tag -width ".Ev LD_LIBMAP_DISABLE" -.It Ev LD_DUMP_REL_POST +.Bl -tag -width ".Ev %%LD_%%LIBMAP_DISABLE" +.It Ev %%LD_%%DUMP_REL_POST If set, .Nm will print a table containing all relocations after symbol binding and relocation. -.It Ev LD_DUMP_REL_PRE +.It Ev %%LD_%%DUMP_REL_PRE If set, .Nm will print a table containing all relocations before symbol binding and relocation. -.It Ev LD_DYNAMIC_WEAK +.It Ev %%LD_%%DYNAMIC_WEAK If set, use the ELF standard-compliant symbol lookup behavior: resolve to the first found symbol definition. .Pp @@ -169,7 +159,7 @@ .Fx rules regardless of the presence of the variable. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_LIBMAP +.It Ev %%LD_%%LIBMAP A library replacement list in the same format as .Xr libmap.conf 5 . For convenience, the characters @@ -181,46 +171,46 @@ .Xr libmap.conf 5 , and will override its entries. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_LIBMAP_DISABLE +.It Ev %%LD_%%LIBMAP_DISABLE If set, disables the use of .Xr libmap.conf 5 and -.Ev LD_LIBMAP . +.Ev %%LD_%%LIBMAP . This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_ELF_HINTS_PATH +.It Ev %%LD_%%ELF_HINTS_PATH This variable will override the default location of .Dq hints file. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_LIBRARY_PATH +.It Ev %%LD_%%LIBRARY_PATH A colon separated list of directories, overriding the default search path for shared libraries. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_LIBRARY_PATH_RPATH +.It Ev %%LD_%%LIBRARY_PATH_RPATH If the variable is specified and has a value starting with any of \'y\', \'Y\' or \'1\' symbols, the path specified by -.Ev LD_LIBRARY_PATH +.Ev %%LD_%%LIBRARY_PATH variable is allowed to override the path from .Dv DT_RPATH for binaries which does not contain .Dv DT_RUNPATH tag. For such binaries, when the variable -.Ev LD_LIBRARY_PATH_RPATH +.Ev %%LD_%%LIBRARY_PATH_RPATH is set, .Dq Fl z Ar nodefaultlib link-time option is ignored as well. -.It Ev LD_PRELOAD +.It Ev %%LD_%%PRELOAD A list of shared libraries, separated by colons and/or white space, to be linked in before any other shared libraries. If the directory is not specified then the directories specified by -.Ev LD_LIBRARY_PATH +.Ev %%LD_%%LIBRARY_PATH will be searched first followed by the set of built-in standard directories. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_PRELOAD_FDS +.It Ev %%LD_%%PRELOAD_FDS A colon separated list of file descriptor numbers for libraries. This is intended for preloading libraries in which we already have a file descriptor. @@ -228,42 +218,42 @@ look for them in directories. It may also be useful in a capability base system where we do not have access to global namespaces such as the filesystem. -.It Ev LD_LIBRARY_PATH_FDS +.It Ev %%LD_%%LIBRARY_PATH_FDS A colon separated list of file descriptor numbers for library directories. This is intended for use within .Xr capsicum 4 sandboxes, when global namespaces such as the filesystem are unavailable. -It is consulted just after LD_LIBRARY_PATH. +It is consulted just after %%LD_%%LIBRARY_PATH. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_BIND_NOT +.It Ev %%LD_%%BIND_NOT When set to a nonempty string, prevents modifications of the PLT slots when doing bindings. As result, each call of the PLT-resolved function is resolved. In combination with debug output, this provides complete account of all bind actions at runtime. This variable is unset for set-user-ID and set-group-ID programs. -.It Ev LD_BIND_NOW +.It Ev %%LD_%%BIND_NOW When set to a nonempty string, causes .Nm to relocate all external function calls before starting execution of the program. Normally, function calls are bound lazily, at the first call of each function. -.Ev LD_BIND_NOW +.Ev %%LD_%%BIND_NOW increases the start-up time of a program, but it avoids run-time surprises caused by unexpectedly undefined functions. -.It Ev LD_TRACE_LOADED_OBJECTS +.It Ev %%LD_%%TRACE_LOADED_OBJECTS When set to a nonempty string, causes .Nm to exit after loading the shared objects and printing a summary which includes the absolute pathnames of all objects, to standard output. -.It Ev LD_TRACE_LOADED_OBJECTS_ALL +.It Ev %%LD_%%TRACE_LOADED_OBJECTS_ALL When set to a nonempty string, causes .Nm to expand the summary to indicate which objects caused each object to be loaded. -.It Ev LD_TRACE_LOADED_OBJECTS_FMT1 -.It Ev LD_TRACE_LOADED_OBJECTS_FMT2 +.It Ev %%LD_%%TRACE_LOADED_OBJECTS_FMT1 +.It Ev %%LD_%%TRACE_LOADED_OBJECTS_FMT2 When set, these variables are interpreted as format strings a la .Xr printf 3 to customize the trace output and are used by @@ -274,9 +264,9 @@ to be operated as a filter more conveniently. If the dependency name starts with string .Pa lib , -.Ev LD_TRACE_LOADED_OBJECTS_FMT1 +.Ev %%LD_%%TRACE_LOADED_OBJECTS_FMT1 is used, otherwise -.Ev LD_TRACE_LOADED_OBJECTS_FMT2 +.Ev %%LD_%%TRACE_LOADED_OBJECTS_FMT2 is used. The following conversions can be used: .Bl -tag -width 4n @@ -286,7 +276,7 @@ .Dq __progname ) . .It Li \&%A The value of the environment variable -.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME . +.Ev %%LD_%%TRACE_LOADED_OBJECTS_PROGNAME . Typically used to print both the names of programs and shared libraries being inspected using .Xr ldd 1 . @@ -305,19 +295,19 @@ and .Ql \et are recognized and have their usual meaning. -.It Ev LD_UTRACE +.It Ev %%LD_%%UTRACE If set, .Nm will log events such as the loading and unloading of shared objects via .Xr utrace 2 . -.It Ev LD_LOADFLTR +.It Ev %%LD_%%LOADFLTR If set, .Nm will process the filtee dependencies of the loaded objects immediately, instead of postponing it until required. Normally, the filtees are opened at the time of the first symbol resolution from the filter object. -.It Ev LD_SHOW_AUXV +.It Ev %%LD_%%SHOW_AUXV If set, causes .Nm to dump content of the aux vector to standard output, before passing @@ -341,7 +331,7 @@ .Pp The syntax of the direct invocation is .Bd -ragged -offset indent -.Pa /libexec/ld-elf.so.1 +.Pa %%PROG%% .Op Fl b Ar exe .Op Fl d .Op Fl f Ar fd @@ -392,7 +382,7 @@ to find the binary to execute. .It Fl u Ignore all -.Ev LD_ +.Ev %%LD_%% environment variables that otherwise affect the dynamic linker behavior. .It Fl v @@ -478,15 +468,11 @@ and not the address of the initialization segment. .El .Sh FILES -.Bl -tag -width ".Pa /var/run/ld-elf32.so.hints" -compact -.It Pa /var/run/ld-elf.so.hints +.Bl -tag -width ".Pa /var/run/ld-elf%%libcompat%%.so.hints" -compact +.It Pa /var/run/ld-elf%%libcompat%%.so.hints Hints file. -.It Pa /var/run/ld-elf32.so.hints -Hints file for 32-bit binaries on 64-bit system. -.It Pa /etc/libmap.conf +.It Pa /etc/libmap%%libcompat%%.conf The libmap configuration file. -.It Pa /etc/libmap32.conf -The libmap configuration file for 32-bit binaries on 64-bit system. .El .Sh SEE ALSO .Xr ld 1 , diff --git a/libexec/rtld-elf32/Makefile b/libexec/rtld-elf32/Makefile --- a/libexec/rtld-elf32/Makefile +++ b/libexec/rtld-elf32/Makefile @@ -4,8 +4,6 @@ .include PROG= ld-elf32.so.1 -MAN= -MLINKS= rtld.1 ld-elf32.so.1 .PATH: ${SRCTOP}/libexec/rtld-elf .include "${SRCTOP}/libexec/rtld-elf/Makefile"