#include <stdint.h>
#include <_itoa.h>
#include <dl-hwcaps.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <not-errno.h>
#ifndef _DL_PLATFORMS_COUNT
# define _DL_PLATFORMS_COUNT 0
if (cache_new != (void *) -1)
{
uint64_t platform;
+ int disable_hwcap = 0;
/* This is where the strings start. */
cache_data = (const char *) cache_new;
uint64_t hwcap_mask = GET_HWCAP_MASK();
+#ifdef NEED_LD_SO_NOHWCAP
+ if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
+ disable_hwcap = 1;
+#endif
+
#define _DL_HWCAP_TLS_MASK (1LL << 63)
uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & hwcap_mask)
| _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
continue; \
if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
continue; \
+ if (disable_hwcap && lib->hwcap != 0) \
+ continue; \
if (_DL_PLATFORMS_COUNT \
&& (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
&& (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
#include <libintl.h>
#include <unistd.h>
#include <ldsodefs.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <not-errno.h>
#include <dl-procinfo.h>
#include <dl-hwcaps.h>
size_t cnt = platform != NULL;
size_t n, m;
size_t total;
+ struct r_strlenpair *temp;
struct r_strlenpair *result;
struct r_strlenpair *rp;
char *cp;
/* For TLS enabled builds always add 'tls'. */
++cnt;
+#ifdef NEED_LD_SO_NOHWCAP
+ if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
+ {
+ /* If hwcap is disabled, we only have the base directory to search. */
+ result = (struct r_strlenpair *) malloc (sizeof (*result));
+ if (result == NULL)
+ goto no_memory;
+
+ result[0].str = (char *) result; /* Does not really matter. */
+ result[0].len = 0;
+
+ *sz = 1;
+ return result;
+ }
+#endif
+
/* Create temporary data structure to generate result table. */
- struct r_strlenpair temp[cnt];
+ temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
m = 0;
for (n = 0; masked != 0; ++n)
if ((masked & (1ULL << n)) != 0)
*sz = 1 << cnt;
result = (struct r_strlenpair *) malloc (*sz * sizeof (*result) + total);
if (result == NULL)
- _dl_signal_error (ENOMEM, NULL, NULL,
- N_("cannot create capability list"));
+ {
+#ifdef NEED_LD_SO_NOHWCAP
+ no_memory:
+#endif
+ _dl_signal_error (ENOMEM, NULL, NULL,
+ N_("cannot create capability list"));
+ }
if (cnt == 1)
{