summaryrefslogtreecommitdiff
path: root/libc/sysdeps/x86_64/tst-xmmymm.sh
blob: da8af7e686960cca6f8a42d080d4c8093580ac3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/bash
objpfx="$1"

tmp=$(mktemp ${objpfx}tst-xmmymm.XXXXXX)
trap 'rm -f "$tmp"' 1 2 3 15

# List of object files we have to test
rtldobjs=$(readelf -W -wi ${objpfx}dl-allobjs.os |
    awk '/^ </ { if ($5 == "(DW_TAG_compile_unit)") c=1; else c=0 } $2 == "DW_AT_name" { if (c == 1) print $NF }' |
    sed 's,\(.*/\|\)\([_[:alnum:]-]*[.]\).$,\2os,')
rtldobjs="$rtldobjs $(ar t ${objpfx}rtld-libc.a)"

# OBJECT symbols can be ignored.
readelf -sW ${objpfx}dl-allobjs.os ${objpfx}rtld-libc.a |
egrep " OBJECT  *GLOBAL " |
awk '{if ($7 != "ABS") print $8 }' |
sort -u > "$tmp"
declare -a objects
objects=($(cat "$tmp"))

objs="dl-runtime.os"
tocheck="dl-runtime.os"

while test -n "$objs"; do
  this="$objs"
  objs=""

  for f in $this; do
    undef=$(nm -u "$objpfx"../*/"$f" | awk '{print $2}')
    if test -n "$undef"; then
      for s in $undef; do
	for obj in ${objects[*]} "_GLOBAL_OFFSET_TABLE_"; do
	  if test "$obj" = "$s"; then
	    continue 2
	  fi
	done
        for o in $rtldobjs; do
	  ro=$(echo "$objpfx"../*/"$o")
	  if nm -g --defined-only "$ro" | egrep -qs " $s\$"; then
	    if ! (echo "$tocheck $objs" | fgrep -qs "$o"); then
	      echo "$o needed for $s"
	      objs="$objs $o"
	    fi
	    break;
	  fi
	done
      done
    fi
  done
  tocheck="$tocheck$objs"
done

echo
echo
echo "object files needed: $tocheck"

cp /dev/null "$tmp"
for f in $tocheck; do
  objdump -d "$objpfx"../*/"$f" |
  awk 'BEGIN { last="" } /^[[:xdigit:]]* <[_[:alnum:]]*>:$/ { fct=substr($2, 2, length($2)-3) } /,%[xy]mm[[:digit:]]*$/ { if (last != fct) { print fct; last=fct} }' |
  while read fct; do
    if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
      continue;
    fi
    echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
    result=1
  done
done

if test -s "$tmp"; then
  echo
  echo
  cat "$tmp"
  result=1
else
  result=0
fi

rm "$tmp"
exit $result