Date: Tue, 2 Feb 1999 19:15:13 -0600
From: John Goerzen <jgoerzen@complete.org>
> Good. Alexandre has already said that he will accept a patch to
> disable -rpath for any directory listed in /etc/ld.so.conf. I
> encourage you and/or others who care to write this patch. Then the
> problem will be solved, without requiring further hyperbole.
>
> Another simple solution would be to tweak the Debian dynamic linker in
> the same way that the RedHat dynamic linker was tweaked, as already
> discussed.
I apparently missed both messages to which you refer; however, commenting
upon the first: I'm unsure what you mean here. -rpath is decided at compile
time, ld.so.conf at runtime. ls.so.conf itself may change, and at compile
time it may not have a complete picture.
I don't know what sort of tweaks RedHat made. Can you enlighten me/us?
Both were discussed on some set of mailing lists, but I don't know
precisely which ones. I thought at least one Debian list was on the
CC line at that point.
You're quite right that ld.so.conf may not be the same when a program
is linked and when it is run. However, it is appropriate for libtool
to use -rpath if the shared library is installed in a user's
directory; otherwise, the user would have to set LD_LIBRARY_PATH,
which is inconvenient, particularly if many people expect to run the
resulting program.
Therefore, it's not OK to eliminate -rpath entirely from libtool.
However, it's probably OK to avoid using -rpath for any system
directory, one which the dynamic linker will search.
The use of /etc/ld.so.cache, rather than a simple directory search,
means that there is no actual list of system directories on a Linux
system other than /lib and /usr/lib. However, /etc/ld.so.conf is a
reasonable approximation, one which will probably not mislead an
ordinary program.
It would also be possible to add an option to libtool to avoid the use
of -rpath. However, no package maintainer would ever use such an
option, since it would never be correct without knowing the --prefix
option used for configure. Only an organization like Debian would use
it. Alexandre sent out a patch which disabled -rpath, which Debian
could use just as easily as a special option. I don't have a copy of
that patch.
The RedHat patch to the libc5 dynamic linker has been sent out twice.
I've appended it again. This patch changes the handling of DT_RPATH
in order to make it more likely that a program linked on a libc5
system will work on a glibc system. It breaks the ABI for a libc5
program, but then the ABI was already broken anyhow.
Ian
--- ld.so-1.9.5/d-link/readelflib1.c.ewt Mon Nov 17 10:04:15 1997
+++ ld.so-1.9.5/d-link/readelflib1.c Mon Nov 17 10:23:15 1997
@@ -179,38 +179,10 @@
goto goof;
}
- /*
- * The ABI specifies that RPATH is searched before LD_*_PATH or
- * the default path of /usr/lib.
- * Check in rpath directories
- */
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
- if (tpnt->libtype == elf_executable) {
- pnt1 = (char *)tpnt->dynamic_info[DT_RPATH];
- if(pnt1) {
- pnt1 += (unsigned int) tpnt->loadaddr + tpnt->dynamic_info[DT_STRTAB];
- while(*pnt1){
- pnt2 = mylibname;
- while(*pnt1 && *pnt1 != ':') {
- if (pnt2 - mylibname < 1024)
- *pnt2++ = *pnt1++;
- else
- pnt1++;
- }
- if (pnt2 - mylibname >= 1024)
- break;
- if(pnt2[-1] != '/') *pnt2++ = '/';
- pnt = libname;
- while(*pnt) *pnt2++ = *pnt++;
- *pnt2++ = 0;
- tpnt1 = _dl_load_elf_shared_library(mylibname, 0);
- if(tpnt1) return tpnt1;
- if(*pnt1 == ':') pnt1++;
- }
- }
- }
- }
-
+ /* EWT - change things around a bit... The RPATH is almost definitely
+ wrong for libc 5 apps as things got moved around so much. Rather
+ then checking it first, we'll check it last. While this could
+ cause major breakages, it probably won't. */
/* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
pnt1 = _dl_library_path;
@@ -259,6 +231,38 @@
}
}
#endif
+
+ /*
+ * The ABI specifies that RPATH is searched before LD_*_PATH or
+ * the default path of /usr/lib.
+ * Check in rpath directories
+ */
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
+ if (tpnt->libtype == elf_executable) {
+ pnt1 = (char *)tpnt->dynamic_info[DT_RPATH];
+ if(pnt1) {
+ pnt1 += (unsigned int) tpnt->loadaddr + tpnt->dynamic_info[DT_STRTAB];
+ while(*pnt1){
+ pnt2 = mylibname;
+ while(*pnt1 && *pnt1 != ':') {
+ if (pnt2 - mylibname < 1024)
+ *pnt2++ = *pnt1++;
+ else
+ pnt1++;
+ }
+ if (pnt2 - mylibname >= 1024)
+ break;
+ if(pnt2[-1] != '/') *pnt2++ = '/';
+ pnt = libname;
+ while(*pnt) *pnt2++ = *pnt++;
+ *pnt2++ = 0;
+ tpnt1 = _dl_load_elf_shared_library(mylibname, 0);
+ if(tpnt1) return tpnt1;
+ if(*pnt1 == ':') pnt1++;
+ }
+ }
+ }
+ }
/* Check in /usr/lib */
#ifdef IBCS_COMPATIBLE