HomeFreeBSD

linux(4): Don't relie on process osreldata when testing features

Description

linux(4): Don't relie on process osreldata when testing features

The ELF note identifyies the operating-system ABI that the executable
was created for. The note data of the Glibc executable contains the
earliest release number of the Linux kernel that supports this ABI.
As of a current 2.37 version of Glibc, it is 3.2.0 for x86, 3.7.0
for Aarch64.
Glibc does not use this release number and the current kernel's
LINUX_VERSION_CODE to detect kernel features, using fallbacks to known
previous way in case of ENOSYS or something else instead.

A dynamically linked Glibc reads the current kernel's LINUX_VERSION_CODE
from the ELF note in the vDSO or fallback to uname syscall if the vDSO
can't be located and parse the release field in struct utsname. Glibc
uses the current kernel's LINUX_VERSION_CODE for "kernel too old" check.

While here use inlined LINUX_KERNVER for tests to improve readability,
as suggested by emaste@.

MFC after: 1 month

(cherry picked from commit 76f8584e49cf7eedaa2e1312593bf46c7225d79a)

Details

Provenance
dchaginAuthored on Apr 26 2023, 1:56 PM
Parents
rG276bc96ff331: linux(4): Fix arm64 build after b7a6bcdd, missed chunk added
Branches
Unknown
Tags
Unknown