initial commit
[glibc.git] / debian / patches / any / local-ldso-disable-hwcap.diff
1 # DP: Allow hwcap's to be disabled with the existence of a file. This
2 # DP: makes it easier to do upgrades with optimized (hwcap) library
3 # DP: packages.
4 # DP: Author: Rewritten by Daniel Jacobowitz <dan@debian.org>
5 # DP: Upstream status: Debian-Specific
6 # DP: Status Details: This isn't going to be acceptable upstream, we
7 # DP: only need it because we support in-place upgrades.
8 # DP: Date: 2003-10-28, (Updated 2005-01-02 gotom, 2007-05-20 aurel32)
9
10 ---
11 elf/dl-cache.c | 10 ++++++++++
12 elf/dl-hwcaps.c | 20 ++++++++++++++++++++
13 sysdeps/alpha/ldsodefs.h | 2 ++
14 3 files changed, 32 insertions(+)
15
16 --- a/elf/dl-hwcaps.c
17 +++ b/elf/dl-hwcaps.c
18 @@ -22,6 +22,9 @@
19 #include <libintl.h>
20 #include <unistd.h>
21 #include <ldsodefs.h>
22 +#include <fcntl.h>
23 +#include <sysdep.h>
24 +#include <not-errno.h>
25
26 #include <dl-procinfo.h>
27 #include <dl-hwcaps.h>
28 @@ -204,6 +207,23 @@
29 /* For TLS enabled builds always add 'tls'. */
30 ++cnt;
31
32 +#ifdef NEED_LD_SO_NOHWCAP
33 + if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
34 + {
35 + /* If hwcap is disabled, we only have the base directory to search. */
36 + result = (struct r_strlenpair *) malloc (sizeof (*result));
37 + if (result == NULL)
38 + _dl_signal_error (ENOMEM, NULL, NULL,
39 + N_("cannot create capability list"));
40 +
41 + result[0].str = (char *) result; /* Does not really matter. */
42 + result[0].len = 0;
43 +
44 + *sz = 1;
45 + return result;
46 + }
47 +#endif
48 +
49 /* Create temporary data structure to generate result table. */
50 struct r_strlenpair temp[cnt];
51 m = 0;
52 --- a/elf/dl-cache.c
53 +++ b/elf/dl-cache.c
54 @@ -26,6 +26,9 @@
55 #include <_itoa.h>
56 #include <dl-hwcaps.h>
57 #include <dl-isa-level.h>
58 +#include <fcntl.h>
59 +#include <sysdep.h>
60 +#include <not-errno.h>
61
62 #ifndef _DL_PLATFORMS_COUNT
63 # define _DL_PLATFORMS_COUNT 0
64 @@ -216,6 +219,11 @@
65 #ifdef SHARED
66 uint32_t best_priority = 0;
67 #endif
68 + int disable_hwcap = 0;
69 +#ifdef NEED_LD_SO_NOHWCAP
70 + if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
71 + disable_hwcap = 1;
72 +#endif
73
74 while (left <= right)
75 {
76 @@ -297,6 +305,8 @@
77
78 if ((libnew->hwcap & hwcap_exclude) && !named_hwcap)
79 continue;
80 + if (disable_hwcap && libnew->hwcap != 0)
81 + continue;
82 if (_DL_PLATFORMS_COUNT
83 && (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0
84 && ((libnew->hwcap & _DL_HWCAP_PLATFORM)
85 --- a/sysdeps/alpha/ldsodefs.h
86 +++ b/sysdeps/alpha/ldsodefs.h
87 @@ -37,6 +37,8 @@
88 struct La_alpha_retval *, \
89 const char *);
90
91 +#define NEED_LD_SO_NOHWCAP
92 +
93 #include_next <ldsodefs.h>
94
95 #endif