diff options
author | peter <peter@FreeBSD.org> | 1999-01-07 14:03:27 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-01-07 14:03:27 +0000 |
commit | d3a68b2218865fe260aba70f878854dd945b07d4 (patch) | |
tree | ed128b53935d24931ec40a8a37289d71d1c0e0b7 /contrib | |
parent | edc7d9f14b64bef899706c8224a0835b613c0086 (diff) | |
download | FreeBSD-src-d3a68b2218865fe260aba70f878854dd945b07d4.zip FreeBSD-src-d3a68b2218865fe260aba70f878854dd945b07d4.tar.gz |
ld was kinly looking up the Linux /etc/ld.so.conf (which we don't have).
Teach it about the FreeBSD equivalent, because there are some funny things
going on with -rpath that I can't quite get a handle on. It looks like
setting an rpath on a new shared object overrides all the implicit
DT_RPATH's from the dependencies, causing them to fail at link time
(but not runtime).
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/binutils/ld/emultempl/elf32.em | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/contrib/binutils/ld/emultempl/elf32.em b/contrib/binutils/ld/emultempl/elf32.em index c4debe2..ece1d2e 100644 --- a/contrib/binutils/ld/emultempl/elf32.em +++ b/contrib/binutils/ld/emultempl/elf32.em @@ -139,8 +139,69 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) EOF if [ "x${host}" = "x${target}" ] ; then if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then -cat >>e${EMULATION_NAME}.c <<EOF + case ${target} in + *-*-freebsd*) + cat >>e${EMULATION_NAME}.c <<EOF +/* + * Read the system search path the FreeBSD way rather than like Linux. + */ +#include <elf.h> + +static boolean gld${EMULATION_NAME}_check_ld_elf_hints + PARAMS ((const char *, int)); + +static boolean +gld${EMULATION_NAME}_check_ld_elf_hints (name, force) + const char *name; + int force; +{ + static boolean initialized; + static char *ld_elf_hints; + + if (! initialized) + { + FILE *f; + + f = fopen (_PATH_ELF_HINTS, FOPEN_RB); + if (f != NULL) + { + struct elfhints_hdr hdr; + + if (fread(&hdr, 1, sizeof(hdr), f) == sizeof(hdr) && + hdr.magic == ELFHINTS_MAGIC && + hdr.version == 1) + { + if (fseek(f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1) + { + char *b; + + b = (char *) xmalloc (hdr.dirlistlen + 1); + if (fread(b, 1, hdr.dirlistlen + 1, f) != + hdr.dirlistlen + 1) + { + free(b); + } + else + { + ld_elf_hints = b; + } + } + } + fclose (f); + } + initialized = true; + } + + if (ld_elf_hints == NULL) + return false; + + return gld${EMULATION_NAME}_search_needed (ld_elf_hints, name, force); +} +EOF + ;; + *) + cat >>e${EMULATION_NAME}.c <<EOF /* For a native linker, check the file /etc/ld.so.conf for directories in which we may find shared libraries. /etc/ld.so.conf is really only meaningful on Linux, but we check it on other systems anyhow. */ @@ -221,8 +282,8 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force) return gld${EMULATION_NAME}_search_needed (ld_so_conf, name, force); } - EOF + esac fi fi cat >>e${EMULATION_NAME}.c <<EOF @@ -335,10 +396,20 @@ cat >>e${EMULATION_NAME}.c <<EOF EOF if [ "x${host}" = "x${target}" ] ; then if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then -cat >>e${EMULATION_NAME}.c <<EOF + case ${target} in + *-*-freebsd*) + cat >>e${EMULATION_NAME}.c <<EOF + if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force)) + break; +EOF + ;; + *) + cat >>e${EMULATION_NAME}.c <<EOF if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) break; EOF + ;; + esac fi fi cat >>e${EMULATION_NAME}.c <<EOF |