wok rev 12702

Add: cross-arm-glibc (2.14.1)
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 03 18:07:11 2012 +0200 (2012-05-03)
parents 6fef0ccec331
children b981e20f2719
files cross-arm-glibc/receipt cross-arm-glibc/stuff/glibc-2.14-reexport-rpc-interface.patch cross-arm-glibc/stuff/glibc-2.14-reinstall-nis-rpc-headers.patch cross-arm-glibc/stuff/glibc-2.14-revert-4768ae77.patch cross-arm-glibc/stuff/glibc-2.14.1-fixes-1.patch cross-arm-glibc/stuff/glibc-2.14.1-gcc_fix-1.patch cross-arm-glibc/stuff/glibc-2.14.1-sort-1.patch
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cross-arm-glibc/receipt	Thu May 03 18:07:11 2012 +0200
     1.3 @@ -0,0 +1,74 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="cross-arm-glibc"
     1.7 +VERSION="2.14.1"
     1.8 +CATEGORY="system-tools"
     1.9 +SHORT_DESC="The GNU C libraries for the ARM cross toolchain"
    1.10 +MAINTAINER="pankso@slitaz.org"
    1.11 +SOURCE="glibc"
    1.12 +TARBALL="$SOURCE-$VERSION.tar.gz"
    1.13 +WEB_SITE="http://www.gnu.org/software/libc/"
    1.14 +WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL"
    1.15 +
    1.16 +DEPENDS=""
    1.17 +BUILD_DEPENDS="linux-arm-api-headers cross-arm-binutils cross-arm-gcc \
    1.18 +autoconf bash gawk"
    1.19 +
    1.20 +# Cross toolchain variables.
    1.21 +CROSS_TARGET="arm-slitaz-linux-gnueabi"
    1.22 +CROSS_PREFIX="/usr/cross/arm"
    1.23 +CROSS_TRIPLET="--build=$HOST_SYSTEM --host=$HOST_SYSTEM --target=$CROSS_TARGET"
    1.24 +
    1.25 +# CFLAGS and CXXFLAGS must not be set during the building of cross-tools.
    1.26 +unset CFLAGS CXXFLAGS CONFIG_SITE
    1.27 +
    1.28 +# Path to cross tools
    1.29 +export PATH=$PATH:$CROSS_PREFIX/bin
    1.30 +
    1.31 +# Rules to configure and make the package.
    1.32 +compile_rules()
    1.33 +{
    1.34 +	echo "cook: make linux/version.h"
    1.35 +	cd $CROSS_PREFIX/include
    1.36 +	make linux/version.h
    1.37 +
    1.38 +	cd $src
    1.39 +
    1.40 +	# Glibc ports.
    1.41 +	if [ ! -f "$SRC/glibc-ports-$VERSION.tar.bz2" ]; then
    1.42 +		wget $GNU_MIRROR/$SOURCE/glibc-ports-$VERSION.tar.bz2 \
    1.43 +			-O $SRC/glibc-ports-$VERSION.tar.bz2
    1.44 +	fi
    1.45 +	echo "Extracting glibc-ports..."
    1.46 +	tar xjf $SRC/glibc-ports-$VERSION.tar.bz2
    1.47 +	mv glibc-ports-$VERSION ports
    1.48 +
    1.49 +	# #define TLS_DTV_UNALLOCATED ((void *) -1l) is already in dl-tls.h
    1.50 +	#echo "#define TLS_DTV_UNALLOCATED ((void *) -1l)" \
    1.51 +	#	>> ports/sysdeps/arm/dl-tls.h
    1.52 +
    1.53 +	mkdir ../glibc-build && cd ../glibc-build
    1.54 +	CC=$CROSS_PREFIX/bin/$CROSS_TARGET-gcc
    1.55 +	echo "libc_cv_forced_unwind=yes" > config.cache
    1.56 +	echo "libc_cv_c_cleanup=yes" >> config.cache
    1.57 +	$src/configure \
    1.58 +		--prefix=$CROSS_PREFIX \
    1.59 +		--enable-add-ons \
    1.60 +		--with-headers=$CROSS_PREFIX/include \
    1.61 +		--with-binutils=$CROSS_PREFIX/bin \
    1.62 +		--config-cache \
    1.63 +		--build=$HOST_SYSTEM \
    1.64 +		--host=$CROSS_TARGET &&
    1.65 +	make && make install_root=$DESTDIR install
    1.66 +}
    1.67 +
    1.68 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.69 +genpkg_rules()
    1.70 +{
    1.71 +	mkdir -p $fs/usr
    1.72 +	cp -a $install/usr/cross $fs/usr
    1.73 +	#cd ${fs}${CROSS_PREFIX}/$CROSS_TARGET
    1.74 +	#rm -rf lib include
    1.75 +	#ln -s ../lib lib
    1.76 +	#ln -s ../include include
    1.77 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/cross-arm-glibc/stuff/glibc-2.14-reexport-rpc-interface.patch	Thu May 03 18:07:11 2012 +0200
     2.3 @@ -0,0 +1,26 @@
     2.4 +diff --git a/include/libc-symbols.h b/include/libc-symbols.h
     2.5 +index 67e1ca2..5e7cca5 100644
     2.6 +--- a/include/libc-symbols.h
     2.7 ++++ b/include/libc-symbols.h
     2.8 +@@ -635,7 +635,7 @@ for linking")
     2.9 + # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
    2.10 + # define libc_hidden_def(name) hidden_def (name)
    2.11 + # define libc_hidden_weak(name) hidden_weak (name)
    2.12 +-# define libc_hidden_nolink(name, version) hidden_nolink (name, libc, version)
    2.13 ++# define libc_hidden_nolink(name, version) hidden_def (name)
    2.14 + # define libc_hidden_ver(local, name) hidden_ver (local, name)
    2.15 + # define libc_hidden_data_def(name) hidden_data_def (name)
    2.16 + # define libc_hidden_data_weak(name) hidden_data_weak (name)
    2.17 +diff --git a/sunrpc/Makefile b/sunrpc/Makefile
    2.18 +index 5134ce9..40c73d1 100644
    2.19 +--- a/sunrpc/Makefile
    2.20 ++++ b/sunrpc/Makefile
    2.21 +@@ -53,7 +53,7 @@ headers-in-tirpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \
    2.22 + 				    des_crypt.h)
    2.23 + headers-not-in-tirpc = $(addprefix rpc/,key_prot.h rpc_des.h) \
    2.24 + 		       $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
    2.25 +-headers = rpc/netdb.h
    2.26 ++headers = rpc/netdb.h $(headers-in-tirpc) $(headers-not-in-tirpc)
    2.27 + install-others = $(inst_sysconfdir)/rpc
    2.28 + generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
    2.29 + 	    $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/cross-arm-glibc/stuff/glibc-2.14-reinstall-nis-rpc-headers.patch	Thu May 03 18:07:11 2012 +0200
     3.3 @@ -0,0 +1,28 @@
     3.4 +From bdd816a366c4e5bba5de7157d948e0c0737fb4fb Mon Sep 17 00:00:00 2001
     3.5 +From: Andreas Schwab <schwab@redhat.com>
     3.6 +Date: Tue, 17 May 2011 17:42:30 +0200
     3.7 +Subject: [PATCH] Reinstall NIS RPC headers
     3.8 +
     3.9 +---
    3.10 + nis/Makefile |    4 ++--
    3.11 + 1 files changed, 2 insertions(+), 2 deletions(-)
    3.12 +
    3.13 +diff --git a/nis/Makefile b/nis/Makefile
    3.14 +index b5c9609..d2934d9 100644
    3.15 +--- a/nis/Makefile
    3.16 ++++ b/nis/Makefile
    3.17 +@@ -23,9 +23,9 @@ subdir	:= nis
    3.18 + 
    3.19 + aux			:= nis_hash
    3.20 + 
    3.21 ++headers			:= $(wildcard rpcsvc/*.[hx])
    3.22 + distribute		:= nss-nis.h nss-nisplus.h nis_intern.h Banner \
    3.23 +-			   nisplus-parser.h nis_xdr.h nss \
    3.24 +-			   $(wildcard rpcsvc/*.[hx])
    3.25 ++			   nisplus-parser.h nis_xdr.h nss
    3.26 + 
    3.27 + # These are the databases available for the nis (and perhaps later nisplus)
    3.28 + # service.  This must be a superset of the services in nss.
    3.29 +-- 
    3.30 +1.7.5.4
    3.31 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/cross-arm-glibc/stuff/glibc-2.14-revert-4768ae77.patch	Thu May 03 18:07:11 2012 +0200
     4.3 @@ -0,0 +1,37 @@
     4.4 +diff -Naur glibc-orig//resolv/res_send.c glibc/resolv/res_send.c
     4.5 +--- glibc-orig//resolv/res_send.c	2011-06-10 18:59:03.041436996 +1000
     4.6 ++++ glibc/resolv/res_send.c	2011-06-10 19:08:09.379309323 +1000
     4.7 +@@ -549,7 +549,7 @@
     4.8 +				    ns, ansp, ansp2, nansp2, resplen2);
     4.9 +			if (n < 0)
    4.10 +				return (-1);
    4.11 +-			if (n == 0 && (buf2 == NULL || *resplen2 == 0))
    4.12 ++			if (n == 0)
    4.13 +				goto next_ns;
    4.14 +		} else {
    4.15 +			/* Use datagrams. */
    4.16 +@@ -559,7 +559,7 @@
    4.17 +				    ansp2, nansp2, resplen2);
    4.18 +			if (n < 0)
    4.19 +				return (-1);
    4.20 +-			if (n == 0 && (buf2 == NULL || *resplen2 == 0))
    4.21 ++			if (n == 0)
    4.22 +				goto next_ns;
    4.23 +			if (v_circuit)
    4.24 +			  // XXX Check whether both requests failed or
    4.25 +@@ -1275,14 +1275,10 @@
    4.26 +				(*thisresplenp > *thisanssizp)
    4.27 +				? *thisanssizp : *thisresplenp);
    4.28 +
    4.29 +-			if (recvresp1 || (buf2 != NULL && recvresp2)) {
    4.30 +-			  *resplen2 = 0;
    4.31 ++			if (recvresp1 || (buf2 != NULL && recvresp2))
    4.32 +			  return resplen;
    4.33 +-			}
    4.34 +			if (buf2 != NULL)
    4.35 +			  {
    4.36 +-			    /* No data from the first reply.  */
    4.37 +-			    resplen = 0;
    4.38 +			    /* We are waiting for a possible second reply.  */
    4.39 +			    if (hp->id == anhp->id)
    4.40 +			      recvresp1 = 1;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/cross-arm-glibc/stuff/glibc-2.14.1-fixes-1.patch	Thu May 03 18:07:11 2012 +0200
     5.3 @@ -0,0 +1,159 @@
     5.4 +Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
     5.5 +Date:                    2011-10-07
     5.6 +Initial Package Version: 2.14.1
     5.7 +Upstream Status:         From upstream
     5.8 +Origin:                  Matt Burgess
     5.9 +Description:             Fixes Firefox crashes and a bug when programs link to
    5.10 +                         SDL.
    5.11 +
    5.12 +diff -Naur glibc-2.14.1.orig/elf/dl-close.c glibc-2.14.1/elf/dl-close.c
    5.13 +--- glibc-2.14.1.orig/elf/dl-close.c	2011-10-07 09:48:55.000000000 +0000
    5.14 ++++ glibc-2.14.1/elf/dl-close.c	2011-10-07 19:43:10.346411120 +0000
    5.15 +@@ -119,17 +119,8 @@
    5.16 +   if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
    5.17 +       || dl_close_state != not_pending)
    5.18 +     {
    5.19 +-      if (map->l_direct_opencount == 0)
    5.20 +-	{
    5.21 +-	  if (map->l_type == lt_loaded)
    5.22 +-	    dl_close_state = rerun;
    5.23 +-	  else if (map->l_type == lt_library)
    5.24 +-	    {
    5.25 +-	      struct link_map **oldp = map->l_initfini;
    5.26 +-	      map->l_initfini = map->l_orig_initfini;
    5.27 +-	      _dl_scope_free (oldp);
    5.28 +-	    }
    5.29 +-	}
    5.30 ++      if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
    5.31 ++	dl_close_state = rerun;
    5.32 + 
    5.33 +       /* There are still references to this object.  Do nothing more.  */
    5.34 +       if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
    5.35 +diff -Naur glibc-2.14.1.orig/elf/dl-deps.c glibc-2.14.1/elf/dl-deps.c
    5.36 +--- glibc-2.14.1.orig/elf/dl-deps.c	2011-10-07 09:48:55.000000000 +0000
    5.37 ++++ glibc-2.14.1/elf/dl-deps.c	2011-10-07 19:43:10.348432639 +0000
    5.38 +@@ -478,6 +478,7 @@
    5.39 + 		  nneeded * sizeof needed[0]);
    5.40 + 	  atomic_write_barrier ();
    5.41 + 	  l->l_initfini = l_initfini;
    5.42 ++	  l->l_free_initfini = 1;
    5.43 + 	}
    5.44 + 
    5.45 +       /* If we have no auxiliary objects just go on to the next map.  */
    5.46 +@@ -678,6 +679,7 @@
    5.47 +   l_initfini[nlist] = NULL;
    5.48 +   atomic_write_barrier ();
    5.49 +   map->l_initfini = l_initfini;
    5.50 ++  map->l_free_initfini = 1;
    5.51 +   if (l_reldeps != NULL)
    5.52 +     {
    5.53 +       atomic_write_barrier ();
    5.54 +@@ -686,7 +688,7 @@
    5.55 +       _dl_scope_free (old_l_reldeps);
    5.56 +     }
    5.57 +   if (old_l_initfini != NULL)
    5.58 +-      map->l_orig_initfini = old_l_initfini;
    5.59 ++    _dl_scope_free (old_l_initfini);
    5.60 + 
    5.61 +   if (errno_reason)
    5.62 +     _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
    5.63 +diff -Naur glibc-2.14.1.orig/elf/dl-libc.c glibc-2.14.1/elf/dl-libc.c
    5.64 +--- glibc-2.14.1.orig/elf/dl-libc.c	2011-10-07 09:48:55.000000000 +0000
    5.65 ++++ glibc-2.14.1/elf/dl-libc.c	2011-10-07 19:43:10.352411141 +0000
    5.66 +@@ -279,6 +279,10 @@
    5.67 + 	      if (! old->dont_free)
    5.68 + 		free (old);
    5.69 + 	    }
    5.70 ++
    5.71 ++	  /* Free the initfini dependency list.  */
    5.72 ++	  if (l->l_free_initfini)
    5.73 ++	    free (l->l_initfini);
    5.74 + 	}
    5.75 + 
    5.76 +       if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0
    5.77 +diff -Naur glibc-2.14.1.orig/elf/rtld.c glibc-2.14.1/elf/rtld.c
    5.78 +--- glibc-2.14.1.orig/elf/rtld.c	2011-10-07 09:48:55.000000000 +0000
    5.79 ++++ glibc-2.14.1/elf/rtld.c	2011-10-07 19:43:10.355406263 +0000
    5.80 +@@ -2263,6 +2263,7 @@
    5.81 + 	      lnp->dont_free = 1;
    5.82 + 	      lnp = lnp->next;
    5.83 + 	    }
    5.84 ++	  l->l_free_initfini = 0;
    5.85 + 
    5.86 + 	  if (l != &GL(dl_rtld_map))
    5.87 + 	    _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
    5.88 +diff -Naur glibc-2.14.1.orig/include/link.h glibc-2.14.1/include/link.h
    5.89 +--- glibc-2.14.1.orig/include/link.h	2011-10-07 09:48:55.000000000 +0000
    5.90 ++++ glibc-2.14.1/include/link.h	2011-10-07 19:43:10.357462703 +0000
    5.91 +@@ -192,6 +192,9 @@
    5.92 + 						 during LD_TRACE_PRELINKING=1
    5.93 + 						 contains any DT_SYMBOLIC
    5.94 + 						 libraries.  */
    5.95 ++    unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be
    5.96 ++				       freed, ie. not allocated with
    5.97 ++				       the dummy malloc in ld.so.  */
    5.98 + 
    5.99 +     /* Collected information about own RPATH directories.  */
   5.100 +     struct r_search_path_struct l_rpath_dirs;
   5.101 +@@ -240,9 +243,6 @@
   5.102 + 
   5.103 +     /* List of object in order of the init and fini calls.  */
   5.104 +     struct link_map **l_initfini;
   5.105 +-    /* The init and fini list generated at startup, saved when the
   5.106 +-       object is also loaded dynamically.  */
   5.107 +-    struct link_map **l_orig_initfini;
   5.108 + 
   5.109 +     /* List of the dependencies introduced through symbol binding.  */
   5.110 +     struct link_map_reldeps
   5.111 +diff -Naur glibc-2.14.1.orig/resolv/res_query.c glibc-2.14.1/resolv/res_query.c
   5.112 +--- glibc-2.14.1.orig/resolv/res_query.c	2011-10-07 09:48:55.000000000 +0000
   5.113 ++++ glibc-2.14.1/resolv/res_query.c	2011-10-07 19:43:10.361412711 +0000
   5.114 +@@ -122,6 +122,7 @@
   5.115 + 		  int *resplen2)
   5.116 + {
   5.117 + 	HEADER *hp = (HEADER *) answer;
   5.118 ++	HEADER *hp2;
   5.119 + 	int n, use_malloc = 0;
   5.120 + 	u_int oflags = statp->_flags;
   5.121 + 
   5.122 +@@ -239,26 +240,25 @@
   5.123 + 	  /* __libc_res_nsend might have reallocated the buffer.  */
   5.124 + 	  hp = (HEADER *) *answerp;
   5.125 + 
   5.126 +-	/* We simplify the following tests by assigning HP to HP2.  It
   5.127 +-	   is easy to verify that this is the same as ignoring all
   5.128 +-	   tests of HP2.  */
   5.129 +-	HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp;
   5.130 +-
   5.131 +-	if (n < (int) sizeof (HEADER) && answerp2 != NULL
   5.132 +-	    && *resplen2 > (int) sizeof (HEADER))
   5.133 ++	/* We simplify the following tests by assigning HP to HP2 or
   5.134 ++	   vice versa.  It is easy to verify that this is the same as
   5.135 ++	   ignoring all tests of HP or HP2.  */
   5.136 ++	if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER))
   5.137 + 	  {
   5.138 +-	    /* Special case of partial answer.  */
   5.139 +-	    assert (hp != hp2);
   5.140 +-	    hp = hp2;
   5.141 ++	    hp2 = hp;
   5.142 + 	  }
   5.143 +-	else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER)
   5.144 +-		 && n > (int) sizeof (HEADER))
   5.145 ++	else
   5.146 + 	  {
   5.147 +-	    /* Special case of partial answer.  */
   5.148 +-	    assert (hp != hp2);
   5.149 +-	    hp2 = hp;
   5.150 ++	    hp2 = (HEADER *) *answerp2;
   5.151 ++	    if (n < (int) sizeof (HEADER))
   5.152 ++	      {
   5.153 ++	        hp = hp2;
   5.154 ++	      }
   5.155 + 	  }
   5.156 + 
   5.157 ++	/* Make sure both hp and hp2 are defined */
   5.158 ++	assert((hp != NULL) && (hp2 != NULL));
   5.159 ++
   5.160 + 	if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0)
   5.161 + 	    && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) {
   5.162 + #ifdef DEBUG
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/cross-arm-glibc/stuff/glibc-2.14.1-gcc_fix-1.patch	Thu May 03 18:07:11 2012 +0200
     6.3 @@ -0,0 +1,49 @@
     6.4 +Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
     6.5 +Date:                    2010-04-18
     6.6 +Initial Package Version: 2.11.1
     6.7 +Upstream Status:         Not Submitted
     6.8 +Origin:                  http://www.eglibc.org/archives/patches/msg00073.html
     6.9 +Description:             Fixes the following build problem with GCC-4.5.0:
    6.10 +
    6.11 +/mnt/lfs/sources/libc-build/math/s_frexp.os.dt -MT /mnt/lfs/sources/libc-build/math/s_frexp.os
    6.12 +./sysdeps/i386/fpu/s_frexp.S: Assembler messages:
    6.13 +./sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef"
    6.14 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
    6.15 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
    6.16 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
    6.17 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.'
    6.18 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1'
    6.19 +./sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive
    6.20 +./sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if"
    6.21 +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression
    6.22 +make[2]: *** [/mnt/lfs/sources/libc-build/math/s_frexp.os] Error 1
    6.23 +
    6.24 +diff -Naur glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c
    6.25 +--- glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c	2009-12-08 20:10:20.000000000 +0000
    6.26 ++++ glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c	2010-04-17 11:34:06.882681001 +0000
    6.27 +@@ -45,6 +45,11 @@
    6.28 + /* Embed an #include to pull in the alignment and .end directives. */
    6.29 + asm ("\n#include \"defs.h\"");
    6.30 + 
    6.31 ++asm ("\n#if defined __i686 && defined __ASSEMBLER__");
    6.32 ++asm ("\n#undef __i686");
    6.33 ++asm ("\n#define __i686 __i686");
    6.34 ++asm ("\n#endif");
    6.35 ++
    6.36 + /* The initial common code ends here. */
    6.37 + asm ("\n/*@HEADER_ENDS*/");
    6.38 + 
    6.39 +diff -Naur glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h
    6.40 +--- glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h	2009-12-08 20:10:20.000000000 +0000
    6.41 ++++ glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h	2010-04-17 11:34:06.882681001 +0000
    6.42 +@@ -29,6 +29,10 @@
    6.43 + #include <dl-sysdep.h>
    6.44 + #include <tls.h>
    6.45 + 
    6.46 ++#if defined __i686 && defined __ASSEMBLER__
    6.47 ++#undef __i686
    6.48 ++#define __i686 __i686
    6.49 ++#endif
    6.50 + 
    6.51 + /* For Linux we can use the system call table in the header file
    6.52 + 	/usr/include/asm/unistd.h
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/cross-arm-glibc/stuff/glibc-2.14.1-sort-1.patch	Thu May 03 18:07:11 2012 +0200
     7.3 @@ -0,0 +1,273 @@
     7.4 +Submitted By:            Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org>
     7.5 +Date:                    2012-02-24
     7.6 +Initial Package Version: 2.14.1
     7.7 +Upstream Status:         From upstream
     7.8 +Origin:                  Upstream
     7.9 +Description:             Sort objects by dependency before relocation.
    7.10 +                         Fixes segfault in dlopen for several programs.
    7.11 +
    7.12 +diff --git a/Makeconfig b/Makeconfig
    7.13 +index 2db2821..68547b2 100644
    7.14 +--- a/Makeconfig
    7.15 ++++ b/Makeconfig
    7.16 +@@ -938,6 +938,12 @@ libdl =
    7.17 + endif
    7.18 + endif
    7.19 + 
    7.20 ++ifeq ($(build-shared),yes)
    7.21 ++libm = $(common-objpfx)math/libm.so$(libm.so-version)
    7.22 ++else
    7.23 ++libm = $(common-objpfx)math/libm.a
    7.24 ++endif
    7.25 ++
    7.26 + # These are the subdirectories containing the library source.  The order
    7.27 + # is more or less arbitrary.  The sorting step will take care of the
    7.28 + # dependencies.
    7.29 +diff --git a/elf/Makefile b/elf/Makefile
    7.30 +index 052e763..3f1772a 100644
    7.31 +--- a/elf/Makefile
    7.32 ++++ b/elf/Makefile
    7.33 +@@ -124,7 +124,8 @@ distribute	:= rtld-Rules \
    7.34 + 		   tst-initordera1.c tst-initordera2.c tst-initorderb1.c \
    7.35 + 		   tst-initorderb2.c tst-initordera3.c tst-initordera4.c \
    7.36 + 		   tst-initorder.c \
    7.37 +-		   tst-initorder2.c
    7.38 ++		   tst-initorder2.c \
    7.39 ++		   tst-relsort1.c tst-relsort1mod1.c tst-relsort1mod2.c
    7.40 + 
    7.41 + CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
    7.42 + CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
    7.43 +@@ -227,7 +228,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
    7.44 + 	 tst-audit1 tst-audit2 \
    7.45 + 	 tst-stackguard1 tst-addr1 tst-thrlock \
    7.46 + 	 tst-unique1 tst-unique2 tst-unique3 tst-unique4 \
    7.47 +-	 tst-initorder tst-initorder2
    7.48 ++	 tst-initorder tst-initorder2 tst-relsort1
    7.49 + #	 reldep9
    7.50 + test-srcs = tst-pathopt
    7.51 + selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
    7.52 +@@ -290,7 +291,9 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
    7.53 + 		tst-initordera1 tst-initorderb1 \
    7.54 + 		tst-initordera2 tst-initorderb2 \
    7.55 + 		tst-initordera3 tst-initordera4 \
    7.56 +-		tst-initorder2a tst-initorder2b tst-initorder2c tst-initorder2d
    7.57 ++		tst-initorder2a tst-initorder2b tst-initorder2c \
    7.58 ++		tst-initorder2d \
    7.59 ++		tst-relsort1mod1 tst-relsort1mod2
    7.60 + ifeq (yes,$(have-initfini-array))
    7.61 + modules-names += tst-array2dep tst-array5dep
    7.62 + endif
    7.63 +@@ -1195,3 +1198,9 @@ CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS)
    7.64 + CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS)
    7.65 + CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
    7.66 + endif
    7.67 ++
    7.68 ++$(objpfx)tst-relsort1: $(libdl)
    7.69 ++$(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
    7.70 ++$(objpfx)tst-relsort1mod2.so: $(libm)
    7.71 ++$(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
    7.72 ++			   $(objpfx)tst-relsort1mod2.so
    7.73 +diff --git a/elf/dl-open.c b/elf/dl-open.c
    7.74 +index a0b5c50..a56bdc1 100644
    7.75 +--- a/elf/dl-open.c
    7.76 ++++ b/elf/dl-open.c
    7.77 +@@ -1,5 +1,5 @@
    7.78 + /* Load a shared object at runtime, relocate it, and run its initializer.
    7.79 +-   Copyright (C) 1996-2007, 2009, 2010, 2011 Free Software Foundation, Inc.
    7.80 ++   Copyright (C) 1996-2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    7.81 +    This file is part of the GNU C Library.
    7.82 + 
    7.83 +    The GNU C Library is free software; you can redistribute it and/or
    7.84 +@@ -303,45 +303,109 @@ dl_open_worker (void *a)
    7.85 +   if (GLRO(dl_lazy))
    7.86 +     reloc_mode |= mode & RTLD_LAZY;
    7.87 + 
    7.88 +-  /* Relocate the objects loaded.  We do this in reverse order so that copy
    7.89 +-     relocs of earlier objects overwrite the data written by later objects.  */
    7.90 +-
    7.91 ++  /* Sort the objects by dependency for the relocation process.  This
    7.92 ++     allows IFUNC relocations to work and it also means copy
    7.93 ++     relocation of dependencies are if necessary overwritten.  */
    7.94 ++  size_t nmaps = 0;
    7.95 +   struct link_map *l = new;
    7.96 +-  while (l->l_next)
    7.97 +-    l = l->l_next;
    7.98 +-  while (1)
    7.99 ++  do
   7.100 ++    {
   7.101 ++      if (! l->l_real->l_relocated)
   7.102 ++	++nmaps;
   7.103 ++      l = l->l_next;
   7.104 ++    }
   7.105 ++  while (l != NULL);
   7.106 ++  struct link_map *maps[nmaps];
   7.107 ++  nmaps = 0;
   7.108 ++  l = new;
   7.109 ++  do
   7.110 +     {
   7.111 +       if (! l->l_real->l_relocated)
   7.112 ++	maps[nmaps++] = l;
   7.113 ++      l = l->l_next;
   7.114 ++    }
   7.115 ++  while (l != NULL);
   7.116 ++  if (nmaps > 1)
   7.117 ++    {
   7.118 ++      char seen[nmaps];
   7.119 ++      memset (seen, '\0', nmaps);
   7.120 ++      size_t i = 0;
   7.121 ++      while (1)
   7.122 + 	{
   7.123 +-#ifdef SHARED
   7.124 +-	  if (__builtin_expect (GLRO(dl_profile) != NULL, 0))
   7.125 ++	  ++seen[i];
   7.126 ++	  struct link_map *thisp = maps[i];
   7.127 ++
   7.128 ++	  /* Find the last object in the list for which the current one is
   7.129 ++	     a dependency and move the current object behind the object
   7.130 ++	     with the dependency.  */
   7.131 ++	  size_t k = nmaps - 1;
   7.132 ++	  while (k > i)
   7.133 + 	    {
   7.134 +-	      /* If this here is the shared object which we want to profile
   7.135 +-		 make sure the profile is started.  We can find out whether
   7.136 +-		 this is necessary or not by observing the `_dl_profile_map'
   7.137 +-		 variable.  If was NULL but is not NULL afterwars we must
   7.138 +-		 start the profiling.  */
   7.139 +-	      struct link_map *old_profile_map = GL(dl_profile_map);
   7.140 ++	      struct link_map **runp = maps[k]->l_initfini;
   7.141 ++	      if (runp != NULL)
   7.142 ++		/* Look through the dependencies of the object.  */
   7.143 ++		while (*runp != NULL)
   7.144 ++		  if (__builtin_expect (*runp++ == thisp, 0))
   7.145 ++		    {
   7.146 ++		      /* Move the current object to the back past the last
   7.147 ++			 object with it as the dependency.  */
   7.148 ++		      memmove (&maps[i], &maps[i + 1],
   7.149 ++			       (k - i) * sizeof (maps[0]));
   7.150 ++		      maps[k] = thisp;
   7.151 ++
   7.152 ++		      if (seen[i + 1] > 1)
   7.153 ++			{
   7.154 ++			  ++i;
   7.155 ++			  goto next_clear;
   7.156 ++			}
   7.157 ++
   7.158 ++		      char this_seen = seen[i];
   7.159 ++		      memmove (&seen[i], &seen[i + 1],
   7.160 ++			       (k - i) * sizeof (seen[0]));
   7.161 ++		      seen[k] = this_seen;
   7.162 ++
   7.163 ++		      goto next;
   7.164 ++		    }
   7.165 ++
   7.166 ++	      --k;
   7.167 ++	    }
   7.168 + 
   7.169 +-	      _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1);
   7.170 ++	  if (++i == nmaps)
   7.171 ++	    break;
   7.172 ++	next_clear:
   7.173 ++	  memset (&seen[i], 0, (nmaps - i) * sizeof (seen[0]));
   7.174 ++	next:;
   7.175 ++	}
   7.176 ++    }
   7.177 + 
   7.178 +-	      if (old_profile_map == NULL && GL(dl_profile_map) != NULL)
   7.179 +-		{
   7.180 +-		  /* We must prepare the profiling.  */
   7.181 +-		  _dl_start_profile ();
   7.182 ++  for (size_t i = nmaps; i-- > 0; )
   7.183 ++    {
   7.184 ++      l = maps[i];
   7.185 + 
   7.186 +-		  /* Prevent unloading the object.  */
   7.187 +-		  GL(dl_profile_map)->l_flags_1 |= DF_1_NODELETE;
   7.188 +-		}
   7.189 ++#ifdef SHARED
   7.190 ++      if (__builtin_expect (GLRO(dl_profile) != NULL, 0))
   7.191 ++	{
   7.192 ++	  /* If this here is the shared object which we want to profile
   7.193 ++	     make sure the profile is started.  We can find out whether
   7.194 ++	     this is necessary or not by observing the `_dl_profile_map'
   7.195 ++	     variable.  If it was NULL but is not NULL afterwars we must
   7.196 ++	     start the profiling.  */
   7.197 ++	  struct link_map *old_profile_map = GL(dl_profile_map);
   7.198 ++
   7.199 ++	  _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1);
   7.200 ++
   7.201 ++	  if (old_profile_map == NULL && GL(dl_profile_map) != NULL)
   7.202 ++	    {
   7.203 ++	      /* We must prepare the profiling.  */
   7.204 ++	      _dl_start_profile ();
   7.205 ++
   7.206 ++	      /* Prevent unloading the object.  */
   7.207 ++	      GL(dl_profile_map)->l_flags_1 |= DF_1_NODELETE;
   7.208 + 	    }
   7.209 +-	  else
   7.210 +-#endif
   7.211 +-	    _dl_relocate_object (l, l->l_scope, reloc_mode, 0);
   7.212 + 	}
   7.213 +-
   7.214 +-      if (l == new)
   7.215 +-	break;
   7.216 +-      l = l->l_prev;
   7.217 ++      else
   7.218 ++#endif
   7.219 ++	_dl_relocate_object (l, l->l_scope, reloc_mode, 0);
   7.220 +     }
   7.221 + 
   7.222 +   /* If the file is not loaded now as a dependency, add the search
   7.223 +diff --git a/elf/tst-relsort1.c b/elf/tst-relsort1.c
   7.224 +new file mode 100644
   7.225 +index 0000000..972100c
   7.226 +--- /dev/null
   7.227 ++++ b/elf/tst-relsort1.c
   7.228 +@@ -0,0 +1,19 @@
   7.229 ++#include <dlfcn.h>
   7.230 ++#include <stdio.h>
   7.231 ++
   7.232 ++
   7.233 ++static int
   7.234 ++do_test ()
   7.235 ++{
   7.236 ++  const char lib[] = "$ORIGIN/tst-relsort1mod1.so";
   7.237 ++  void *h = dlopen (lib, RTLD_NOW);
   7.238 ++  if (h == NULL)
   7.239 ++    {
   7.240 ++      puts (dlerror ());
   7.241 ++      return 1;
   7.242 ++    }
   7.243 ++  return 0;
   7.244 ++}
   7.245 ++
   7.246 ++#define TEST_FUNCTION do_test ()
   7.247 ++#include "../test-skeleton.c"
   7.248 +diff --git a/elf/tst-relsort1mod1.c b/elf/tst-relsort1mod1.c
   7.249 +new file mode 100644
   7.250 +index 0000000..9e4a943
   7.251 +--- /dev/null
   7.252 ++++ b/elf/tst-relsort1mod1.c
   7.253 +@@ -0,0 +1,7 @@
   7.254 ++extern int foo (double);
   7.255 ++
   7.256 ++int
   7.257 ++bar (void)
   7.258 ++{
   7.259 ++  return foo (1.2);
   7.260 ++}
   7.261 +diff --git a/elf/tst-relsort1mod2.c b/elf/tst-relsort1mod2.c
   7.262 +new file mode 100644
   7.263 +index 0000000..a2c3e55
   7.264 +--- /dev/null
   7.265 ++++ b/elf/tst-relsort1mod2.c
   7.266 +@@ -0,0 +1,7 @@
   7.267 ++#include <math.h>
   7.268 ++
   7.269 ++int
   7.270 ++foo (double d)
   7.271 ++{
   7.272 ++  return floor (d) != 0.0;
   7.273 ++}
   7.274 +-- 
   7.275 +1.7.3.4
   7.276 +