x86: Set minimum x86-64 level marker [BZ #27318]
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 2 Feb 2021 21:45:58 +0000 (13:45 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 6 Mar 2021 15:49:30 +0000 (07:49 -0800)
commit339bf918ea4830fb35614632e96f3aab3237adce
tree5ecd1bdd6660574885c79796e389c30dcd6bc539
parent3c667926673bac6017bf78569f582f6baee9948f
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.
config.h.in
sysdeps/x86/configure
sysdeps/x86/configure.ac
sysdeps/x86/isa-level.c