Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 123496 | Differences between
and this patch

Collapse All | Expand All

(-)binutils-2.16.91.0.6/ld/Makefile.in (+4 lines)
Lines 446-451 ALL_EMULATIONS = \ Link Here
446
	ei386beos.o \
446
	ei386beos.o \
447
	ei386bsd.o \
447
	ei386bsd.o \
448
	ei386coff.o \
448
	ei386coff.o \
449
	ei386freebsd.o \
449
	ei386go32.o \
450
	ei386go32.o \
450
	ei386linux.o \
451
	ei386linux.o \
451
	ei386lynx.o \
452
	ei386lynx.o \
Lines 1795-1800 ei386bsd.c: $(srcdir)/emulparams/i386bsd Link Here
1795
ei386coff.c: $(srcdir)/emulparams/i386coff.sh \
1796
ei386coff.c: $(srcdir)/emulparams/i386coff.sh \
1796
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS}
1797
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS}
1797
	${GENSCRIPTS} i386coff "$(tdir_i386coff)"
1798
	${GENSCRIPTS} i386coff "$(tdir_i386coff)"
1799
ei386freebsd.c: $(srcdir)/emulparams/i386freebsd.sh \
1800
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
1801
	${GENSCRIPTS} i386freebsd "$(tdir_i386freebsd)"
1798
ei386go32.c: $(srcdir)/emulparams/i386go32.sh \
1802
ei386go32.c: $(srcdir)/emulparams/i386go32.sh \
1799
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386go32.sc ${GEN_DEPENDS}
1803
  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386go32.sc ${GEN_DEPENDS}
1800
	${GENSCRIPTS} i386go32 "$(tdir_i386go32)"
1804
	${GENSCRIPTS} i386go32 "$(tdir_i386go32)"
(-)binutils-2.16.91.0.6/ld/emulparams/i386freebsd.sh (+6 lines)
Line 0 Link Here
1
SCRIPT_NAME=aout
2
TEXT_START_ADDR=0x1020
3
OUTPUT_FORMAT="a.out-i386-freebsd"
4
TARGET_PAGE_SIZE=0x1000
5
ARCH=i386
6
EXECUTABLE_SYMBOLS='__DYNAMIC = 0;'
(-)binutils-2.16.91.0.6/ld/emultempl/elf32.em (+97 lines)
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
(-)binutils-2.16.91.0.6/ld/configure.in (-1 / +1 lines)
Lines 99-105 AC_SUBST(HOSTING_CRT0) Link Here
99
AC_SUBST(HOSTING_LIBS)
99
AC_SUBST(HOSTING_LIBS)
100
AC_SUBST(NATIVE_LIB_DIRS)
100
AC_SUBST(NATIVE_LIB_DIRS)
101
101
102
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
102
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h)
103
AC_CHECK_FUNCS(sbrk realpath glob)
103
AC_CHECK_FUNCS(sbrk realpath glob)
104
AC_HEADER_DIRENT
104
AC_HEADER_DIRENT
105
105

Return to bug 123496