* Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try
@ 2006-03-21 22:52 Diego 'Flameeyes' Pettenò
2006-03-21 23:59 ` Mike Frysinger
2006-04-11 13:12 ` Nick Clifton
0 siblings, 2 replies; 3+ messages in thread
From: Diego 'Flameeyes' Pettenò @ 2006-03-21 22:52 UTC (permalink / raw)
To: binutils
[-- Attachment #1.1: Type: text/plain, Size: 888 bytes --]
Okay, new version of the patch, this time it includes an almost verbatim copy
of the elf-hints header file from FreeBSD as elf-hints-local.h, that is
included if the elf-hints.h file is not present in the system already, so
that it works when building non systems not using FreeBSD's or DragonFly's
libc,but still defaults to system's headers if they are present, so that if
they change the signature it works fine anyway.
This should solve the license issues, too.
I also fixed the code style, thanks to Nick Clifton for pointing this out and
Mike Frysinger for helping me by checking the code after passing it through
indent.
I'm not quite sure about the changelog entry though... what should i put, and
more importantly where?
--
Diego "Flameeyes" Pettenò - http://dev.gentoo.org/~flameeyes/
Gentoo/ALT lead, Gentoo/FreeBSD, Video, AMD64, Sound, PAM, KDE
[-- Attachment #1.2: binutils-2.16.91.0.7-ldhints.patch --]
[-- Type: text/x-diff, Size: 5688 bytes --]
Index: binutils-2.16.91.0.7/ld/emultempl/elf32.em
===================================================================
--- binutils-2.16.91.0.7.orig/ld/emultempl/elf32.em
+++ binutils-2.16.91.0.7/ld/emultempl/elf32.em
@@ -529,6 +529,69 @@ gld${EMULATION_NAME}_add_sysroot (const
EOF
case ${target} in
+ *-*-freebsd* | *-*-dragonfly*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+/* Read the system search path the FreeBSD way rather than like Linux. */
+#ifdef HAVE_ELF_HINTS_H
+#include <elf-hints.h>
+#else
+#include "elf-hints-local.h"
+#endif
+
+static bfd_boolean
+gld${EMULATION_NAME}_check_ld_elf_hints (const char *name, int force)
+{
+ static bfd_boolean initialized;
+ static char *ld_elf_hints;
+ struct dt_needed needed;
+
+ if (!initialized)
+ {
+ FILE *f;
+ char *tmppath;
+
+ tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL);
+ f = fopen (tmppath, FOPEN_RB);
+ free (tmppath);
+ if (f != NULL)
+ {
+ struct elfhints_hdr hdr;
+
+ if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr)
+ && hdr.magic == ELFHINTS_MAGIC && hdr.version == 1)
+ {
+ if (fseek (f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1)
+ {
+ char *b;
+
+ b = (char *) xmalloc (hdr.dirlistlen + 1);
+ if (fread (b, 1, hdr.dirlistlen + 1, f) ==
+ hdr.dirlistlen + 1)
+ {
+ ld_elf_hints =
+ gld${EMULATION_NAME}_add_sysroot (b);
+ }
+ free (b);
+ }
+ }
+ fclose (f);
+ }
+
+ initialized = TRUE;
+ }
+
+ if (ld_elf_hints == NULL)
+ return FALSE;
+
+ needed.by = NULL;
+ needed.name = name;
+ return gld${EMULATION_NAME}_search_needed (ld_elf_hints, &needed,
+ force);
+}
+EOF
+ # FreeBSD
+ ;;
+
*-*-linux-* | *-*-k*bsd*-*)
cat >>e${EMULATION_NAME}.c <<EOF
/* For a native linker, check the file /etc/ld.so.conf for directories
@@ -921,6 +984,14 @@ EOF
fi
if [ "x${USE_LIBPATH}" = xyes ] ; then
case ${target} in
+ *-*-freebsd* | *-*-dragonfly*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ if (gld${EMULATION_NAME}_check_ld_elf_hints (l->name, force))
+ break;
+EOF
+ # FreeBSD
+ ;;
+
*-*-linux-* | *-*-k*bsd*-*)
# Linux
cat >>e${EMULATION_NAME}.c <<EOF
Index: binutils-2.16.91.0.7/ld/configure.in
===================================================================
--- binutils-2.16.91.0.7.orig/ld/configure.in
+++ binutils-2.16.91.0.7/ld/configure.in
@@ -99,7 +99,7 @@ AC_SUBST(HOSTING_CRT0)
AC_SUBST(HOSTING_LIBS)
AC_SUBST(NATIVE_LIB_DIRS)
-AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h)
+AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h)
AC_CHECK_FUNCS(sbrk realpath glob)
AC_HEADER_DIRENT
Index: binutils-2.16.91.0.7/ld/Makefile.am
===================================================================
--- binutils-2.16.91.0.7.orig/ld/Makefile.am
+++ binutils-2.16.91.0.7/ld/Makefile.am
@@ -414,7 +414,7 @@ CFILES = ldctor.c ldemul.c ldexp.c ldfil
HFILES = ld.h ldctor.h ldemul.h ldexp.h ldfile.h \
ldlang.h ldlex.h ldmain.h ldmisc.h ldver.h \
- ldwrite.h mri.h deffile.h pe-dll.h
+ ldwrite.h mri.h deffile.h pe-dll.h elf-hints-local.h
GENERATED_CFILES = ldgram.c ldlex.c deffilep.c
GENERATED_HFILES = ldgram.h ldemul-list.h deffilep.h
Index: binutils-2.16.91.0.7/ld/elf-hints-local.h
===================================================================
--- /dev/null
+++ binutils-2.16.91.0.7/ld/elf-hints-local.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1997 John D. Polstra.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/elf-hints.h,v 1.4 2001/05/02 23:56:17 obrien Exp $
+ */
+
+#ifndef _ELF_HINTS_H_
+#define _ELF_HINTS_H_
+
+/*
+ * Hints file produced by ldconfig.
+ */
+struct elfhints_hdr
+{
+ u_int32_t magic; /* Magic number */
+ u_int32_t version; /* File version (1) */
+ u_int32_t strtab; /* Offset of string table in file */
+ u_int32_t strsize; /* Size of string table */
+ u_int32_t dirlist; /* Offset of directory list in
+ string table */
+ u_int32_t dirlistlen; /* strlen(dirlist) */
+ u_int32_t spare[26]; /* Room for expansion */
+};
+
+#define ELFHINTS_MAGIC 0x746e6845
+
+#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
+
+#endif /* !_ELF_HINTS_H_ */
[-- Attachment #2: Type: application/pgp-signature, Size: 191 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try
2006-03-21 22:52 Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try Diego 'Flameeyes' Pettenò
@ 2006-03-21 23:59 ` Mike Frysinger
2006-04-11 13:12 ` Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2006-03-21 23:59 UTC (permalink / raw)
To: binutils; +Cc: flameeyes
On Tuesday 21 March 2006 16:23, Diego 'Flameeyes' Pettenò wrote:
> I'm not quite sure about the changelog entry though... what should i put,
something like this i imagine:
2006-03-21 Diego Pettenò <flameeyes@gentoo.org>
* emultempl/elf32.em: Add support for elf-hints.h on FreeBSD
and Dragonfly targets.
* configure.in (AC_CHECK_HEADERS): Add elf-hints.h.
* Makefile.am (HFILES): Add elf-hints-local.h.
* elf-hints-local.h: New file.
> and more importantly where?
include it in the header of the patch itself ... since this patch is against
only the ld subdir and ld has its own ChangeLog, you omit the 'ld/' from the
filenames since this change entries will go into ld/ChangeLog
-mike
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try
2006-03-21 22:52 Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try Diego 'Flameeyes' Pettenò
2006-03-21 23:59 ` Mike Frysinger
@ 2006-04-11 13:12 ` Nick Clifton
1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2006-04-11 13:12 UTC (permalink / raw)
To: Diego 'Flameeyes' Pettenò; +Cc: binutils
Hi Diego,
> Okay, new version of the patch, this time it includes an almost verbatim copy
> of the elf-hints header file from FreeBSD as elf-hints-local.h, that is
> included if the elf-hints.h file is not present in the system already, so
> that it works when building non systems not using FreeBSD's or DragonFly's
> libc,but still defaults to system's headers if they are present, so that if
> they change the signature it works fine anyway.
> This should solve the license issues, too.
Thanks - I have checked your patch in together with this ChangeLog entry.
Cheers
Nick
ld/ChangeLog
2006-04-11 Diego Petteno <flameeyes@gentoo.org>
* emultempl/elf32.em: Add support for elf-hints.h on FreeBSD
and Dragonfly targets.
* configure.in (AC_CHECK_HEADERS): Add elf-hints.h.
* Makefile.am (HFILES): Add elf-hints-local.h.
* elf-hints-local.h: New file.
* Makefile.in: Regenerate.
* configure: Regenerate.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-11 10:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-21 22:52 Add support for ld-elf.so.hints on FreeBSD and DragonFly - Fourth try Diego 'Flameeyes' Pettenò
2006-03-21 23:59 ` Mike Frysinger
2006-04-11 13:12 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).