From patchwork Tue Aug 25 20:53:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 8438 Received: (qmail 47529 invoked by alias); 25 Aug 2015 20:54:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 47511 invoked by uid 89); 25 Aug 2015 20:54:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f171.google.com MIME-Version: 1.0 X-Received: by 10.60.36.202 with SMTP id s10mr30259209oej.0.1440536033307; Tue, 25 Aug 2015 13:53:53 -0700 (PDT) In-Reply-To: <20150825183521.2898C2C3A73@topped-with-meat.com> References: <20150825122223.GA1588@gmail.com> <20150825183521.2898C2C3A73@topped-with-meat.com> Date: Tue, 25 Aug 2015 13:53:53 -0700 Message-ID: Subject: Re: [PATCH 2/7] Don't disable SSE in x86-64 ld.so From: "H.J. Lu" To: Roland McGrath Cc: GNU C Library On Tue, Aug 25, 2015 at 11:35 AM, Roland McGrath wrote: > When you're just moving code from one file to another, make that clear in > the log entry. The original code needed comments explaining why it's > there. So add some now. Here is the updated patch. OK for master? From 60aa23c4b74d5c5ee72874f642086e2d5a8b457f Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 28 Jul 2015 18:56:18 -0700 Subject: [PATCH] Don't disable SSE in x86-64 ld.so Since x86-64 ld.so preserves vector registers now, we can use SSE in x86-64 ld.so. We should run tst-ld-sse-use.sh only on i386. * sysdeps/x86/Makefile [$(subdir) == elf] (CFLAGS-.os, tests-special, $(objpfx)tst-ld-sse-use.out): Moved to ... * sysdeps/i386/Makefile [$(subdir) == elf] (CFLAGS-.os, tests-special, $(objpfx)tst-ld-sse-use.out): Here. * sysdeps/x86_64/Makefile [$(subdir) == elf] (CFLAGS-.os): Add -mno-mmx for $(all-rtld-routines). * sysdeps/x86/tst-ld-sse-use.sh: Moved to ... * sysdeps/i386/tst-ld-sse-use.sh: Here. Update comments. --- sysdeps/i386/Makefile | 11 +++++ sysdeps/i386/tst-ld-sse-use.sh | 105 +++++++++++++++++++++++++++++++++++++++++ sysdeps/x86/Makefile | 11 ----- sysdeps/x86/tst-ld-sse-use.sh | 103 ---------------------------------------- sysdeps/x86_64/Makefile | 3 ++ 5 files changed, 119 insertions(+), 114 deletions(-) create mode 100755 sysdeps/i386/tst-ld-sse-use.sh delete mode 100755 sysdeps/x86/tst-ld-sse-use.sh diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile index 717d8e7..cb47e3c 100644 --- a/sysdeps/i386/Makefile +++ b/sysdeps/i386/Makefile @@ -83,3 +83,14 @@ endif ifeq ($(subdir),csu) gen-as-const-headers += tlsdesc.sym endif + +ifeq ($(subdir),elf) +CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\ + -mno-sse -mno-mmx) + +tests-special += $(objpfx)tst-ld-sse-use.out +$(objpfx)tst-ld-sse-use.out: ../sysdeps/i386/tst-ld-sse-use.sh $(objpfx)ld.so + @echo "Checking ld.so for SSE register use. This will take a few seconds..." + $(BASH) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@; \ + $(evaluate-test) +endif diff --git a/sysdeps/i386/tst-ld-sse-use.sh b/sysdeps/i386/tst-ld-sse-use.sh new file mode 100755 index 0000000..7267dbb --- /dev/null +++ b/sysdeps/i386/tst-ld-sse-use.sh @@ -0,0 +1,105 @@ +#! /bin/bash +# Make sure no code in ld.so uses xmm/ymm/zmm registers on i386 since +# the first 3 xmm/ymm/zmm registers are used to pass vector parameters +# which must be preserved. +# Copyright (C) 2009-2015 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 +# . + +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 '/^ "$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 diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index c262fdf..0de4f42 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -1,14 +1,3 @@ -ifeq ($(subdir),elf) -CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\ - -mno-sse -mno-mmx) - -tests-special += $(objpfx)tst-ld-sse-use.out -$(objpfx)tst-ld-sse-use.out: ../sysdeps/x86/tst-ld-sse-use.sh $(objpfx)ld.so - @echo "Checking ld.so for SSE register use. This will take a few seconds..." - $(BASH) $< $(objpfx) '$(NM)' '$(OBJDUMP)' '$(READELF)' > $@; \ - $(evaluate-test) -endif - ifeq ($(subdir),csu) gen-as-const-headers += cpu-features-offsets.sym rtld-global-offsets.sym endif diff --git a/sysdeps/x86/tst-ld-sse-use.sh b/sysdeps/x86/tst-ld-sse-use.sh deleted file mode 100755 index 839de18..0000000 --- a/sysdeps/x86/tst-ld-sse-use.sh +++ /dev/null @@ -1,103 +0,0 @@ -#! /bin/bash -# Make sure no code in ld.so uses xmm/ymm/zmm registers on x86-64. -# Copyright (C) 2009-2015 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 -# . - -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 '/^ "$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 diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index e50bcad..7bcfd87 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -19,6 +19,9 @@ gen-as-const-headers += locale-defines.sym endif ifeq ($(subdir),elf) +CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\ + -mno-mmx) + sysdep-dl-routines += tlsdesc dl-tlsdesc tests += ifuncmain8 -- 2.4.3