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