summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-dst.h15
-rw-r--r--elf/dl-load.c9
2 files changed, 22 insertions, 2 deletions
diff --git a/elf/dl-dst.h b/elf/dl-dst.h
index 42bd4185af..83d16bdb0e 100644
--- a/elf/dl-dst.h
+++ b/elf/dl-dst.h
@@ -1,5 +1,5 @@
/* Handling of dynamic sring tokens.
- Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999,2001,2002,2003,2004,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -50,6 +50,7 @@
\
First get the origin string if it is not available yet. \
This can only happen for the map of the executable. */ \
+ DL_DST_REQ_STATIC \
if ((l)->l_origin == NULL) \
{ \
assert ((l)->l_name[0] == '\0'); \
@@ -66,6 +67,18 @@
\
__len; })
+#ifdef SHARED
+# define DL_DST_REQ_STATIC /* nothing */
+#else
+# define DL_DST_REQ_STATIC \
+ if ((l) == NULL) \
+ { \
+ const char *origin = _dl_get_origin (); \
+ origin_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \
+ } \
+ else
+#endif
+
#ifndef IS_IN_rtld
# define _dl_get_origin GLRO(dl_get_origin)
# define _dl_dst_substitute GLRO(dl_dst_substitute)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 29fdfd8f19..01e1572f51 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -266,7 +266,14 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
++name;
if ((len = is_dst (start, name, "ORIGIN", is_path,
INTUSE(__libc_enable_secure))) != 0)
- repl = l->l_origin;
+ {
+#ifndef SHARED
+ if (l == NULL)
+ repl = _dl_get_origin ();
+ else
+#endif
+ repl = l->l_origin;
+ }
else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
repl = GLRO(dl_platform);
else if ((len = is_dst (start, name, "LIB", is_path, 0)) != 0)