diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-02-02 13:45:58 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-03-06 07:49:30 -0800 |
commit | 339bf918ea4830fb35614632e96f3aab3237adce (patch) | |
tree | 5ecd1bdd6660574885c79796e389c30dcd6bc539 /sysdeps/x86/configure.ac | |
parent | 3c667926673bac6017bf78569f582f6baee9948f (diff) | |
download | glibc-339bf918ea4830fb35614632e96f3aab3237adce.tar glibc-339bf918ea4830fb35614632e96f3aab3237adce.tar.gz glibc-339bf918ea4830fb35614632e96f3aab3237adce.tar.bz2 glibc-339bf918ea4830fb35614632e96f3aab3237adce.zip |
x86: Set minimum x86-64 level marker [BZ #27318]
Since the full ISA set used in an ELF binary is unknown to compiler,
an x86-64 ISA level marker indicates the minimum, not maximum, ISA set
required to run such an ELF binary. We never guarantee a library with
an x86-64 ISA level v3 marker doesn't contain other ISAs beyond x86-64
ISA level v3, like AVX VNNI. We check the x86-64 ISA level marker for
the minimum ISA set. Since -march=sandybridge enables only some ISAs
in x86-64 ISA level v3, we should set the needed ISA marker to v2.
Otherwise, libc is compiled with -march=sandybridge will fail to run on
Sandy Bridge:
$ ./elf/ld.so ./libc.so
./libc.so: (p) CPU ISA level is lower than required: needed: 7; got: 3
Set the minimum, instead of maximum, x86-64 ISA level marker should have
no impact on the glibc-hwcaps directory assignment logic in ldconfig nor
ld.so.
Diffstat (limited to 'sysdeps/x86/configure.ac')
-rw-r--r-- | sysdeps/x86/configure.ac | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac index f94088f377..bca97fdc2f 100644 --- a/sysdeps/x86/configure.ac +++ b/sysdeps/x86/configure.ac @@ -98,14 +98,30 @@ cat > conftest2.S <<EOF 4: EOF libc_cv_include_x86_isa_level=no +libc_cv_have_x86_lahf_sahf=no +libc_cv_have_x86_movbe=no if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l` if test "$count" = 1; then libc_cv_include_x86_isa_level=yes + cat > conftest.c <<EOF +EOF + if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c) | grep -q "\-msahf"; then + libc_cv_have_x86_lahf_sahf=yes + fi + if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c) | grep -q "\-mmovbe"; then + libc_cv_have_x86_movbe=yes + fi fi fi rm -f conftest*]) if test $libc_cv_include_x86_isa_level = yes; then AC_DEFINE(INCLUDE_X86_ISA_LEVEL) fi +if test $libc_cv_have_x86_lahf_sahf = yes; then + AC_DEFINE(HAVE_X86_LAHF_SAHF) +fi +if test $libc_cv_have_x86_movbe = yes; then + AC_DEFINE(HAVE_X86_MOVBE) +fi LIBC_CONFIG_VAR([enable-x86-isa-level], [$libc_cv_include_x86_isa_level]) |