bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ELF ld with full path DT_NEEDED entries in dependencies


From: Ulrich Drepper
Subject: ELF ld with full path DT_NEEDED entries in dependencies
Date: 18 Mar 2001 01:36:12 -0800
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.2 (Thelxepeia)

Complex subject line, here's an example:

  mod2.so: a simple DSO, defining function foo
  mod1.so: a second DSO, linked against mod2.so with the full path,
           no DT_SONAME

  prog.c: reference foo()

When running

  gcc -o prog prog.c $THEPATH/mod1.so

the linker fails with something like

  ./ld: warning: .../mod2.so, needed by .../mod1.so, not found (try using 
-rpath or -rpath-link)

and then the compilation fails because the definition of foo() is not
found.

The reason for this is that although the DT_NEEDED entry in mod1.so is
an absolute path ld tries to find the file along the normal link path.
This is of course bogus.  The following patch fixes the problem.  OK?

2001-03-17  Ulrich Drepper  <address@hidden>

        * emultmpl/elf32.em (gld${EMULATION_NAME}_search_needed): If NAME
        is an absolute path look only for this file and not along the path.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.43
diff -u -u -r1.43 elf32.em
--- elf32.em    2001/03/17 21:24:26     1.43
+++ elf32.em    2001/03/18 09:33:20
@@ -386,6 +386,9 @@
   const char *s;
   size_t len;
 
+  if (name[0] == '/')
+    return gld${EMULATION_NAME}_try_needed (name, force);
+
   if (path == NULL || *path == '\0')
     return false;
   len = strlen (name);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]