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 |
#ifdef HAVE_ELF_HINTS_H |
531 |
#include <elf-hints.h> |
532 |
#else |
533 |
/* |
534 |
* Fallback code took from FreeBSD's libc |
535 |
* Copyright (c) 1997 John D. Polstra. |
536 |
* |
537 |
* This works only if the hints file is generated with a compatible version |
538 |
* of ldconfig (most FreeBSD up to 6.1 and DragonFly at least up to 1.4), |
539 |
* and with the same endianness. |
540 |
*/ |
541 |
|
542 |
struct elfhints_hdr { |
543 |
u_int32_t magic; /* Magic number */ |
544 |
u_int32_t version; /* File version (1) */ |
545 |
u_int32_t strtab; /* Offset of string table in file */ |
546 |
u_int32_t strsize; /* Size of string table */ |
547 |
u_int32_t dirlist; /* Offset of directory list in |
548 |
string table */ |
549 |
u_int32_t dirlistlen; /* strlen(dirlist) */ |
550 |
u_int32_t spare[26]; /* Room for expansion */ |
551 |
}; |
552 |
|
553 |
#define ELFHINTS_MAGIC 0x746e6845 |
554 |
|
555 |
#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints" |
556 |
#endif |
557 |
|
558 |
static bfd_boolean |
559 |
gld${EMULATION_NAME}_check_ld_elf_hints (struct dt_needed *n, int force) |
560 |
{ |
561 |
const char *name = n->name; |
562 |
static bfd_boolean initialized; |
563 |
static char *ld_elf_hints; |
564 |
|
565 |
if (! initialized) |
566 |
{ |
567 |
FILE *f; |
568 |
char *tmppath; |
569 |
|
570 |
tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL); |
571 |
f = fopen (tmppath, FOPEN_RB); |
572 |
free (tmppath); |
573 |
if (f != NULL) |
574 |
{ |
575 |
struct elfhints_hdr hdr; |
576 |
|
577 |
if (fread(&hdr, 1, sizeof(hdr), f) == sizeof(hdr) && |
578 |
hdr.magic == ELFHINTS_MAGIC && |
579 |
hdr.version == 1) |
580 |
{ |
581 |
if (fseek(f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1) |
582 |
{ |
583 |
char *b; |
584 |
|
585 |
b = (char *) xmalloc (hdr.dirlistlen + 1); |
586 |
if (fread(b, 1, hdr.dirlistlen + 1, f) != |
587 |
hdr.dirlistlen + 1) |
588 |
{ |
589 |
free(b); |
590 |
b = NULL; |
591 |
} |
592 |
else |
593 |
{ |
594 |
ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b); |
595 |
free (b); |
596 |
} |
597 |
} |
598 |
} |
599 |
fclose (f); |
600 |
} |
601 |
|
602 |
initialized = TRUE; |
603 |
} |
604 |
|
605 |
if (ld_elf_hints == NULL) |
606 |
return FALSE; |
607 |
|
608 |
return gld${EMULATION_NAME}_search_needed (ld_elf_hints, n, force); |
609 |
} |
610 |
EOF |
611 |
# FreeBSD |
612 |
;; |
613 |
|
525 |
*-*-linux-gnu*) |
614 |
*-*-linux-gnu*) |
526 |
cat >>e${EMULATION_NAME}.c <<EOF |
615 |
cat >>e${EMULATION_NAME}.c <<EOF |
527 |
/* For a native linker, check the file /etc/ld.so.conf for directories |
616 |
/* 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 |
1021 |
EOF |
933 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
1022 |
if [ "x${USE_LIBPATH}" = xyes ] ; then |
934 |
case ${target} in |
1023 |
case ${target} in |
|
|
1024 |
*-*-freebsd*) |
1025 |
cat >>e${EMULATION_NAME}.c <<EOF |
1026 |
if (gld${EMULATION_NAME}_check_ld_elf_hints (&n, force)) |
1027 |
break; |
1028 |
EOF |
1029 |
# FreeBSD |
1030 |
;; |
1031 |
|
935 |
*-*-linux-gnu*) |
1032 |
*-*-linux-gnu*) |
936 |
cat >>e${EMULATION_NAME}.c <<EOF |
1033 |
cat >>e${EMULATION_NAME}.c <<EOF |
937 |
if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) |
1034 |
if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) |