Lines 522-527
gld${EMULATION_NAME}_add_sysroot (const
Link Here
|
522 |
|
522 |
|
523 |
EOF |
523 |
EOF |
524 |
case ${target} in |
524 |
case ${target} in |
|
|
525 |
*-*-freebsd*) |
526 |
cat >>e${EMULATION_NAME}.c <<EOF |
527 |
/* |
528 |
* Read the system search path the FreeBSD way rather than like Linux. |
529 |
*/ |
530 |
#include <elf-hints.h> |
531 |
|
532 |
static bfd_boolean |
533 |
gld${EMULATION_NAME}_check_ld_elf_hints (struct dt_needed *n, int force) |
534 |
{ |
535 |
const char *name = n->name; |
536 |
static bfd_boolean initialized; |
537 |
static char *ld_elf_hints; |
538 |
|
539 |
if (! initialized) |
540 |
{ |
541 |
FILE *f; |
542 |
char *tmppath; |
543 |
|
544 |
tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL); |
545 |
f = fopen (tmppath, FOPEN_RB); |
546 |
free (tmppath); |
547 |
if (f != NULL) |
548 |
{ |
549 |
struct elfhints_hdr hdr; |
550 |
|
551 |
if (fread(&hdr, 1, sizeof(hdr), f) == sizeof(hdr) && |
552 |
hdr.magic == ELFHINTS_MAGIC && |
553 |
hdr.version == 1) |
554 |
{ |
555 |
if (fseek(f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1) |
556 |
{ |
557 |
char *b; |
558 |
|
559 |
b = (char *) xmalloc (hdr.dirlistlen + 1); |
560 |
if (fread(b, 1, hdr.dirlistlen + 1, f) != |
561 |
hdr.dirlistlen + 1) |
562 |
{ |
563 |
free(b); |
564 |
b = NULL; |
565 |
} |
566 |
else |
567 |
{ |
568 |
ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b); |
569 |
free (b); |
570 |
} |
571 |
} |
572 |
} |
573 |
fclose (f); |
574 |
} |
575 |
|
576 |
initialized = TRUE; |
577 |
} |
578 |
|
579 |
if (ld_elf_hints == NULL) |
580 |
return FALSE; |
581 |
|
582 |
return gld${EMULATION_NAME}_search_needed (ld_elf_hints, n, force); |
583 |
} |
584 |
EOF |
585 |
# FreeBSD |
586 |
;; |
587 |
|
525 |
*-*-linux-gnu*) |
588 |
*-*-linux-gnu*) |
526 |
cat >>e${EMULATION_NAME}.c <<EOF |
589 |
cat >>e${EMULATION_NAME}.c <<EOF |
527 |
/* For a native linker, check the file /etc/ld.so.conf for directories |
590 |
/* For a native linker, check the file /etc/ld.so.conf for directories |
Lines 932-937
cat >>e${EMULATION_NAME}.c <<EOF
Link Here
|
932 |
EOF |
995 |
EOF |
933 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
996 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
934 |
case ${target} in |
997 |
case ${target} in |
|
|
998 |
*-*-freebsd*) |
999 |
cat >>e${EMULATION_NAME}.c <<EOF |
1000 |
if (gld${EMULATION_NAME}_check_ld_elf_hints (&n, force)) |
1001 |
break; |
1002 |
EOF |
1003 |
# FreeBSD |
1004 |
;; |
1005 |
|
935 |
*-*-linux-gnu*) |
1006 |
*-*-linux-gnu*) |
936 |
cat >>e${EMULATION_NAME}.c <<EOF |
1007 |
cat >>e${EMULATION_NAME}.c <<EOF |
937 |
if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) |
1008 |
if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) |