da8af7e686960cca6f8a42d080d4c8093580ac3e
[platform/upstream/glibc.git] / sysdeps / x86_64 / tst-xmmymm.sh
1 #! /bin/bash
2 objpfx="$1"
3
4 tmp=$(mktemp ${objpfx}tst-xmmymm.XXXXXX)
5 trap 'rm -f "$tmp"' 1 2 3 15
6
7 # List of object files we have to test
8 rtldobjs=$(readelf -W -wi ${objpfx}dl-allobjs.os |
9     awk '/^ </ { if ($5 == "(DW_TAG_compile_unit)") c=1; else c=0 } $2 == "DW_AT_name" { if (c == 1) print $NF }' |
10     sed 's,\(.*/\|\)\([_[:alnum:]-]*[.]\).$,\2os,')
11 rtldobjs="$rtldobjs $(ar t ${objpfx}rtld-libc.a)"
12
13 # OBJECT symbols can be ignored.
14 readelf -sW ${objpfx}dl-allobjs.os ${objpfx}rtld-libc.a |
15 egrep " OBJECT  *GLOBAL " |
16 awk '{if ($7 != "ABS") print $8 }' |
17 sort -u > "$tmp"
18 declare -a objects
19 objects=($(cat "$tmp"))
20
21 objs="dl-runtime.os"
22 tocheck="dl-runtime.os"
23
24 while test -n "$objs"; do
25   this="$objs"
26   objs=""
27
28   for f in $this; do
29     undef=$(nm -u "$objpfx"../*/"$f" | awk '{print $2}')
30     if test -n "$undef"; then
31       for s in $undef; do
32         for obj in ${objects[*]} "_GLOBAL_OFFSET_TABLE_"; do
33           if test "$obj" = "$s"; then
34             continue 2
35           fi
36         done
37         for o in $rtldobjs; do
38           ro=$(echo "$objpfx"../*/"$o")
39           if nm -g --defined-only "$ro" | egrep -qs " $s\$"; then
40             if ! (echo "$tocheck $objs" | fgrep -qs "$o"); then
41               echo "$o needed for $s"
42               objs="$objs $o"
43             fi
44             break;
45           fi
46         done
47       done
48     fi
49   done
50   tocheck="$tocheck$objs"
51 done
52
53 echo
54 echo
55 echo "object files needed: $tocheck"
56
57 cp /dev/null "$tmp"
58 for f in $tocheck; do
59   objdump -d "$objpfx"../*/"$f" |
60   awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
61   while read fct; do
62     if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
63       continue;
64     fi
65     echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
66     result=1
67   done
68 done
69
70 if test -s "$tmp"; then
71   echo
72   echo
73   cat "$tmp"
74   result=1
75 else
76   result=0
77 fi
78
79 rm "$tmp"
80 exit $result