Lines 529-534
gld${EMULATION_NAME}_add_sysroot (const
Link Here
|
529 |
|
529 |
|
530 |
EOF |
530 |
EOF |
531 |
case ${target} in |
531 |
case ${target} in |
|
|
532 |
*-*-freebsd*) |
533 |
cat >>e${EMULATION_NAME}.c <<EOF |
534 |
/* |
535 |
* Read the system search path the FreeBSD way rather than like Linux. |
536 |
*/ |
537 |
#include <elf-hints.h> |
538 |
|
539 |
static bfd_boolean |
540 |
gld${EMULATION_NAME}_check_ld_elf_hints (struct dt_needed *n, int force) |
541 |
{ |
542 |
const char *name = n->name; |
543 |
static bfd_boolean initialized; |
544 |
static char *ld_elf_hints; |
545 |
|
546 |
if (! initialized) |
547 |
{ |
548 |
FILE *f; |
549 |
char *tmppath; |
550 |
|
551 |
tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL); |
552 |
f = fopen (tmppath, FOPEN_RB); |
553 |
free (tmppath); |
554 |
if (f != NULL) |
555 |
{ |
556 |
struct elfhints_hdr hdr; |
557 |
|
558 |
if (fread(&hdr, 1, sizeof(hdr), f) == sizeof(hdr) && |
559 |
hdr.magic == ELFHINTS_MAGIC && |
560 |
hdr.version == 1) |
561 |
{ |
562 |
if (fseek(f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1) |
563 |
{ |
564 |
char *b; |
565 |
|
566 |
b = (char *) xmalloc (hdr.dirlistlen + 1); |
567 |
if (fread(b, 1, hdr.dirlistlen + 1, f) != |
568 |
hdr.dirlistlen + 1) |
569 |
{ |
570 |
free(b); |
571 |
b = NULL; |
572 |
} |
573 |
else |
574 |
{ |
575 |
ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b); |
576 |
free (b); |
577 |
} |
578 |
} |
579 |
} |
580 |
fclose (f); |
581 |
} |
582 |
|
583 |
initialized = TRUE; |
584 |
} |
585 |
|
586 |
if (ld_elf_hints == NULL) |
587 |
return FALSE; |
588 |
|
589 |
return gld${EMULATION_NAME}_search_needed (ld_elf_hints, n, force); |
590 |
} |
591 |
EOF |
592 |
# FreeBSD |
593 |
;; |
594 |
|
532 |
*-*-linux-* | *-*-k*bsd*-*) |
595 |
*-*-linux-* | *-*-k*bsd*-*) |
533 |
cat >>e${EMULATION_NAME}.c <<EOF |
596 |
cat >>e${EMULATION_NAME}.c <<EOF |
534 |
/* For a native linker, check the file /etc/ld.so.conf for directories |
597 |
/* For a native linker, check the file /etc/ld.so.conf for directories |
Lines 921-926
EOF
Link Here
|
921 |
fi |
984 |
fi |
922 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
985 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
923 |
case ${target} in |
986 |
case ${target} in |
|
|
987 |
*-*-freebsd*) |
988 |
cat >>e${EMULATION_NAME}.c <<EOF |
989 |
if (gld${EMULATION_NAME}_check_ld_elf_hints (&n, force)) |
990 |
break; |
991 |
EOF |
992 |
# FreeBSD |
993 |
;; |
994 |
|
924 |
*-*-linux-* | *-*-k*bsd*-*) |
995 |
*-*-linux-* | *-*-k*bsd*-*) |
925 |
# Linux |
996 |
# Linux |
926 |
cat >>e${EMULATION_NAME}.c <<EOF |
997 |
cat >>e${EMULATION_NAME}.c <<EOF |