summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorPeter Valchev <pvalchev@cvs.openbsd.org>2002-03-19 02:02:58 +0000
committerPeter Valchev <pvalchev@cvs.openbsd.org>2002-03-19 02:02:58 +0000
commitadcf4b2dea70e423339947f05b3bd5b4bf7a9255 (patch)
tree3dda7cbcf3fbda490dda77db762ecbfeffc93520 /gnu
parenta12f20207badae7e8b0a86b705130aaf339d6066 (diff)
When one shared library requires another, it will try to locate the
required shared library and include it in the link if it's not specified explicitly. This change makes ld look at the -L arguments specified, and build search path. This avoids the need for -rpath-link, and somewhat resembles the a.out linker behaviour. However behaviour of -rpath and -rpath-link is still preserved as a GNU extension. ok drahn, espie looked at it too
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/binutils/ld/emultempl/elf32.em32
1 files changed, 27 insertions, 5 deletions
diff --git a/gnu/usr.bin/binutils/ld/emultempl/elf32.em b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
index 2df71c1ee3e..82d8ba7166f 100644
--- a/gnu/usr.bin/binutils/ld/emultempl/elf32.em
+++ b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
@@ -467,14 +467,15 @@ gld${EMULATION_NAME}_after_open ()
linker will search. That means that we want to use
rpath_link, rpath, then the environment variable
LD_LIBRARY_PATH (native only), then the linker script
- LIB_SEARCH_DIRS. We do not search using the -L arguments.
+ LIB_SEARCH_DIRS. We look at the -L arguments to build
+ search path.
We search twice. The first time, we skip objects which may
introduce version mismatches. The second time, we force
their use. See gld${EMULATION_NAME}_vercheck comment. */
for (force = 0; force < 2; force++)
{
- const char *lib_path;
+ char *lib_path;
size_t len;
search_dirs_type *search;
@@ -484,20 +485,41 @@ gld${EMULATION_NAME}_after_open ()
if (gld${EMULATION_NAME}_search_needed (command_line.rpath,
l->name, force))
break;
- if (command_line.rpath_link == NULL
+ if (getenv("LD_RUN_PATH") != NULL
+ && command_line.rpath_link == NULL
&& command_line.rpath == NULL)
{
- lib_path = (const char *) getenv ("LD_RUN_PATH");
+ lib_path = getenv ("LD_RUN_PATH");
if (gld${EMULATION_NAME}_search_needed (lib_path, l->name,
force))
+ break;
+ }
+ len = strlen(search_head->name);
+ lib_path = xstrdup(search_head->name);
+ for (search = search_head->next; search != NULL;
+ search = search->next)
+ {
+ size_t nlen;
+
+ nlen = strlen(search->name);
+ lib_path = xrealloc(lib_path, len + nlen + 2);
+ lib_path[len] = ':';
+ strcpy(lib_path + len + 1, search->name);
+ len += nlen + 1;
+ }
+ if (gld${EMULATION_NAME}_search_needed (lib_path, l->name,
+ force))
+ {
+ free(lib_path);
break;
}
+ free(lib_path);
EOF
if [ "x${host}" = "x${target}" ] ; then
case " ${EMULATION_LIBPATH} " in
*" ${EMULATION_NAME} "*)
cat >>e${EMULATION_NAME}.c <<EOF
- lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
+ lib_path = getenv ("LD_LIBRARY_PATH");
if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force))
break;
EOF