Skip to contentSkip to conversation

ld.so.8: List more places in which dynamic string tokens are expanded

PATCH In review Florian Weimer 2 participants 2 messages Jul 20, 2020 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ld.so.8: List more places in which dynamic string tokens are expanded

This happens for more than just DT_RPATH/DT_RUNPATH.

---
 man8/ld.so.8 | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)
man8/ld.so.8 +37 -5
index 2e98b7f5a..80f57a541 100644
@@ -97,12 +97,41 @@ and then
 If the binary was linked with the
 .B \-z nodeflib
 linker option, this step is skipped.
-.SS Rpath token expansion
+.SS Dynamic string tokens
 .PP
-The dynamic linker
-understands certain token strings in an rpath specification
-(DT_RPATH or DT_RUNPATH).
-Those strings are substituted as follows:
+In several places, the dynamic linker expands dynamic string tokens:
+.IP o 3
+In the environment variables
+.BR LD_LIBRARY_PATH ,
+.BR LD_PRELOAD ,
+and
+.BR LD_AUDIT ,
+.IP o 3
+inside the values of the dynamic section tags
+.BR DT_NEEDED ,
+.BR DT_RPATH ,
+.BR DT_RUNPATH ,
+.BR DT_AUDIT ,
+and
+.BR DT_DEPAUDIT
+of ELF binaries,
+.IP o 3
+in the arguments to the
+.B ld.so
+command line options
+.BR \-\-audit ,
+.BR \-\-library-path ,
+and
+.B \-\-preload
+(see below), and
+.IP o 3
+in the file name arguments to the
+.BR dlopen (3)
+and
+.BR dlmopen (3)
+functions.
+.PP
+The substituted tokens are as follows.
 .TP
 .IR $ORIGIN " (or equivalently " ${ORIGIN} )
 This expands to
@@ -156,6 +185,9 @@ value in the auxiliary vector (see
 .\"
 .\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
 .\" Don't do this!!
+.PP
+Note that the dynamic string tokens have to be quoted properly when
+set from a shell, to prevent their expension as environment variables.
 .SH OPTIONS
 .TP
 .BI \-\-audit " list"
#1 lore raw

Hi Florian,

Quoted 3 lines · Florian Weimer

This happens for more than just DT_RPATH/DT_RUNPATH.

Thanks! Patch applied.

The page already mentioned that these tokens were usable with LD_LIBRARY_PATH, LD_PRELOAD, and LD_AUDIT, but I was unaware of the other places where they are applicable.

Cheers,

Michael

Quoted 66 lines
---
 man8/ld.so.8 | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)
man8/ld.so.8 +37 -5
index 2e98b7f5a..80f57a541 100644
@@ -97,12 +97,41 @@ and then
 If the binary was linked with the
 .B \-z nodeflib
 linker option, this step is skipped.
-.SS Rpath token expansion
+.SS Dynamic string tokens
 .PP
-The dynamic linker
-understands certain token strings in an rpath specification
-(DT_RPATH or DT_RUNPATH).
-Those strings are substituted as follows:
+In several places, the dynamic linker expands dynamic string tokens:
+.IP o 3
+In the environment variables
+.BR LD_LIBRARY_PATH ,
+.BR LD_PRELOAD ,
+and
+.BR LD_AUDIT ,
+.IP o 3
+inside the values of the dynamic section tags
+.BR DT_NEEDED ,
+.BR DT_RPATH ,
+.BR DT_RUNPATH ,
+.BR DT_AUDIT ,
+and
+.BR DT_DEPAUDIT
+of ELF binaries,
+.IP o 3
+in the arguments to the
+.B ld.so
+command line options
+.BR \-\-audit ,
+.BR \-\-library-path ,
+and
+.B \-\-preload
+(see below), and
+.IP o 3
+in the file name arguments to the
+.BR dlopen (3)
+and
+.BR dlmopen (3)
+functions.
+.PP
+The substituted tokens are as follows.
 .TP
 .IR $ORIGIN " (or equivalently " ${ORIGIN} )
 This expands to
@@ -156,6 +185,9 @@ value in the auxiliary vector (see
 .\"
 .\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
 .\" Don't do this!!
+.PP
+Note that the dynamic string tokens have to be quoted properly when
+set from a shell, to prevent their expension as environment variables.
 .SH OPTIONS
 .TP
 .BI \-\-audit " list"
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/