the number of program headers in the array. */
RTLD_DI_PHDR = 11,
- RTLD_DI_MAX = 11
+ /* Treat ARG as `const char **' and at that location, store the address
+ of the directory name used to expand $ORIGIN in this shared object's
+ dependency file names. */
+ RTLD_DI_ORIGIN_PATH = 12,
+
+ RTLD_DI_MAX = 12
};
strcpy (args->arg, l->l_origin);
break;
+ case RTLD_DI_ORIGIN_PATH:
+ if (l->l_origin != (char *) -1)
+ *(const char **) args->arg = l->l_origin;
+ else
+ *(const char **) args->arg = NULL;
+ break;
+
case RTLD_DI_TLS_MODID:
*(size_t *) args->arg = 0;
*(size_t *) args->arg = l->l_tls_modid;
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
+#include <support/check.h>
#define TEST_FUNCTION do_test ()
printf ("origin: %s\n", origin);
}
+ const char *origin_path;
+ TRY (RTLD_DI_ORIGIN_PATH, &origin_path)
+ {
+ TEST_COMPARE_STRING (origin, origin_path);
+ printf ("origin_path: %s\n", origin_path);
+ }
+
Dl_serinfo counts;
TRY (RTLD_DI_SERINFOSIZE, &counts)
{
@code{*@var{arg}}. The @var{arg} argument must be the address of an
object of type @code{Lmid_t}.
+@item RTLD_DI_ORIGIN_PATH
+The @code{$ORIGIN} dynamic string token pointer for @var{handle} is written
+to @code{*@var{arg}}. The @var{arg} argument must be the address of a
+@code{const char *}. If the @code{$ORIGIN} could not be determined, the
+function still returns 0 but writes a null pointer to @code{*@var{arg}}.
+The returned string is only valid as long as the corresponding handle is
+valid. Accessing it after @code{dlclose} has been called for the
+corresponding @var{handle} is undefined behavior.
+
@item RTLD_DI_ORIGIN
The value of the @code{$ORIGIN} dynamic string token for @var{handle} is
written to the character array starting at @var{arg} as a
null-terminated string.
This request type should not be used because it is prone to buffer
-overflows.
+overflows. Instead, @code{RTLD_DI_ORIGIN_PATH} described above should be
+used.
@item RTLD_DI_SERINFO
@itemx RTLD_DI_SERINFOSIZE