patches/glibc/ports-2.13/360-tests-sandbox-libdl-paths.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue May 03 00:19:56 2011 +0200 (2011-05-03)
changeset 2438 2ba5655f6297
permissions -rw-r--r--
libc/glibc: add 2.13

Patchset provided by "Ioannis E. Venetis" <venetis@mail.capsl.udel.edu>
http://sourceware.org/ml/crossgcc/2011-04/msg00072.html
http://sourceware.org/ml/crossgcc/2011-04/msg00073.html

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 when glibc runs its tests, it does so by invoking the local library loader.
     2 in Gentoo, we build/run inside of our "sandbox" which itself is linked against
     3 libdl (so that it can load libraries and pull out symbols).  the trouble
     4 is that when you upgrade from an older glibc to the new one, often times
     5 internal symbols change name or abi.  this is normally OK as you cannot use
     6 libc.so from say version 2.3.6 but libpthread.so from say version 2.5, so
     7 we always say "keep all of the glibc libraries from the same build".  but
     8 when glibc runs its tests, it uses dynamic paths to point to its new local
     9 copies of libraries.  if the test doesnt use libdl, then glibc doesnt add
    10 its path, and when sandbox triggers the loading of libdl, glibc does so
    11 from the host system system.  this gets us into the case of all libraries
    12 are from the locally compiled version of glibc except for libdl.so.
    13 
    14 Fix by Wormo
    15 
    16 http://bugs.gentoo.org/56898
    17 
    18 diff -durN glibc-2.13.orig/grp/tst_fgetgrent.sh glibc-2.13/grp/tst_fgetgrent.sh
    19 --- glibc-2.13.orig/grp/tst_fgetgrent.sh	2001-07-06 06:54:46.000000000 +0200
    20 +++ glibc-2.13/grp/tst_fgetgrent.sh	2009-11-13 00:50:37.000000000 +0100
    21 @@ -24,7 +24,8 @@
    22  rtld_installed_name=$1; shift
    23  
    24  testout=${common_objpfx}/grp/tst_fgetgrent.out
    25 -library_path=${common_objpfx}
    26 +# make sure libdl is also in path in case sandbox is in use
    27 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
    28  
    29  result=0
    30  
    31 diff -durN glibc-2.13.orig/iconvdata/run-iconv-test.sh glibc-2.13/iconvdata/run-iconv-test.sh
    32 --- glibc-2.13.orig/iconvdata/run-iconv-test.sh	2008-05-15 03:59:44.000000000 +0200
    33 +++ glibc-2.13/iconvdata/run-iconv-test.sh	2009-11-13 00:50:37.000000000 +0100
    34 @@ -34,7 +34,7 @@
    35  export GCONV_PATH
    36  
    37  # We have to have some directories in the library path.
    38 -LIBPATH=$codir:$codir/iconvdata
    39 +LIBPATH=$codir:$codir/iconvdata:$codir/dlfcn
    40  
    41  # How the start the iconv(1) program.
    42  ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
    43 diff -durN glibc-2.13.orig/iconvdata/tst-table.sh glibc-2.13/iconvdata/tst-table.sh
    44 --- glibc-2.13.orig/iconvdata/tst-table.sh	2002-04-24 23:39:35.000000000 +0200
    45 +++ glibc-2.13/iconvdata/tst-table.sh	2009-11-13 00:50:37.000000000 +0100
    46 @@ -59,8 +59,11 @@
    47    irreversible=${charset}.irreversible
    48  fi
    49  
    50 +# make sure libdl is also in path in case sandbox is in use
    51 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
    52 +
    53  # iconv in one direction.
    54 -${common_objpfx}elf/ld.so --library-path $common_objpfx \
    55 +${common_objpfx}elf/ld.so --library-path $library_path \
    56  ${objpfx}tst-table-from ${charset} \
    57    > ${objpfx}tst-${charset}.table
    58  
    59 diff -durN glibc-2.13.orig/intl/tst-codeset.sh glibc-2.13/intl/tst-codeset.sh
    60 --- glibc-2.13.orig/intl/tst-codeset.sh	2005-04-06 04:18:35.000000000 +0200
    61 +++ glibc-2.13/intl/tst-codeset.sh	2009-11-13 00:50:37.000000000 +0100
    62 @@ -37,6 +37,9 @@
    63  LOCPATH=${common_objpfx}localedata
    64  export LOCPATH
    65  
    66 +# make sure libdl is also in path in case sandbox is in use
    67 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
    68 +
    69  ${common_objpfx}elf/ld.so --library-path $common_objpfx \
    70  ${objpfx}tst-codeset > ${objpfx}tst-codeset.out
    71  
    72 diff -durN glibc-2.13.orig/intl/tst-gettext.sh glibc-2.13/intl/tst-gettext.sh
    73 --- glibc-2.13.orig/intl/tst-gettext.sh	2004-08-15 21:28:18.000000000 +0200
    74 +++ glibc-2.13/intl/tst-gettext.sh	2009-11-13 00:50:37.000000000 +0100
    75 @@ -51,9 +51,12 @@
    76  LOCPATH=${common_objpfx}localedata
    77  export LOCPATH
    78  
    79 +# make sure libdl is also in path in case sandbox is in use
    80 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
    81 +
    82  # Now run the test.
    83  MALLOC_TRACE=$malloc_trace LOCPATH=${objpfx}localedir:$LOCPATH \
    84 -${common_objpfx}elf/ld.so --library-path $common_objpfx \
    85 +${common_objpfx}elf/ld.so --library-path $library_path \
    86  ${objpfx}tst-gettext > ${objpfx}tst-gettext.out ${objpfx}domaindir
    87  
    88  exit $?
    89 diff -durN glibc-2.13.orig/intl/tst-gettext2.sh glibc-2.13/intl/tst-gettext2.sh
    90 --- glibc-2.13.orig/intl/tst-gettext2.sh	2005-05-04 19:54:48.000000000 +0200
    91 +++ glibc-2.13/intl/tst-gettext2.sh	2009-11-13 00:50:37.000000000 +0100
    92 @@ -65,8 +65,11 @@
    93  LOCPATH=${objpfx}domaindir
    94  export LOCPATH
    95  
    96 +# make sure libdl is also in path in case sandbox is in use
    97 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
    98 +
    99  # Now run the test.
   100 -${common_objpfx}elf/ld.so --library-path $common_objpfx \
   101 +${common_objpfx}elf/ld.so --library-path $library_path \
   102  ${objpfx}tst-gettext2 > ${objpfx}tst-gettext2.out ${objpfx}domaindir &&
   103  cmp ${objpfx}tst-gettext2.out - <<EOF
   104  String1 - Lang1: 1st string
   105 diff -durN glibc-2.13.orig/intl/tst-translit.sh glibc-2.13/intl/tst-translit.sh
   106 --- glibc-2.13.orig/intl/tst-translit.sh	2005-05-04 19:56:10.000000000 +0200
   107 +++ glibc-2.13/intl/tst-translit.sh	2009-11-13 00:50:37.000000000 +0100
   108 @@ -36,7 +36,10 @@
   109  LOCPATH=${common_objpfx}localedata
   110  export LOCPATH
   111  
   112 -${common_objpfx}elf/ld.so --library-path $common_objpfx \
   113 +# make sure libdl is also in path in case sandbox is in use
   114 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
   115 +
   116 +${common_objpfx}elf/ld.so --library-path $library_path \
   117  ${objpfx}tst-translit > ${objpfx}tst-translit.out ${objpfx}domaindir
   118  
   119  exit $?
   120 diff -durN glibc-2.13.orig/malloc/tst-mtrace.sh glibc-2.13/malloc/tst-mtrace.sh
   121 --- glibc-2.13.orig/malloc/tst-mtrace.sh	2005-10-15 01:40:35.000000000 +0200
   122 +++ glibc-2.13/malloc/tst-mtrace.sh	2009-11-13 00:50:37.000000000 +0100
   123 @@ -24,9 +24,12 @@
   124  status=0
   125  trap "rm -f ${common_objpfx}malloc/tst-mtrace.leak; exit 1" 1 2 15
   126  
   127 +# make sure libdl is also in path in case sandbox is in use
   128 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
   129 +
   130  MALLOC_TRACE=${common_objpfx}malloc/tst-mtrace.leak \
   131  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
   132 -${common_objpfx}elf/ld.so --library-path $common_objpfx \
   133 +${common_objpfx}elf/ld.so --library-path $library_path \
   134    ${common_objpfx}malloc/tst-mtrace || status=1
   135  
   136  if test $status -eq 0 && test -f ${common_objpfx}malloc/mtrace; then
   137 diff -durN glibc-2.13.orig/nptl/tst-tls6.sh glibc-2.13/nptl/tst-tls6.sh
   138 --- glibc-2.13.orig/nptl/tst-tls6.sh	2003-09-03 00:02:59.000000000 +0200
   139 +++ glibc-2.13/nptl/tst-tls6.sh	2009-11-13 00:50:37.000000000 +0100
   140 @@ -5,8 +5,8 @@
   141  rtld_installed_name=$1; shift
   142  logfile=$common_objpfx/nptl/tst-tls6.out
   143  
   144 -# We have to find libc and nptl
   145 -library_path=${common_objpfx}:${common_objpfx}nptl
   146 +# We have to find libc and nptl (also libdl in case sandbox is in use)
   147 +library_path=${common_objpfx}:${common_objpfx}nptl:${common_objpfx}/dlfcn
   148  tst_tls5="${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
   149  	  ${common_objpfx}/nptl/tst-tls5"
   150  
   151 diff -durN glibc-2.13.orig/posix/globtest.sh glibc-2.13/posix/globtest.sh
   152 --- glibc-2.13.orig/posix/globtest.sh	2008-12-06 07:05:39.000000000 +0100
   153 +++ glibc-2.13/posix/globtest.sh	2009-11-13 00:50:37.000000000 +0100
   154 @@ -18,7 +18,7 @@
   155  esac
   156  
   157  # We have to find the libc and the NSS modules.
   158 -library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
   159 +library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod:${common_objpfx}/dlfcn
   160  
   161  # Since we use `sort' we must make sure to use the same locale everywhere.
   162  LC_ALL=C
   163 diff -durN glibc-2.13.orig/posix/tst-getconf.sh glibc-2.13/posix/tst-getconf.sh
   164 --- glibc-2.13.orig/posix/tst-getconf.sh	2002-09-01 13:11:25.000000000 +0200
   165 +++ glibc-2.13/posix/tst-getconf.sh	2009-11-13 00:50:37.000000000 +0100
   166 @@ -10,7 +10,10 @@
   167  else
   168    rtld_installed_name=$1; shift
   169    runit() {
   170 -    ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} "$@"
   171 +    
   172 +  # make sure libdl is also in path in case sandbox is in use
   173 +  library_path=${common_objpfx}:${common_objpfx}/dlfcn
   174 +    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} "$@"
   175    }
   176  fi
   177  
   178 diff -durN glibc-2.13.orig/posix/wordexp-tst.sh glibc-2.13/posix/wordexp-tst.sh
   179 --- glibc-2.13.orig/posix/wordexp-tst.sh	2000-10-20 18:23:30.000000000 +0200
   180 +++ glibc-2.13/posix/wordexp-tst.sh	2009-11-13 00:50:37.000000000 +0100
   181 @@ -19,8 +19,11 @@
   182  "
   183  export IFS
   184  
   185 +# make sure libdl is also in path in case sandbox is in use
   186 +library_path=${common_objpfx}:${common_objpfx}/dlfcn
   187 +
   188  failed=0
   189 -${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
   190 +${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
   191  ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
   192  cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
   193  wordexp returned 0