glibc/sysdeps/i386/tst-ld-sse-use.sh

104 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
# Make sure no code in ld.so uses xmm/ymm/zmm registers on i386.
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
# 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
Prefer https to http for gnu.org and fsf.org URLs Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
# <https://www.gnu.org/licenses/>.
set -e
objpfx="$1"
NM="$2"
OBJDUMP="$3"
READELF="$4"
tmp=$(mktemp ${objpfx}tst-ld-sse-use.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) } /,%[xyz]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/zmm" >> "$tmp"
result=1
done
done
if test -s "$tmp"; then
echo
echo
cat "$tmp"
result=1
else
result=0
fi
rm "$tmp"
exit $result