conformtest: Fix pthreads expectations for XPG3 / XPG4 / UNIX98.
[platform/upstream/glibc.git] / sysdeps / x86_64 / tst-xmmymm.sh
1 #! /bin/bash
2 # Make sure no code in ld.so uses xmm/ymm registers on x86-64.
3 # Copyright (C) 2009-2012 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
19
20 set -e
21
22 objpfx="$1"
23
24 tmp=$(mktemp ${objpfx}tst-xmmymm.XXXXXX)
25 trap 'rm -f "$tmp"' 1 2 3 15
26
27 # List of object files we have to test
28 rtldobjs=$(readelf -W -wi ${objpfx}dl-allobjs.os |
29     awk '/^ </ { if ($5 == "(DW_TAG_compile_unit)") c=1; else c=0 } $2 == "DW_AT_name" { if (c == 1) print $NF }' |
30     sed 's,\(.*/\|\)\([_[:alnum:]-]*[.]\).$,\2os,')
31 rtldobjs="$rtldobjs $(ar t ${objpfx}rtld-libc.a)"
32
33 # OBJECT symbols can be ignored.
34 readelf -sW ${objpfx}dl-allobjs.os ${objpfx}rtld-libc.a |
35 egrep " OBJECT  *GLOBAL " |
36 awk '{if ($7 != "ABS") print $8 }' |
37 sort -u > "$tmp"
38 declare -a objects
39 objects=($(cat "$tmp"))
40
41 objs="dl-runtime.os"
42 tocheck="dl-runtime.os"
43
44 while test -n "$objs"; do
45   this="$objs"
46   objs=""
47
48   for f in $this; do
49     undef=$(nm -u "$objpfx"../*/"$f" | awk '{print $2}')
50     if test -n "$undef"; then
51       for s in $undef; do
52         for obj in ${objects[*]} "_GLOBAL_OFFSET_TABLE_"; do
53           if test "$obj" = "$s"; then
54             continue 2
55           fi
56         done
57         for o in $rtldobjs; do
58           ro=$(echo "$objpfx"../*/"$o")
59           if nm -g --defined-only "$ro" | egrep -qs " $s\$"; then
60             if ! (echo "$tocheck $objs" | fgrep -qs "$o"); then
61               echo "$o needed for $s"
62               objs="$objs $o"
63             fi
64             break;
65           fi
66         done
67       done
68     fi
69   done
70   tocheck="$tocheck$objs"
71 done
72
73 echo
74 echo
75 echo "object files needed: $tocheck"
76
77 cp /dev/null "$tmp"
78 for f in $tocheck; do
79   objdump -d "$objpfx"../*/"$f" |
80   awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
81   while read fct; do
82     if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
83       continue;
84     fi
85     echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
86     result=1
87   done
88 done
89
90 if test -s "$tmp"; then
91   echo
92   echo
93   cat "$tmp"
94   result=1
95 else
96   result=0
97 fi
98
99 rm "$tmp"
100 exit $result