# HG changeset patch # User Xander Ziiryanoff # Date 1406153039 0 # Node ID ee67322bc8311ef3af31f72881a38fdc8b505d65 # Parent 60e3e78f0d90dc715d371b7f428d872afaac46a7 add again glibc diff -r 60e3e78f0d90 -r ee67322bc831 glibc-base/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-base/receipt Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,136 @@ +# SliTaz package receipt. + +PACKAGE="glibc-base" +VERSION="2.14.1" +CATEGORY="base-system" +SHORT_DESC="GNU libc minimal libraries and UTF-8 support for SliTaz." +WEB_SITE="http://www.gnu.org/software/libc/" +MAINTAINER="pankso@slitaz.org" +LICENSE="GPL2" +WANTED="glibc" +HOST_ARCH="i486 arm x86_64" + +# Locales include by default, other locales are in: locale-** and glibc-locale +DEFAULT_LOCALE="en_US en_GB" + +# Handle multiarch compilation. +case "$ARCH" in + arm*|x86_64) VERSION="2.13" WANTED="" ;; +esac + +# Handle multiarch installation. +case "$SLITAZ_ARCH" in + arm*|x86_64) VERSION="2.13" WANTED="" ;; +esac + +# Rules to gen a SliTaz package suitable for Tazpkg. +# +# Full glibc is very long to compile (see package glibc for more +# informations). You can use the precompiled package available on +# SliTaz mirror to build a distro without recompiling glibc. +# + +# i18n +get_locales() +{ + local path=$1 + for i in $DEFAULT_LOCALE + do + cp $install/$path/i18n/locales/$i $fs/usr/share/i18n/locales + done +} + +genpkg_rules() +{ + # Mkdir's. + for dir in $(cat $stuff/mkdir.list) + do + mkdir -p ${fs}$dir + done + + case "$ARCH" in + arm*) + # Eglibc is cross compiled by cross to have a toolchain so we can + # use these files instead of recooking it. ARM use Eglibc + echo "Using cross compiled Eglibc..." + install=/cross/$ARCH/sysroot + + # /usr/{bin,share} /usr/lib/gconv + for file in $(cat $stuff/arm-files.list) + do + cp -a ${install}$file ${fs}$file + done + + # libs + for lib in libcrypt libm libc libresolv librt libutil libpthread \ + libnss_* libnsl libanl libdl + do + cp -a $install/lib/${lib}-*.so $fs/lib + cp -a $install/lib/${lib}.so* $fs/lib + cp -a $install/usr/lib/${lib}.so $fs/usr/lib + done + cp -a $install/lib/ld-*.so* $fs/lib + cp -a $install/usr/lib/libc_nonshared.a $fs/usr/lib + cp -a $install/usr/lib/libpthread_nonshared.a $fs/usr/lib + cp $install/etc/rpc $fs/etc + touch $fs/etc/ld.so.conf + touch $fs/etc/ld.so.cache + get_locales "usr/share" ;; + x86_64) + # EXPERIMENTAL: Glibc is cross compiled by cross to have a + # toolchain so we can use these files instead of recooking it. + echo "Using cross compiled Glibc..." + install=/usr/cross/$ARCH + + # /usr/{bin,share} /usr/lib/gconv + for file in $(cat $stuff/arm-files.list) + do + cp -a ${install}$file ${fs}/usr/$file + done + + # /lib + for lib in libcrypt libm libc libresolv librt libutil libpthread \ + libnss_* libnsl libanl libdl + do + cp -a $install/lib/${lib}-*.so $fs/lib + cp -a $install/lib/${lib}.so* $fs/lib + done + cp -a $install/lib/ld-*.so* $fs/lib + cp -a $install/lib/libc_nonshared.a $fs/lib + cp -a $install/lib/libpthread_nonshared.a $fs/lib + cp $install/etc/rpc $fs/etc + touch $fs/etc/ld.so.conf + get_locales "share" + # Fix libraries search path + sed -i s"|/usr/cross/$ARCH||"g $fs/lib/libc.so + sed -i s"|/usr/cross/$ARCH||"g $fs/lib/libpthread.so ;; + *) + # Copy all files specified in stuff/files.list. We get the files + # from glibc package. + for file in $(cat $stuff/wanted-files.list) + do + cp -a ${install}$file ${fs}$file + done + get_locales "usr/share" + esac +} + +# Remove an eventual locale-archive since we use directories. +pre_install() +{ + rm -f $root/usr/lib/locale/locale-archive +} + +# Glibc-base is auto-updated in chroot but when cross-compiling we need +# to have /usr/cross/$ARCH search path in libc.so +post_install() +{ + # x86_64 + if echo $root | grep -q /usr/cross/x86_64; then + echo "Fixing x86_64: $root/lib/libc.so" + cat > $root/lib/libc.so << EOT +OUTPUT_FORMAT(elf64-x86-64) +GROUP ( $root/lib/libc.so.6 $root/lib/libc_nonshared.a AS_NEEDED ( $root/lib/ld-linux-x86-64.so.2 ) ) +EOT + fi +} diff -r 60e3e78f0d90 -r ee67322bc831 glibc-base/stuff/arm-files.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-base/stuff/arm-files.list Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,31 @@ +/usr/lib/gconv/UNICODE.so +/usr/lib/gconv/gconv-modules +/usr/lib/gconv/ANSI_X3.110.so +/usr/lib/gconv/ISO8859-1.so +/usr/lib/gconv/ISO8859-15.so +/usr/lib/gconv/UTF-16.so +/usr/lib/gconv/CP1252.so +/usr/lib/gconv/IBM437.so +/usr/lib/gconv/IBM850.so + +/usr/bin/locale +/usr/bin/localedef + +/usr/share/locale/locale.alias +/usr/share/i18n/charmaps/UTF-8.gz + +/usr/share/i18n/locales/i18n +/usr/share/i18n/locales/iso14651_t1 +/usr/share/i18n/locales/iso14651_t1_common +/usr/share/i18n/locales/translit_neutral +/usr/share/i18n/locales/translit_combining +/usr/share/i18n/locales/translit_circle +/usr/share/i18n/locales/translit_cjk_compat +/usr/share/i18n/locales/translit_compat +/usr/share/i18n/locales/translit_font +/usr/share/i18n/locales/translit_fraction +/usr/share/i18n/locales/translit_narrow +/usr/share/i18n/locales/translit_small +/usr/share/i18n/locales/translit_wide + +/usr/share/zoneinfo/UTC diff -r 60e3e78f0d90 -r ee67322bc831 glibc-base/stuff/i486-files.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-base/stuff/i486-files.list Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,80 @@ +/lib/libutil-2.14.1.so +/lib/libnss_dns-2.14.1.so +/lib/libnsl-2.14.1.so +/lib/libanl-2.14.1.so +/lib/libm-2.14.1.so +/lib/libpthread-2.14.1.so +/lib/libthread_db-1.0.so +/lib/libnss_compat-2.14.1.so +/lib/libc-2.14.1.so +/lib/librt-2.14.1.so +/lib/libcrypt-2.14.1.so +/lib/ld-2.14.1.so +/lib/libresolv-2.14.1.so +/lib/libnss_files-2.14.1.so +/lib/libdl-2.14.1.so + +/usr/lib/gconv/UNICODE.so +/usr/lib/gconv/gconv-modules +/usr/lib/gconv/ANSI_X3.110.so +/usr/lib/gconv/ISO8859-1.so +/usr/lib/gconv/ISO8859-15.so +/usr/lib/gconv/UTF-16.so +/usr/lib/gconv/CP1252.so +/usr/lib/gconv/IBM437.so +/usr/lib/gconv/IBM850.so + +/usr/bin/locale +/usr/bin/localedef + +/usr/share/locale/locale.alias +/usr/share/i18n/charmaps/UTF-8.gz + +/usr/share/i18n/locales/i18n +/usr/share/i18n/locales/iso14651_t1 +/usr/share/i18n/locales/iso14651_t1_common +/usr/share/i18n/locales/translit_neutral +/usr/share/i18n/locales/translit_combining +/usr/share/i18n/locales/translit_circle +/usr/share/i18n/locales/translit_cjk_compat +/usr/share/i18n/locales/translit_compat +/usr/share/i18n/locales/translit_font +/usr/share/i18n/locales/translit_fraction +/usr/share/i18n/locales/translit_narrow +/usr/share/i18n/locales/translit_small +/usr/share/i18n/locales/translit_wide + +/usr/share/zoneinfo/UTC + +/etc/rpc +/etc/ld.so.conf +/etc/ld.so.cache + +/lib/libc.so.6 +/lib/librt.so.1 +/lib/libdl.so.2 +/lib/libanl.so.1 +/lib/libutil.so.1 +/lib/libnss_dns.so.2 +/lib/libnss_compat.so.2 +/lib/libcrypt.so.1 +/lib/libpthread.so.0 +/lib/libthread_db.so.1 +/lib/libm.so.6 +/lib/ld-linux.so.2 +/lib/libresolv.so.2 +/lib/libnsl.so.1 +/lib/libnss_files.so.2 + +/usr/lib/libnss_dns.so +/usr/lib/libnss_files.so +/usr/lib/libcrypt.so +/usr/lib/libnss_compat.so +/usr/lib/libdl.so +/usr/lib/libm.so +/usr/lib/librt.so +/usr/lib/libresolv.so +/usr/lib/libnsl.so +/usr/lib/libutil.so +/usr/lib/libanl.so +/usr/lib/libthread_db.so diff -r 60e3e78f0d90 -r ee67322bc831 glibc-base/stuff/mkdir.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-base/stuff/mkdir.list Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,10 @@ +/etc +/lib +/usr/bin +/usr/lib/gconv +/usr/lib/locale +/usr/share/zoneinfo/America +/usr/share/zoneinfo/Europe +/usr/share/i18n/locales +/usr/share/i18n/charmaps +/usr/share/locale diff -r 60e3e78f0d90 -r ee67322bc831 glibc-base/stuff/wanted-files.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-base/stuff/wanted-files.list Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,80 @@ +/lib/libutil-2.14.1.so +/lib/libnss_dns-2.14.1.so +/lib/libnsl-2.14.1.so +/lib/libanl-2.14.1.so +/lib/libm-2.14.1.so +/lib/libpthread-2.14.1.so +/lib/libthread_db-1.0.so +/lib/libnss_compat-2.14.1.so +/lib/libc-2.14.1.so +/lib/librt-2.14.1.so +/lib/libcrypt-2.14.1.so +/lib/ld-2.14.1.so +/lib/libresolv-2.14.1.so +/lib/libnss_files-2.14.1.so +/lib/libdl-2.14.1.so + +/usr/lib/gconv/UNICODE.so +/usr/lib/gconv/gconv-modules +/usr/lib/gconv/ANSI_X3.110.so +/usr/lib/gconv/ISO8859-1.so +/usr/lib/gconv/ISO8859-15.so +/usr/lib/gconv/UTF-16.so +/usr/lib/gconv/CP1252.so +/usr/lib/gconv/IBM437.so +/usr/lib/gconv/IBM850.so + +/usr/bin/locale +/usr/bin/localedef + +/usr/share/locale/locale.alias +/usr/share/i18n/charmaps/UTF-8.gz + +/usr/share/i18n/locales/i18n +/usr/share/i18n/locales/iso14651_t1 +/usr/share/i18n/locales/iso14651_t1_common +/usr/share/i18n/locales/translit_neutral +/usr/share/i18n/locales/translit_combining +/usr/share/i18n/locales/translit_circle +/usr/share/i18n/locales/translit_cjk_compat +/usr/share/i18n/locales/translit_compat +/usr/share/i18n/locales/translit_font +/usr/share/i18n/locales/translit_fraction +/usr/share/i18n/locales/translit_narrow +/usr/share/i18n/locales/translit_small +/usr/share/i18n/locales/translit_wide + +/usr/share/zoneinfo/UTC + +/etc/rpc +/etc/ld.so.conf +/etc/ld.so.cache + +/lib/libc.so.6 +/lib/librt.so.1 +/lib/libdl.so.2 +/lib/libanl.so.1 +/lib/libutil.so.1 +/lib/libnss_dns.so.2 +/lib/libnss_compat.so.2 +/lib/libcrypt.so.1 +/lib/libpthread.so.0 +/lib/libthread_db.so.1 +/lib/libm.so.6 +/lib/ld-linux.so.2 +/lib/libresolv.so.2 +/lib/libnsl.so.1 +/lib/libnss_files.so.2 + +/usr/lib/libnss_dns.so +/usr/lib/libnss_files.so +/usr/lib/libcrypt.so +/usr/lib/libnss_compat.so +/usr/lib/libdl.so +/usr/lib/libm.so +/usr/lib/librt.so +/usr/lib/libresolv.so +/usr/lib/libnsl.so +/usr/lib/libutil.so +/usr/lib/libanl.so +/usr/lib/libthread_db.so diff -r 60e3e78f0d90 -r ee67322bc831 glibc-dev/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-dev/receipt Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,42 @@ +# SliTaz package receipt. + +PACKAGE="glibc-dev" +VERSION="2.14.1" +CATEGORY="development" +SHORT_DESC="The GNU C libraries devel files (Part of SliTaz toolchain)." +MAINTAINER="pankso@slitaz.org" +LICENSE="GPL2" +WANTED="glibc" +WEB_SITE="http://www.gnu.org/software/libc/" + +DEPENDS="glibc-base" + +# Rules to gen a SliTaz package suitable for Tazpkg. +# +# This package is part of the toolchain. We use list to mkdir and cp files. +# +genpkg_rules() +{ + # Mass copy and then remove all files specified in stuff/base-files.list. + # We get the files from glibc-base. Locale files are in: glibc-locale. + cp -a $install/* $fs + + # Rm base files. + echo -n "Removing all base files..." + for file in `cat $WOK/glibc-base/taz/glibc-base-$VERSION/files.list` + do + rm -f ${fs}$file + done + rm -rf $fs/etc + rm -rf $fs/usr/share + status + + # Rm locale. + echo -n "Removing all locale files..." + for file in `cat $WOK/glibc-locale/taz/glibc-locale-$VERSION/files.list` + do + rm -f ${fs}$file + done + rm -rf $fs/usr/lib/gconv + status +} diff -r 60e3e78f0d90 -r ee67322bc831 glibc-extra-samba/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-extra-samba/receipt Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,20 @@ +# SliTaz package receipt. + +PACKAGE="glibc-extra-samba" +VERSION="2.14.1" +CATEGORY="base-system" +SHORT_DESC="GNU libc extra gconv modules for samba." +WEB_SITE="http://gcc.gnu.org/" +WANTED="glibc" +MAINTAINER="pascal.bellard@slitaz.org" +LICENSE="GPL2" + +# Rules to gen a SliTaz package suitable for Tazpkg. +# +genpkg_rules() +{ + mkdir -p $fs/usr/lib/gconv + for i in IBM850.so IBM437.so; do + cp $install/usr/lib/gconv/$i $fs/usr/lib/gconv/$i + done +} diff -r 60e3e78f0d90 -r ee67322bc831 glibc-locale/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc-locale/receipt Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,53 @@ +# SliTaz package receipt. + +PACKAGE="glibc-locale" +VERSION="2.14.1" +CATEGORY="system-tools" +SHORT_DESC="The GNU C libraries locale files and utilities (see also locale-*)." +MAINTAINER="pankso@slitaz.org" +LICENSE="GPL2" +WANTED="glibc" +WEB_SITE="http://www.gnu.org/software/libc/" + +DEPENDS="glibc-base glibc-extra-samba" + +LOCALE_PACK="cs de es fr hu id it pt ru sl zh_CN zh_TW" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/usr/share $fs/usr/lib $fs/usr/bin + + cp -a $install/usr/lib/gconv $fs/usr/lib + cp -a $install/usr/share/locale $fs/usr/share + cp -a $install/usr/share/i18n $fs/usr/share + cp -a $install/usr/share/zoneinfo $fs/usr/share + + # Utilities and tools + cp -a $install/usr/bin/iconv $fs/usr/bin + cp -a $install/usr/bin/tzselect $fs/usr/bin + + # Rm base files. + echo -n "* Removing all base files..." + for file in `cat $WOK/glibc-base/taz/glibc-base-$VERSION/files.list` + do + rm -f ${fs}$file + done + status + + # Rm glibc-extra-samba files. + echo -n "* Removing extra samba files..." + for file in `cat $WOK/glibc-extra-samba/taz/glibc-extra-samba-$VERSION/files.list` + do + rm -f ${fs}$file + done + status + + # Rm files provided by locale-pack. + for i in $LOCALE_PACK + do + echo -n "* Removing locale: $i" + rm -rf $fs/usr/share/locale/$i + status + done +} diff -r 60e3e78f0d90 -r ee67322bc831 glibc/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/receipt Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,149 @@ +# SliTaz package receipt. + +PACKAGE="glibc" +VERSION="2.14.1" +CATEGORY="meta" +SHORT_DESC="The GNU C libraries. This package is used to compile the libc." +MAINTAINER="pankso@slitaz.org" +LICENSE="GPL2" +TARBALL="$PACKAGE-$VERSION.tar.gz" +WEB_SITE="http://www.gnu.org/software/libc/" +WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL" + +DEPENDS="glibc-base glibc-locale glibc-dev" +BUILD_DEPENDS="linux-api-headers autoconf bash" + +# Genpkg order for tazwok. +COOK_OPT="genpkg=glibc-base:glibc-extra-samba:glib-locale:glibc-dev" + +# Rules to compile & install the temporary toolchain. +cook_tmp_toolchain() +{ + cd $src + + # Glibc Bug Fixes Patch from LFS + patch -Np1 -i $stuff/glibc-2.14.1-fixes-1.patch + # Glibc Bug Sort Relocatable Objects Patch + patch -Np1 -i $stuff/glibc-2.14.1-sort-1.patch + # Fix a bug that prevents Glibc from building with GCC-4.6.2 + patch -Np1 -i stuff/glibc-2.14.1-gcc_fix-1.patch + + # Build in a separate directory. + mkdir ../glibc-build && cd ../glibc-build + + # glibc no longer support i386, so use -march=i486 for better compatibility. + # If i686 ??? + unset CFLAGS CXXFLAGS + case $ARCH in + i386|i486) + echo "CFLAGS += -O2 -march=i486 -mtune=i486" > configparms ;; + *) + echo "CFLAGS += -O2 -march=$ARCH -mtune=$ARCH" > configparms ;; + esac + + { $src/configure \ + --host=$HOST_SYSTEM \ + --build=$($src/scripts/config.guess) \ + --disable-profile --enable-add-ons \ + --enable-kernel=2.6.30 --with-headers=/tools/include \ + libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes && + make && + make install + } || return 1 + + # Link compiler to this new glibc. + SPECS=`dirname $($HOST_SYSTEM-gcc -print-libgcc-file-name)`/specs + $HOST_SYSTEM-gcc -dumpspecs | sed \ + -e 's@/lib\(64\)\?/ld@/tools&@g' \ + -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS + unset SPECS +} + +# Rules to configure and make the package. +compile_rules() +{ + cd $src + + # SliTaz is a Busybox based OS, why we so small and fast. Using gawk by + # default to build package will not ensure package work with Busybox awk + # and so should NOT be use to cook. + if [ -x /usr/bin/cook ]; then + [ -d "/var/lib/tazpkg/installed/gawk" ] || tazpkg get-install gawk + fi + + # Fixes and patches from LFS, Redhat + sed -i -e 's/"db1"/& \&\& $name ne "nss_test1"/' scripts/test-installation.pl + sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in + + # Glibc misc Bug Fixes + patch -Np1 -i $stuff/glibc-2.14.1-fixes-1.patch + + # Glibc Bug Sort Relocatable Objects Patch + #patch -Np1 -i $stuff/glibc-2.14.1-sort-1.patch + + # Fix a bug that prevents Glibc from building with GCC-4.6.2 + patch -Np1 -i $stuff/glibc-2.14.1-gcc_fix-1.patch + + # Revert commit causing issues with crappy DNS servers + patch -Np1 -i $stuff/glibc-2.14-revert-4768ae77.patch + + # re-export RPC interface until libtirpc is ready as a replacement + # http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=acee4873 (only fedora branch...) + patch -Np1 -i $stuff/glibc-2.14-reexport-rpc-interface.patch + # http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=bdd816a3 (only fedora branch...) + patch -Np1 -i $stuff/glibc-2.14-reinstall-nis-rpc-headers.patch + + # Fix a stack imbalance that occurs under some conditions: + sed -i '195,213 s/PRIVATE_FUTEX/FUTEX_CLOCK_REALTIME/' \ + nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S \ + nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S + + # Glibc needs ld.so.conf in the install destdir. + mkdir -p $WOK/$PACKAGE/install/etc + touch $WOK/$PACKAGE/install/etc/ld.so.conf + mkdir ../glibc-build && cd ../glibc-build + + # Read the INSTALL file in glibc. Also Glibc dont build with -Os flag. + # --enale-kernel use latest SliTaz Kernel version. From Glibc INSTALL: + # "The higher the VERSION number is, the less compatibility code is + # added, and the faster the code gets." + unset CFLAGS CXXFLAGS + case "$ARCH" in + i386|i486) + echo "CFLAGS += -O2 -march=i486 -mtune=i486" > configparms ;; + *) + echo "CFLAGS += -O2 -march=$ARCH -mtune=$ARCH" > configparms ;; + esac + { $src/configure \ + --disable-profile \ + --enable-add-ons \ + --enable-kernel=2.6.30 \ + --libexecdir=/usr/lib/glibc \ + --build=$HOST_SYSTEM \ + --host=$HOST_SYSTEM \ + --target=$BUILD_SYSTEM && + make && make install_root=$DESTDIR install + } || return 1 + + # If temporary toolchain was previously used, switch to regular toolchain. + [ -d /tools ] || return + mv /tools/bin/ld /tools/bin/ld-old + mv /tools/$(gcc -dumpmachine)/bin/ld /tools/$(gcc -dumpmachine)/bin/ld-old + mv /tools/bin/ld-new /tools/bin/ld + ln -s /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld + gcc -dumpspecs | sed -e 's@/tools@@g' \ + -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ + -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ + `dirname $(gcc --print-libgcc-file-name)`/specs +} + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + LOCALE="" + mkdir -p $fs/var + + # Remove build directory. + rm -rf $WOK/$PACKAGE/source/$PACKAGE-build + rm -rf $WOK/$PACKAGE/$PACKAGE-build +} diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.13-gcc_fix-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.13-gcc_fix-1.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,49 @@ +Submitted By: Matt Burgess +Date: 2010-04-18 +Initial Package Version: 2.11.1 +Upstream Status: Not Submitted +Origin: http://www.eglibc.org/archives/patches/msg00073.html +Description: Fixes the following build problem with GCC-4.5.0: + +/mnt/lfs/sources/libc-build/math/s_frexp.os.dt -MT /mnt/lfs/sources/libc-build/math/s_frexp.os +./sysdeps/i386/fpu/s_frexp.S: Assembler messages: +./sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef" +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive +./sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if" +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression +make[2]: *** [/mnt/lfs/sources/libc-build/math/s_frexp.os] Error 1 + +diff -Naur glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c +--- glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c 2009-12-08 20:10:20.000000000 +0000 ++++ glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c 2010-04-17 11:34:06.882681001 +0000 +@@ -45,6 +45,11 @@ + /* Embed an #include to pull in the alignment and .end directives. */ + asm ("\n#include \"defs.h\""); + ++asm ("\n#if defined __i686 && defined __ASSEMBLER__"); ++asm ("\n#undef __i686"); ++asm ("\n#define __i686 __i686"); ++asm ("\n#endif"); ++ + /* The initial common code ends here. */ + asm ("\n/*@HEADER_ENDS*/"); + +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 +--- glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h 2009-12-08 20:10:20.000000000 +0000 ++++ glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h 2010-04-17 11:34:06.882681001 +0000 +@@ -29,6 +29,10 @@ + #include + #include + ++#if defined __i686 && defined __ASSEMBLER__ ++#undef __i686 ++#define __i686 __i686 ++#endif + + /* For Linux we can use the system call table in the header file + /usr/include/asm/unistd.h diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14-reexport-rpc-interface.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14-reexport-rpc-interface.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,26 @@ +diff --git a/include/libc-symbols.h b/include/libc-symbols.h +index 67e1ca2..5e7cca5 100644 +--- a/include/libc-symbols.h ++++ b/include/libc-symbols.h +@@ -635,7 +635,7 @@ for linking") + # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) + # define libc_hidden_def(name) hidden_def (name) + # define libc_hidden_weak(name) hidden_weak (name) +-# define libc_hidden_nolink(name, version) hidden_nolink (name, libc, version) ++# define libc_hidden_nolink(name, version) hidden_def (name) + # define libc_hidden_ver(local, name) hidden_ver (local, name) + # define libc_hidden_data_def(name) hidden_data_def (name) + # define libc_hidden_data_weak(name) hidden_data_weak (name) +diff --git a/sunrpc/Makefile b/sunrpc/Makefile +index 5134ce9..40c73d1 100644 +--- a/sunrpc/Makefile ++++ b/sunrpc/Makefile +@@ -53,7 +53,7 @@ headers-in-tirpc = $(addprefix rpc/,auth.h auth_unix.h clnt.h pmap_clnt.h \ + des_crypt.h) + headers-not-in-tirpc = $(addprefix rpc/,key_prot.h rpc_des.h) \ + $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h +-headers = rpc/netdb.h ++headers = rpc/netdb.h $(headers-in-tirpc) $(headers-not-in-tirpc) + install-others = $(inst_sysconfdir)/rpc + generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \ + $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14-reinstall-nis-rpc-headers.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14-reinstall-nis-rpc-headers.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,28 @@ +From bdd816a366c4e5bba5de7157d948e0c0737fb4fb Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Tue, 17 May 2011 17:42:30 +0200 +Subject: [PATCH] Reinstall NIS RPC headers + +--- + nis/Makefile | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/nis/Makefile b/nis/Makefile +index b5c9609..d2934d9 100644 +--- a/nis/Makefile ++++ b/nis/Makefile +@@ -23,9 +23,9 @@ subdir := nis + + aux := nis_hash + ++headers := $(wildcard rpcsvc/*.[hx]) + distribute := nss-nis.h nss-nisplus.h nis_intern.h Banner \ +- nisplus-parser.h nis_xdr.h nss \ +- $(wildcard rpcsvc/*.[hx]) ++ nisplus-parser.h nis_xdr.h nss + + # These are the databases available for the nis (and perhaps later nisplus) + # service. This must be a superset of the services in nss. +-- +1.7.5.4 + diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14-revert-4768ae77.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14-revert-4768ae77.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,37 @@ +diff -Naur glibc-orig//resolv/res_send.c glibc/resolv/res_send.c +--- glibc-orig//resolv/res_send.c 2011-06-10 18:59:03.041436996 +1000 ++++ glibc/resolv/res_send.c 2011-06-10 19:08:09.379309323 +1000 +@@ -549,7 +549,7 @@ + ns, ansp, ansp2, nansp2, resplen2); + if (n < 0) + return (-1); +- if (n == 0 && (buf2 == NULL || *resplen2 == 0)) ++ if (n == 0) + goto next_ns; + } else { + /* Use datagrams. */ +@@ -559,7 +559,7 @@ + ansp2, nansp2, resplen2); + if (n < 0) + return (-1); +- if (n == 0 && (buf2 == NULL || *resplen2 == 0)) ++ if (n == 0) + goto next_ns; + if (v_circuit) + // XXX Check whether both requests failed or +@@ -1275,14 +1275,10 @@ + (*thisresplenp > *thisanssizp) + ? *thisanssizp : *thisresplenp); + +- if (recvresp1 || (buf2 != NULL && recvresp2)) { +- *resplen2 = 0; ++ if (recvresp1 || (buf2 != NULL && recvresp2)) + return resplen; +- } + if (buf2 != NULL) + { +- /* No data from the first reply. */ +- resplen = 0; + /* We are waiting for a possible second reply. */ + if (hp->id == anhp->id) + recvresp1 = 1; diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14.1-fixes-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14.1-fixes-1.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,159 @@ +Submitted By: Matt Burgess +Date: 2011-10-07 +Initial Package Version: 2.14.1 +Upstream Status: From upstream +Origin: Matt Burgess +Description: Fixes Firefox crashes and a bug when programs link to + SDL. + +diff -Naur glibc-2.14.1.orig/elf/dl-close.c glibc-2.14.1/elf/dl-close.c +--- glibc-2.14.1.orig/elf/dl-close.c 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/elf/dl-close.c 2011-10-07 19:43:10.346411120 +0000 +@@ -119,17 +119,8 @@ + if (map->l_direct_opencount > 0 || map->l_type != lt_loaded + || dl_close_state != not_pending) + { +- if (map->l_direct_opencount == 0) +- { +- if (map->l_type == lt_loaded) +- dl_close_state = rerun; +- else if (map->l_type == lt_library) +- { +- struct link_map **oldp = map->l_initfini; +- map->l_initfini = map->l_orig_initfini; +- _dl_scope_free (oldp); +- } +- } ++ if (map->l_direct_opencount == 0 && map->l_type == lt_loaded) ++ dl_close_state = rerun; + + /* There are still references to this object. Do nothing more. */ + if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0)) +diff -Naur glibc-2.14.1.orig/elf/dl-deps.c glibc-2.14.1/elf/dl-deps.c +--- glibc-2.14.1.orig/elf/dl-deps.c 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/elf/dl-deps.c 2011-10-07 19:43:10.348432639 +0000 +@@ -478,6 +478,7 @@ + nneeded * sizeof needed[0]); + atomic_write_barrier (); + l->l_initfini = l_initfini; ++ l->l_free_initfini = 1; + } + + /* If we have no auxiliary objects just go on to the next map. */ +@@ -678,6 +679,7 @@ + l_initfini[nlist] = NULL; + atomic_write_barrier (); + map->l_initfini = l_initfini; ++ map->l_free_initfini = 1; + if (l_reldeps != NULL) + { + atomic_write_barrier (); +@@ -686,7 +688,7 @@ + _dl_scope_free (old_l_reldeps); + } + if (old_l_initfini != NULL) +- map->l_orig_initfini = old_l_initfini; ++ _dl_scope_free (old_l_initfini); + + if (errno_reason) + _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname, +diff -Naur glibc-2.14.1.orig/elf/dl-libc.c glibc-2.14.1/elf/dl-libc.c +--- glibc-2.14.1.orig/elf/dl-libc.c 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/elf/dl-libc.c 2011-10-07 19:43:10.352411141 +0000 +@@ -279,6 +279,10 @@ + if (! old->dont_free) + free (old); + } ++ ++ /* Free the initfini dependency list. */ ++ if (l->l_free_initfini) ++ free (l->l_initfini); + } + + if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0 +diff -Naur glibc-2.14.1.orig/elf/rtld.c glibc-2.14.1/elf/rtld.c +--- glibc-2.14.1.orig/elf/rtld.c 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/elf/rtld.c 2011-10-07 19:43:10.355406263 +0000 +@@ -2263,6 +2263,7 @@ + lnp->dont_free = 1; + lnp = lnp->next; + } ++ l->l_free_initfini = 0; + + if (l != &GL(dl_rtld_map)) + _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0, +diff -Naur glibc-2.14.1.orig/include/link.h glibc-2.14.1/include/link.h +--- glibc-2.14.1.orig/include/link.h 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/include/link.h 2011-10-07 19:43:10.357462703 +0000 +@@ -192,6 +192,9 @@ + during LD_TRACE_PRELINKING=1 + contains any DT_SYMBOLIC + libraries. */ ++ unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be ++ freed, ie. not allocated with ++ the dummy malloc in ld.so. */ + + /* Collected information about own RPATH directories. */ + struct r_search_path_struct l_rpath_dirs; +@@ -240,9 +243,6 @@ + + /* List of object in order of the init and fini calls. */ + struct link_map **l_initfini; +- /* The init and fini list generated at startup, saved when the +- object is also loaded dynamically. */ +- struct link_map **l_orig_initfini; + + /* List of the dependencies introduced through symbol binding. */ + struct link_map_reldeps +diff -Naur glibc-2.14.1.orig/resolv/res_query.c glibc-2.14.1/resolv/res_query.c +--- glibc-2.14.1.orig/resolv/res_query.c 2011-10-07 09:48:55.000000000 +0000 ++++ glibc-2.14.1/resolv/res_query.c 2011-10-07 19:43:10.361412711 +0000 +@@ -122,6 +122,7 @@ + int *resplen2) + { + HEADER *hp = (HEADER *) answer; ++ HEADER *hp2; + int n, use_malloc = 0; + u_int oflags = statp->_flags; + +@@ -239,26 +240,25 @@ + /* __libc_res_nsend might have reallocated the buffer. */ + hp = (HEADER *) *answerp; + +- /* We simplify the following tests by assigning HP to HP2. It +- is easy to verify that this is the same as ignoring all +- tests of HP2. */ +- HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp; +- +- if (n < (int) sizeof (HEADER) && answerp2 != NULL +- && *resplen2 > (int) sizeof (HEADER)) ++ /* We simplify the following tests by assigning HP to HP2 or ++ vice versa. It is easy to verify that this is the same as ++ ignoring all tests of HP or HP2. */ ++ if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER)) + { +- /* Special case of partial answer. */ +- assert (hp != hp2); +- hp = hp2; ++ hp2 = hp; + } +- else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER) +- && n > (int) sizeof (HEADER)) ++ else + { +- /* Special case of partial answer. */ +- assert (hp != hp2); +- hp2 = hp; ++ hp2 = (HEADER *) *answerp2; ++ if (n < (int) sizeof (HEADER)) ++ { ++ hp = hp2; ++ } + } + ++ /* Make sure both hp and hp2 are defined */ ++ assert((hp != NULL) && (hp2 != NULL)); ++ + if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0) + && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) { + #ifdef DEBUG diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14.1-gcc_fix-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14.1-gcc_fix-1.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,49 @@ +Submitted By: Matt Burgess +Date: 2010-04-18 +Initial Package Version: 2.11.1 +Upstream Status: Not Submitted +Origin: http://www.eglibc.org/archives/patches/msg00073.html +Description: Fixes the following build problem with GCC-4.5.0: + +/mnt/lfs/sources/libc-build/math/s_frexp.os.dt -MT /mnt/lfs/sources/libc-build/math/s_frexp.os +./sysdeps/i386/fpu/s_frexp.S: Assembler messages: +./sysdeps/i386/fpu/s_frexp.S:66: Error: invalid identifier for ".ifdef" +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `.' +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk at end of line, first unrecognized character is `1' +./sysdeps/i386/fpu/s_frexp.S:66: Error: expected comma after name `' in .size directive +./sysdeps/i386/fpu/s_frexp.S:66: Error: ".endif" without ".if" +./sysdeps/i386/fpu/s_frexp.S:66: Error: junk `.get_pc_thunk.dx' after expression +make[2]: *** [/mnt/lfs/sources/libc-build/math/s_frexp.os] Error 1 + +diff -Naur glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c +--- glibc-2.11.1.orig/nptl/sysdeps/pthread/pt-initfini.c 2009-12-08 20:10:20.000000000 +0000 ++++ glibc-2.11.1/nptl/sysdeps/pthread/pt-initfini.c 2010-04-17 11:34:06.882681001 +0000 +@@ -45,6 +45,11 @@ + /* Embed an #include to pull in the alignment and .end directives. */ + asm ("\n#include \"defs.h\""); + ++asm ("\n#if defined __i686 && defined __ASSEMBLER__"); ++asm ("\n#undef __i686"); ++asm ("\n#define __i686 __i686"); ++asm ("\n#endif"); ++ + /* The initial common code ends here. */ + asm ("\n/*@HEADER_ENDS*/"); + +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 +--- glibc-2.11.1.orig/sysdeps/unix/sysv/linux/i386/sysdep.h 2009-12-08 20:10:20.000000000 +0000 ++++ glibc-2.11.1/sysdeps/unix/sysv/linux/i386/sysdep.h 2010-04-17 11:34:06.882681001 +0000 +@@ -29,6 +29,10 @@ + #include + #include + ++#if defined __i686 && defined __ASSEMBLER__ ++#undef __i686 ++#define __i686 __i686 ++#endif + + /* For Linux we can use the system call table in the header file + /usr/include/asm/unistd.h diff -r 60e3e78f0d90 -r ee67322bc831 glibc/stuff/glibc-2.14.1-sort-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/glibc/stuff/glibc-2.14.1-sort-1.patch Wed Jul 23 22:03:59 2014 +0000 @@ -0,0 +1,273 @@ +Submitted By: Bruce Dubbs +Date: 2012-02-24 +Initial Package Version: 2.14.1 +Upstream Status: From upstream +Origin: Upstream +Description: Sort objects by dependency before relocation. + Fixes segfault in dlopen for several programs. + +diff --git a/Makeconfig b/Makeconfig +index 2db2821..68547b2 100644 +--- a/Makeconfig ++++ b/Makeconfig +@@ -938,6 +938,12 @@ libdl = + endif + endif + ++ifeq ($(build-shared),yes) ++libm = $(common-objpfx)math/libm.so$(libm.so-version) ++else ++libm = $(common-objpfx)math/libm.a ++endif ++ + # These are the subdirectories containing the library source. The order + # is more or less arbitrary. The sorting step will take care of the + # dependencies. +diff --git a/elf/Makefile b/elf/Makefile +index 052e763..3f1772a 100644 +--- a/elf/Makefile ++++ b/elf/Makefile +@@ -124,7 +124,8 @@ distribute := rtld-Rules \ + tst-initordera1.c tst-initordera2.c tst-initorderb1.c \ + tst-initorderb2.c tst-initordera3.c tst-initordera4.c \ + tst-initorder.c \ +- tst-initorder2.c ++ tst-initorder2.c \ ++ tst-relsort1.c tst-relsort1mod1.c tst-relsort1mod2.c + + CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables + CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables +@@ -227,7 +228,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ + tst-audit1 tst-audit2 \ + tst-stackguard1 tst-addr1 tst-thrlock \ + tst-unique1 tst-unique2 tst-unique3 tst-unique4 \ +- tst-initorder tst-initorder2 ++ tst-initorder tst-initorder2 tst-relsort1 + # reldep9 + test-srcs = tst-pathopt + selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null) +@@ -290,7 +291,9 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ + tst-initordera1 tst-initorderb1 \ + tst-initordera2 tst-initorderb2 \ + tst-initordera3 tst-initordera4 \ +- tst-initorder2a tst-initorder2b tst-initorder2c tst-initorder2d ++ tst-initorder2a tst-initorder2b tst-initorder2c \ ++ tst-initorder2d \ ++ tst-relsort1mod1 tst-relsort1mod2 + ifeq (yes,$(have-initfini-array)) + modules-names += tst-array2dep tst-array5dep + endif +@@ -1195,3 +1198,9 @@ CFLAGS-tst-auditmod6b.c += $(AVX-CFLAGS) + CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS) + CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS) + endif ++ ++$(objpfx)tst-relsort1: $(libdl) ++$(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so ++$(objpfx)tst-relsort1mod2.so: $(libm) ++$(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \ ++ $(objpfx)tst-relsort1mod2.so +diff --git a/elf/dl-open.c b/elf/dl-open.c +index a0b5c50..a56bdc1 100644 +--- a/elf/dl-open.c ++++ b/elf/dl-open.c +@@ -1,5 +1,5 @@ + /* Load a shared object at runtime, relocate it, and run its initializer. +- Copyright (C) 1996-2007, 2009, 2010, 2011 Free Software Foundation, Inc. ++ Copyright (C) 1996-2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or +@@ -303,45 +303,109 @@ dl_open_worker (void *a) + if (GLRO(dl_lazy)) + reloc_mode |= mode & RTLD_LAZY; + +- /* Relocate the objects loaded. We do this in reverse order so that copy +- relocs of earlier objects overwrite the data written by later objects. */ +- ++ /* Sort the objects by dependency for the relocation process. This ++ allows IFUNC relocations to work and it also means copy ++ relocation of dependencies are if necessary overwritten. */ ++ size_t nmaps = 0; + struct link_map *l = new; +- while (l->l_next) +- l = l->l_next; +- while (1) ++ do ++ { ++ if (! l->l_real->l_relocated) ++ ++nmaps; ++ l = l->l_next; ++ } ++ while (l != NULL); ++ struct link_map *maps[nmaps]; ++ nmaps = 0; ++ l = new; ++ do + { + if (! l->l_real->l_relocated) ++ maps[nmaps++] = l; ++ l = l->l_next; ++ } ++ while (l != NULL); ++ if (nmaps > 1) ++ { ++ char seen[nmaps]; ++ memset (seen, '\0', nmaps); ++ size_t i = 0; ++ while (1) + { +-#ifdef SHARED +- if (__builtin_expect (GLRO(dl_profile) != NULL, 0)) ++ ++seen[i]; ++ struct link_map *thisp = maps[i]; ++ ++ /* Find the last object in the list for which the current one is ++ a dependency and move the current object behind the object ++ with the dependency. */ ++ size_t k = nmaps - 1; ++ while (k > i) + { +- /* If this here is the shared object which we want to profile +- make sure the profile is started. We can find out whether +- this is necessary or not by observing the `_dl_profile_map' +- variable. If was NULL but is not NULL afterwars we must +- start the profiling. */ +- struct link_map *old_profile_map = GL(dl_profile_map); ++ struct link_map **runp = maps[k]->l_initfini; ++ if (runp != NULL) ++ /* Look through the dependencies of the object. */ ++ while (*runp != NULL) ++ if (__builtin_expect (*runp++ == thisp, 0)) ++ { ++ /* Move the current object to the back past the last ++ object with it as the dependency. */ ++ memmove (&maps[i], &maps[i + 1], ++ (k - i) * sizeof (maps[0])); ++ maps[k] = thisp; ++ ++ if (seen[i + 1] > 1) ++ { ++ ++i; ++ goto next_clear; ++ } ++ ++ char this_seen = seen[i]; ++ memmove (&seen[i], &seen[i + 1], ++ (k - i) * sizeof (seen[0])); ++ seen[k] = this_seen; ++ ++ goto next; ++ } ++ ++ --k; ++ } + +- _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1); ++ if (++i == nmaps) ++ break; ++ next_clear: ++ memset (&seen[i], 0, (nmaps - i) * sizeof (seen[0])); ++ next:; ++ } ++ } + +- if (old_profile_map == NULL && GL(dl_profile_map) != NULL) +- { +- /* We must prepare the profiling. */ +- _dl_start_profile (); ++ for (size_t i = nmaps; i-- > 0; ) ++ { ++ l = maps[i]; + +- /* Prevent unloading the object. */ +- GL(dl_profile_map)->l_flags_1 |= DF_1_NODELETE; +- } ++#ifdef SHARED ++ if (__builtin_expect (GLRO(dl_profile) != NULL, 0)) ++ { ++ /* If this here is the shared object which we want to profile ++ make sure the profile is started. We can find out whether ++ this is necessary or not by observing the `_dl_profile_map' ++ variable. If it was NULL but is not NULL afterwars we must ++ start the profiling. */ ++ struct link_map *old_profile_map = GL(dl_profile_map); ++ ++ _dl_relocate_object (l, l->l_scope, reloc_mode | RTLD_LAZY, 1); ++ ++ if (old_profile_map == NULL && GL(dl_profile_map) != NULL) ++ { ++ /* We must prepare the profiling. */ ++ _dl_start_profile (); ++ ++ /* Prevent unloading the object. */ ++ GL(dl_profile_map)->l_flags_1 |= DF_1_NODELETE; + } +- else +-#endif +- _dl_relocate_object (l, l->l_scope, reloc_mode, 0); + } +- +- if (l == new) +- break; +- l = l->l_prev; ++ else ++#endif ++ _dl_relocate_object (l, l->l_scope, reloc_mode, 0); + } + + /* If the file is not loaded now as a dependency, add the search +diff --git a/elf/tst-relsort1.c b/elf/tst-relsort1.c +new file mode 100644 +index 0000000..972100c +--- /dev/null ++++ b/elf/tst-relsort1.c +@@ -0,0 +1,19 @@ ++#include ++#include ++ ++ ++static int ++do_test () ++{ ++ const char lib[] = "$ORIGIN/tst-relsort1mod1.so"; ++ void *h = dlopen (lib, RTLD_NOW); ++ if (h == NULL) ++ { ++ puts (dlerror ()); ++ return 1; ++ } ++ return 0; ++} ++ ++#define TEST_FUNCTION do_test () ++#include "../test-skeleton.c" +diff --git a/elf/tst-relsort1mod1.c b/elf/tst-relsort1mod1.c +new file mode 100644 +index 0000000..9e4a943 +--- /dev/null ++++ b/elf/tst-relsort1mod1.c +@@ -0,0 +1,7 @@ ++extern int foo (double); ++ ++int ++bar (void) ++{ ++ return foo (1.2); ++} +diff --git a/elf/tst-relsort1mod2.c b/elf/tst-relsort1mod2.c +new file mode 100644 +index 0000000..a2c3e55 +--- /dev/null ++++ b/elf/tst-relsort1mod2.c +@@ -0,0 +1,7 @@ ++#include ++ ++int ++foo (double d) ++{ ++ return floor (d) != 0.0; ++} +-- +1.7.3.4 +