2009-07-27 20:40:27 +00:00
|
|
|
#! /bin/bash
|
2012-09-24 20:58:00 +00:00
|
|
|
# Make sure no code in ld.so uses xmm/ymm registers on x86-64.
|
2013-01-02 19:01:50 +00:00
|
|
|
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
2012-09-24 20:58:00 +00:00
|
|
|
# This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with the GNU C Library; if not, see
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-09-24 20:52:13 +00:00
|
|
|
set -e
|
|
|
|
|
2009-07-26 23:10:00 +00:00
|
|
|
objpfx="$1"
|
2012-11-08 00:01:46 +00:00
|
|
|
NM="$2"
|
|
|
|
OBJDUMP="$3"
|
|
|
|
READELF="$4"
|
2009-07-26 23:10:00 +00:00
|
|
|
|
|
|
|
tmp=$(mktemp ${objpfx}tst-xmmymm.XXXXXX)
|
|
|
|
trap 'rm -f "$tmp"' 1 2 3 15
|
|
|
|
|
2009-07-27 20:40:27 +00:00
|
|
|
# List of object files we have to test
|
2012-11-08 00:01:46 +00:00
|
|
|
rtldobjs=$($READELF -W -wi ${objpfx}dl-allobjs.os |
|
2009-07-27 20:40:27 +00:00
|
|
|
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)"
|
2009-07-26 23:10:00 +00:00
|
|
|
|
2009-07-27 20:40:27 +00:00
|
|
|
# OBJECT symbols can be ignored.
|
2012-11-08 00:01:46 +00:00
|
|
|
$READELF -sW ${objpfx}dl-allobjs.os ${objpfx}rtld-libc.a |
|
2009-07-27 20:40:27 +00:00
|
|
|
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
|
2012-11-08 00:01:46 +00:00
|
|
|
undef=$($NM -u "$objpfx"../*/"$f" | awk '{print $2}')
|
2009-07-27 20:40:27 +00:00
|
|
|
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")
|
2012-11-08 00:01:46 +00:00
|
|
|
if $NM -g --defined-only "$ro" | egrep -qs " $s\$"; then
|
2009-07-27 20:40:27 +00:00
|
|
|
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
|
2012-11-08 00:01:46 +00:00
|
|
|
$OBJDUMP -d "$objpfx"../*/"$f" |
|
2009-07-27 20:40:27 +00:00
|
|
|
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
|
2009-07-29 15:33:03 +00:00
|
|
|
if test "$fct" = "_dl_runtime_profile" -o "$fct" = "_dl_x86_64_restore_sse"; then
|
|
|
|
continue;
|
2009-07-27 20:40:27 +00:00
|
|
|
fi
|
2009-07-29 15:33:03 +00:00
|
|
|
echo "function $fct in $f modifies xmm/ymm" >> "$tmp"
|
|
|
|
result=1
|
2009-07-27 20:40:27 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -s "$tmp"; then
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
cat "$tmp"
|
|
|
|
result=1
|
|
|
|
else
|
|
|
|
result=0
|
|
|
|
fi
|
2009-07-26 23:10:00 +00:00
|
|
|
|
|
|
|
rm "$tmp"
|
2009-07-27 20:40:27 +00:00
|
|
|
exit $result
|