From 511c5a1087991108118c6e9c9546e83e992bf39c Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 23 May 2017 00:59:16 +0530 Subject: Make LD_HWCAP_MASK usable for static binaries The LD_HWCAP_MASK environment variable was ignored in static binaries, which is inconsistent with the behaviour of dynamically linked binaries. This seems to have been because of the inability of ld_hwcap_mask being read early enough to influence anything but now that it is in tunables, the mask is usable in static binaries as well. This feature is important for aarch64, which relies on HWCAP_CPUID being masked out to disable multiarch. A sanity test on x86_64 shows that there are no failures. Likewise for aarch64. * elf/dl-hwcaps.h [HAVE_TUNABLES]: Always read hwcap_mask. * sysdeps/sparc/sparc32/dl-machine.h [HAVE_TUNABLES]: Likewise. * sysdeps/x86/cpu-features.c (init_cpu_features): Always set up hwcap and hwcap_mask. --- elf/dl-hwcaps.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'elf') diff --git a/elf/dl-hwcaps.h b/elf/dl-hwcaps.h index 9ce33173f1..2c4fa3db02 100644 --- a/elf/dl-hwcaps.h +++ b/elf/dl-hwcaps.h @@ -18,14 +18,13 @@ #include -#ifdef SHARED -# if HAVE_TUNABLES -# define GET_HWCAP_MASK() \ - TUNABLE_GET (glibc, tune, hwcap_mask, uint64_t, NULL) +#if HAVE_TUNABLES +# define GET_HWCAP_MASK() TUNABLE_GET (glibc, tune, hwcap_mask, uint64_t, NULL) +#else +# ifdef SHARED +# define GET_HWCAP_MASK() GLRO(dl_hwcap_mask) # else -# define GET_HWCAP_MASK() GLRO(dl_hwcap_mask) +/* HWCAP_MASK is ignored in static binaries when built without tunables. */ +# define GET_HWCAP_MASK() (0) # endif -#else -/* HWCAP_MASK is ignored in static binaries. */ -# define GET_HWCAP_MASK() (0) #endif -- cgit v1.2.3