aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-04-11 10:36:26 +0000
committerNick Clifton <nickc@redhat.com>2006-04-11 10:36:26 +0000
commitebe1fac16186a77f5b2d971ac10e42a6b3b5b608 (patch)
treed992aa942a0879cb2815dbe5aa9bee683909acc1 /ld/emultempl
parent0f84642536077e28c9d2f749cd3554404060b894 (diff)
downloadgdb-ebe1fac16186a77f5b2d971ac10e42a6b3b5b608.zip
gdb-ebe1fac16186a77f5b2d971ac10e42a6b3b5b608.tar.gz
gdb-ebe1fac16186a77f5b2d971ac10e42a6b3b5b608.tar.bz2
* emultempl/elf32.em: Add support for elf-hints.h on FreeBSD and Dragonfly targets.
* configure.in (AC_CHECK_HEADERS): Add elf-hints.h. * Makefile.am (HFILES): Add elf-hints-local.h. * elf-hints-local.h: New file. * Makefile.in: Regenerate. * configure: Regenerate.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/elf32.em70
1 files changed, 70 insertions, 0 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 537d9dc..dffcff8 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -529,6 +529,68 @@ gld${EMULATION_NAME}_add_sysroot (const char *path)
EOF
case ${target} in
+ *-*-freebsd* | *-*-dragonfly*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+/* Read the system search path the FreeBSD way rather than the Linux way. */
+#ifdef HAVE_ELF_HINTS_H
+#include <elf-hints.h>
+#else
+#include "elf-hints-local.h"
+#endif
+
+static bfd_boolean
+gld${EMULATION_NAME}_check_ld_elf_hints (const char *name, int force)
+{
+ static bfd_boolean initialized;
+ static char *ld_elf_hints;
+ struct dt_needed needed;
+
+ if (!initialized)
+ {
+ FILE *f;
+ char *tmppath;
+
+ tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL);
+ f = fopen (tmppath, FOPEN_RB);
+ free (tmppath);
+ 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 = xmalloc (hdr.dirlistlen + 1);
+ if (fread (b, 1, hdr.dirlistlen + 1, f) ==
+ hdr.dirlistlen + 1)
+ ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b);
+
+ free (b);
+ }
+ }
+ fclose (f);
+ }
+
+ initialized = TRUE;
+ }
+
+ if (ld_elf_hints == NULL)
+ return FALSE;
+
+ needed.by = NULL;
+ needed.name = name;
+ return gld${EMULATION_NAME}_search_needed (ld_elf_hints, & needed,
+ force);
+}
+EOF
+ # FreeBSD
+ ;;
+
*-*-linux-* | *-*-k*bsd*-*)
cat >>e${EMULATION_NAME}.c <<EOF
/* For a native linker, check the file /etc/ld.so.conf for directories
@@ -928,6 +990,14 @@ EOF
fi
if [ "x${USE_LIBPATH}" = xyes ] ; then
case ${target} in
+ *-*-freebsd* | *-*-dragonfly*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force))
+ break;
+EOF
+ # FreeBSD
+ ;;
+
*-*-linux-* | *-*-k*bsd*-*)
# Linux
cat >>e${EMULATION_NAME}.c <<EOF