/[gentoo-alt]/trunk/overlay/sys-devel/binutils/files/binutils-2.16.91.0.6-ldhints.patch
Gentoo

Contents of /trunk/overlay/sys-devel/binutils/files/binutils-2.16.91.0.6-ldhints.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1083 - (show annotations) (download)
Mon Feb 20 21:25:47 2006 UTC (8 years, 10 months ago) by flameeyes
File size: 4901 byte(s)
Add binutils 2.16.1 and 2.16.91.6 with FreeBSD hints file loading patches.
1 Index: binutils-2.16.91.0.6/ld/Makefile.in
2 ===================================================================
3 --- binutils-2.16.91.0.6.orig/ld/Makefile.in
4 +++ binutils-2.16.91.0.6/ld/Makefile.in
5 @@ -446,6 +446,7 @@ ALL_EMULATIONS = \
6 ei386beos.o \
7 ei386bsd.o \
8 ei386coff.o \
9 + ei386freebsd.o \
10 ei386go32.o \
11 ei386linux.o \
12 ei386lynx.o \
13 @@ -1795,6 +1796,9 @@ ei386bsd.c: $(srcdir)/emulparams/i386bsd
14 ei386coff.c: $(srcdir)/emulparams/i386coff.sh \
15 $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS}
16 ${GENSCRIPTS} i386coff "$(tdir_i386coff)"
17 +ei386freebsd.c: $(srcdir)/emulparams/i386freebsd.sh \
18 + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
19 + ${GENSCRIPTS} i386freebsd "$(tdir_i386freebsd)"
20 ei386go32.c: $(srcdir)/emulparams/i386go32.sh \
21 $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386go32.sc ${GEN_DEPENDS}
22 ${GENSCRIPTS} i386go32 "$(tdir_i386go32)"
23 Index: binutils-2.16.91.0.6/ld/emulparams/i386freebsd.sh
24 ===================================================================
25 --- /dev/null
26 +++ binutils-2.16.91.0.6/ld/emulparams/i386freebsd.sh
27 @@ -0,0 +1,6 @@
28 +SCRIPT_NAME=aout
29 +TEXT_START_ADDR=0x1020
30 +OUTPUT_FORMAT="a.out-i386-freebsd"
31 +TARGET_PAGE_SIZE=0x1000
32 +ARCH=i386
33 +EXECUTABLE_SYMBOLS='__DYNAMIC = 0;'
34 Index: binutils-2.16.91.0.6/ld/emultempl/elf32.em
35 ===================================================================
36 --- binutils-2.16.91.0.6.orig/ld/emultempl/elf32.em
37 +++ binutils-2.16.91.0.6/ld/emultempl/elf32.em
38 @@ -529,6 +529,95 @@ gld${EMULATION_NAME}_add_sysroot (const
39
40 EOF
41 case ${target} in
42 + *-*-freebsd*)
43 + cat >>e${EMULATION_NAME}.c <<EOF
44 +/*
45 + * Read the system search path the FreeBSD way rather than like Linux.
46 + */
47 +#ifdef HAVE_ELF_HINTS_H
48 +#include <elf-hints.h>
49 +#else
50 + /*
51 + * Fallback code took from FreeBSD's libc
52 + * Copyright (c) 1997 John D. Polstra.
53 + *
54 + * This works only if the hints file is generated with a compatible version
55 + * of ldconfig (most FreeBSD up to 6.1 and DragonFly at least up to 1.4),
56 + * and with the same endianness.
57 + */
58 +
59 + struct elfhints_hdr {
60 + u_int32_t magic; /* Magic number */
61 + u_int32_t version; /* File version (1) */
62 + u_int32_t strtab; /* Offset of string table in file */
63 + u_int32_t strsize; /* Size of string table */
64 + u_int32_t dirlist; /* Offset of directory list in
65 + string table */
66 + u_int32_t dirlistlen; /* strlen(dirlist) */
67 + u_int32_t spare[26]; /* Room for expansion */
68 + };
69 +
70 + #define ELFHINTS_MAGIC 0x746e6845
71 +
72 + #define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
73 +#endif
74 +
75 +static bfd_boolean
76 +gld${EMULATION_NAME}_check_ld_elf_hints (struct dt_needed *n, int force)
77 +{
78 + const char *name = n->name;
79 + static bfd_boolean initialized;
80 + static char *ld_elf_hints;
81 +
82 + if (! initialized)
83 + {
84 + FILE *f;
85 + char *tmppath;
86 +
87 + tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL);
88 + f = fopen (tmppath, FOPEN_RB);
89 + free (tmppath);
90 + if (f != NULL)
91 + {
92 + struct elfhints_hdr hdr;
93 +
94 + if (fread(&hdr, 1, sizeof(hdr), f) == sizeof(hdr) &&
95 + hdr.magic == ELFHINTS_MAGIC &&
96 + hdr.version == 1)
97 + {
98 + if (fseek(f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1)
99 + {
100 + char *b;
101 +
102 + b = (char *) xmalloc (hdr.dirlistlen + 1);
103 + if (fread(b, 1, hdr.dirlistlen + 1, f) !=
104 + hdr.dirlistlen + 1)
105 + {
106 + free(b);
107 + b = NULL;
108 + }
109 + else
110 + {
111 + ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b);
112 + free (b);
113 + }
114 + }
115 + }
116 + fclose (f);
117 + }
118 +
119 + initialized = TRUE;
120 + }
121 +
122 + if (ld_elf_hints == NULL)
123 + return FALSE;
124 +
125 + return gld${EMULATION_NAME}_search_needed (ld_elf_hints, n, force);
126 +}
127 +EOF
128 + # FreeBSD
129 + ;;
130 +
131 *-*-linux-* | *-*-k*bsd*-*)
132 cat >>e${EMULATION_NAME}.c <<EOF
133 /* For a native linker, check the file /etc/ld.so.conf for directories
134 @@ -921,6 +1010,14 @@ EOF
135 fi
136 if [ "x${USE_LIBPATH}" = xyes ] ; then
137 case ${target} in
138 + *-*-freebsd*)
139 + cat >>e${EMULATION_NAME}.c <<EOF
140 + if (gld${EMULATION_NAME}_check_ld_elf_hints (&n, force))
141 + break;
142 +EOF
143 + # FreeBSD
144 + ;;
145 +
146 *-*-linux-* | *-*-k*bsd*-*)
147 # Linux
148 cat >>e${EMULATION_NAME}.c <<EOF
149 Index: binutils-2.16.91.0.6/ld/configure.in
150 ===================================================================
151 --- binutils-2.16.91.0.6.orig/ld/configure.in
152 +++ binutils-2.16.91.0.6/ld/configure.in
153 @@ -99,7 +99,7 @@ AC_SUBST(HOSTING_CRT0)
154 AC_SUBST(HOSTING_LIBS)
155 AC_SUBST(NATIVE_LIB_DIRS)
156
157 -AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
158 +AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h)
159 AC_CHECK_FUNCS(sbrk realpath glob)
160 AC_HEADER_DIRENT
161

  ViewVC Help
Powered by ViewVC 1.1.20