V5 [PATCH 0/2] x86: Support GNU_PROPERTY_X86_ISA_1_NEEDED marker [BZ #26717]

H.J. Lu hjl.tools@gmail.com
Sun Dec 6 14:49:50 GMT 2020


GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA
levels and -mneeded to emit GNU_PROPERTY_X86_ISA_1_NEEDED property with
GNU_PROPERTY_X86_ISA_1_V[234] marker.

GNU_PROPERTY_X86_ISA_1_NEEDED property in x86 ELF binaries indicate the
micro-architecture ISA level required to execute the binary.  The marker
must be added by programmers explicitly in one of 3 ways:

1. Pass -mneeded to GCC.
2. Add the marker in the linker inputs as this patch does.
3. Pass -z x86-64-v[234] to the linker.

Marked elf/tst-isa-level-1 with x86-64-v4, ran it on x86-64-v3 machine
and got:

[hjl@gnu-cfl-2 build-x86_64-linux]$ ./elf/tst-isa-level-1
./elf/tst-isa-level-1: CPU ISA level is lower than required
[hjl@gnu-cfl-2 build-x86_64-linux]$

H.J. Lu (2):
  x86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker [BZ #26717]
  ldconfig/x86: Add ISA level check to glibc-hwcaps

 config.h.in                                   |   3 +
 elf/elf.h                                     |  35 +++---
 elf/ldconfig.c                                |   9 +-
 elf/readelflib.c                              |  83 ++++++++++++-
 elf/readlib.c                                 |   7 +-
 elf/tst-glibc-hwcaps-2-cache.c                |  45 +++++++
 .../etc/ld.so.conf                            |   2 +
 .../postclean.req                             |   0
 elf/tst-glibc-hwcaps-2-cache.script           |   6 +
 sysdeps/generic/ldconfig.h                    |   9 +-
 sysdeps/generic/read-prop.h                   |  32 +++++
 sysdeps/unix/sysv/linux/x86/read-prop.h       |  57 +++++++++
 sysdeps/unix/sysv/linux/x86/readelflib.c      |  67 +++++++++--
 sysdeps/unix/sysv/linux/x86_64/Makefile       |  26 ++++
 .../sysv/linux/x86_64/tst-glibc-hwcaps-2.c    |  50 ++++++++
 .../linux/x86_64/x86-64-isa-level-VALUE.c     |   4 +
 sysdeps/x86/Makefile                          |  10 ++
 sysdeps/x86/abi-note.c                        |  29 +++++
 sysdeps/x86/configure                         | 101 ++++++++++++++++
 sysdeps/x86/configure.ac                      |  26 ++++
 sysdeps/x86/cpu-features.c                    |   3 +
 sysdeps/x86/dl-cet.c                          |  12 +-
 sysdeps/x86/dl-prop.h                         | 113 +++++++++++++-----
 sysdeps/x86/get-isa-level.h                   |  66 ++++++++++
 sysdeps/x86/include/cpu-features.h            |   2 +
 sysdeps/x86/isa-level.c                       |  95 +++++++++++++++
 sysdeps/x86/link_map.h                        |  18 +--
 sysdeps/x86/tst-isa-level-1.c                 |  74 ++++++++++++
 sysdeps/x86/tst-isa-level-mod-1.c             |  23 ++++
 sysdeps/x86/tst-isa-level-mod-1a.c            |   2 +
 sysdeps/x86/tst-isa-level-mod-1b.c            |   1 +
 sysdeps/x86_64/dl-hwcaps-subdirs.c            |  30 ++---
 sysdeps/x86_64/tst-glibc-hwcaps.c             |  41 ++-----
 33 files changed, 950 insertions(+), 131 deletions(-)
 create mode 100644 elf/tst-glibc-hwcaps-2-cache.c
 create mode 100644 elf/tst-glibc-hwcaps-2-cache.root/etc/ld.so.conf
 create mode 100644 elf/tst-glibc-hwcaps-2-cache.root/postclean.req
 create mode 100644 elf/tst-glibc-hwcaps-2-cache.script
 create mode 100644 sysdeps/generic/read-prop.h
 create mode 100644 sysdeps/unix/sysv/linux/x86/read-prop.h
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-glibc-hwcaps-2.c
 create mode 100644 sysdeps/unix/sysv/linux/x86_64/x86-64-isa-level-VALUE.c
 create mode 100644 sysdeps/x86/abi-note.c
 create mode 100644 sysdeps/x86/get-isa-level.h
 create mode 100644 sysdeps/x86/isa-level.c
 create mode 100644 sysdeps/x86/tst-isa-level-1.c
 create mode 100644 sysdeps/x86/tst-isa-level-mod-1.c
 create mode 100644 sysdeps/x86/tst-isa-level-mod-1a.c
 create mode 100644 sysdeps/x86/tst-isa-level-mod-1b.c

-- 
2.28.0



More information about the Libc-alpha mailing list