This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH ping] Relative path from search path in DT_NEEDED
- From: Matt Rice <ratmice at yahoo dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 25 Mar 2005 09:26:36 -0800 (PST)
- Subject: [PATCH ping] Relative path from search path in DT_NEEDED
this patch never got reviewed, ping.
>Here is a patch,
>
>it adds a substitution sequence which allows for
>relative linking to the search path
>
>my original proposal is here..
>http://sourceware.org/ml/libc-alpha/2005-02/msg00093.html
>but has switched to using a substitution sequence
>instead of a new type of NEEDED entry.
matt
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Index: elf/dl-deps.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-deps.c,v
retrieving revision 1.77
diff -u -p -r1.77 dl-deps.c
--- elf/dl-deps.c 14 Oct 2004 02:01:14 -0000 1.77
+++ elf/dl-deps.c 2 Mar 2005 10:52:24 -0000
@@ -237,10 +237,8 @@ _dl_map_object_deps (struct link_map *ma
struct link_map *dep;
int err;
- /* Recognize DSTs. */
- name = expand_dst (l, strtab + d->d_un.d_val, 0);
/* Store the tag in the argument structure. */
- args.name = name;
+ args.name = strtab + d->d_un.d_val;
err = _dl_catch_error (&objname, &errstring, openaux, &args);
if (__builtin_expect (errstring != NULL, 0))
Index: elf/dl-load.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-load.c,v
retrieving revision 1.263
diff -u -p -r1.263 dl-load.c
--- elf/dl-load.c 1 Mar 2005 20:30:34 -0000 1.263
+++ elf/dl-load.c 2 Mar 2005 10:52:28 -0000
@@ -231,7 +231,8 @@ _dl_dst_count (const char *name, int is_
if ((len = is_dst (start, name, "ORIGIN", is_path,
INTUSE(__libc_enable_secure))) != 0
|| (len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0
- || (len = is_dst (start, name, "LIB", is_path, 0)) != 0)
+ || (len = is_dst (start, name, "LIB", is_path, 0)) != 0
+ || (len = is_dst (start, name, "RELATIVE_SEARCH_PATH", is_path, 0)) != 0)
++cnt;
name = strchr (name + len, '$');
@@ -270,6 +271,8 @@ _dl_dst_substitute (struct link_map *l,
repl = GLRO(dl_platform);
else if ((len = is_dst (start, name, "LIB", is_path, 0)) != 0)
repl = DL_DST_LIB;
+ else if ((len = is_dst (start, name, "RELATIVE_SEARCH_PATH", is_path, 0)) != 0)
+ repl = "";
if (repl != NULL && repl != (const char *) -1)
{
@@ -303,6 +306,28 @@ _dl_dst_substitute (struct link_map *l,
return result;
}
+static int relative_dynamic_string_token(struct link_map *l, const char *name)
+{
+ size_t cnt;
+ const char *const start = name;
+ cnt = DL_DST_COUNT(name, 0);
+
+ if (__builtin_expect (cnt, 0) == 0)
+ return 0;
+
+ do
+ {
+ size_t len;
+
+ ++name;
+ if ((len = is_dst (start, name, "RELATIVE_SEARCH_PATH", 0, 0)) != 0)
+ return 1;
+ name = strchr (name + len, '$');
+ }
+ while (name != NULL);
+
+ return 0;
+}
/* Return copy of argument with all recognized dynamic string tokens
($ORIGIN and $PLATFORM for now) replaced. On some platforms it
@@ -1971,11 +1996,15 @@ _dl_map_object (struct link_map *loader,
}
#endif
- if (strchr (name, '/') == NULL)
+ if (strchr (name, '/') == NULL
+ || (name[0] == '$' && relative_dynamic_string_token(loader, name)))
{
/* Search for NAME in several places. */
- size_t namelen = strlen (name) + 1;
+ size_t namelen;
+
+ name = expand_dynamic_string_token (loader, name);
+ namelen = strlen(name) + 1;
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_LIBS, 0))
_dl_debug_printf ("find library=%s [%lu]; searching\n", name, nsid);