aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan S. Arnold <rsa@linux.vnet.ibm.com>2013-06-27 15:48:35 -0500
committerRyan S. Arnold <rsa@linux.vnet.ibm.com>2013-06-27 15:48:35 -0500
commit0cfec279fbb3c25b9c37e35e303ad4cdab77ed81 (patch)
treebd6898ac31cecffe9ea408e08113eb6e648ad9a9
parentfe114d206479a36369d732ea260e81a686fdbb0b (diff)
downloadglibc-rsa/hwcap2_v5.zip
glibc-rsa/hwcap2_v5.tar.gz
glibc-rsa/hwcap2_v5.tar.bz2
Add GLRO(dl_hwcap2), conditional on per platform HWCAP2_AVAIL.rsa/hwcap2_v5
-rw-r--r--ChangeLog31
-rw-r--r--elf/dl-support.c10
-rw-r--r--elf/dl-sysdep.c15
-rw-r--r--misc/getauxval.c6
-rw-r--r--ports/sysdeps/alpha/dl-procinfo.h2
-rw-r--r--ports/sysdeps/mips/dl-procinfo.h2
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h6
-rw-r--r--sysdeps/generic/dl-hwcap2.h25
-rw-r--r--sysdeps/generic/dl-procinfo.h2
-rw-r--r--sysdeps/generic/ldsodefs.h9
-rw-r--r--sysdeps/i386/dl-procinfo.h2
-rw-r--r--sysdeps/powerpc/dl-procinfo.h6
-rw-r--r--sysdeps/s390/dl-procinfo.h2
-rw-r--r--sysdeps/sparc/dl-procinfo.h6
-rw-r--r--sysdeps/unix/sysv/linux/i386/dl-procinfo.h6
-rw-r--r--sysdeps/unix/sysv/linux/s390/dl-procinfo.h6
16 files changed, 123 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 1012b2c..ff00d1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2013-06-27 Ryan S. Arnold <rsa@linux.vnet.ibm.com>
+
+ * elf/dl-support.c (_dl_hwcap2): Add a new hwcap field for more
+ hardware capabilities, conditional on HWCAP2_AVAIL.
+ (_dl_aux_init): Read AT_HWCAP2 into GLRO(dl_hwcap2), conditional on
+ HWCAP2_AVAIL.
+ * elf/dl-sysdep.c (_dl_sysdep_start): Read AT_HWCAP2 into
+ GLRO(dl_hwcap2), conditional on HWCAP2_AVAIL.
+ (_dl_show_auxv): Add support for calling _dl_procinfo when AT_HWCAP2
+ is encountered conditional on HWCAP2_AVAIL such that the default
+ mechanism is used otherwise.
+ * misc/getauxval.c (__getauxval): Return GLRO(dl_hwcap2) on AT_HWCAP2,
+ conditional on HWCAP2_AVAIL.
+ * sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_hwcap2 as a new
+ struct member, conditional on HWCAP2_AVAIL.
+ * sysdeps/generic/dl-hwcap2.h: New file defining HWCAP2_AVAIL as 0.
+ * ports/sysdeps/alpha/dl-procinfo.h (_dl_procinfo): Add TYPE parameter
+ to macro prototype for AT_HWCAP2 support.
+ * ports/sysdeps/mips/dl-procinfo.h: Likewise.
+ * sysdeps/generic/dl-procinfo.h: Likewise.
+ * sysdeps/i386/dl-procinfo.h: Likewise.
+ * sysdeps/s390/dl-procinfo.h: Likewise.
+ * ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_dl_procinfo): Add
+ TYPE parameter to macro prototype for AT_HWCAP2 support. Make WORD
+ unsigned long int rather than signed int. Stub in case for TYPE ==
+ AT_HWCAP2.
+ * sysdeps/powerpc/dl-procinfo.h: Likewise.
+ * sysdeps/sparc/dl-procinfo.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise.
+
2013-06-26 Joseph Myers <joseph@codesourcery.com>
* configure.in (CC): Require GCC version 4.4 or later.
diff --git a/elf/dl-support.c b/elf/dl-support.c
index b3ab956..94d35e9 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -31,6 +31,7 @@
#include <dl-cache.h>
#include <dl-librecon.h>
#include <dl-procinfo.h>
+#include <dl-hwcap2.h>
#include <unsecvars.h>
#include <hp-timing.h>
#include <stackinfo.h>
@@ -131,6 +132,10 @@ const ElfW(Phdr) *_dl_phdr;
size_t _dl_phnum;
uint64_t _dl_hwcap __attribute__ ((nocommon));
+#if HWCAP2_AVAIL
+uint64_t _dl_hwcap2 __attribute__ ((nocommon));
+#endif
+
/* This is not initialized to HWCAP_IMPORTANT, matching the definition
of _dl_important_hwcaps, below, where no hwcap strings are ever
used. This mask is still used to mediate the lookups in the cache
@@ -214,6 +219,11 @@ _dl_aux_init (ElfW(auxv_t) *av)
case AT_HWCAP:
GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
break;
+#if HWCAP2_AVAIL
+ case AT_HWCAP2:
+ GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
+ break;
+#endif
#ifdef NEED_DL_SYSINFO
case AT_SYSINFO:
GL(dl_sysinfo) = av->a_un.a_val;
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 52de23f..50d84a0 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -43,6 +43,7 @@
#include <dl-osinfo.h>
#include <hp-timing.h>
#include <tls.h>
+#include <dl-hwcap2.h>
extern char **_environ attribute_hidden;
extern char _end[] attribute_hidden;
@@ -156,6 +157,11 @@ _dl_sysdep_start (void **start_argptr,
case AT_HWCAP:
GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
break;
+#if HWCAP2_AVAIL
+ case AT_HWCAP2:
+ GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
+ break;
+#endif
case AT_CLKTCK:
GLRO(dl_clktck) = av->a_un.a_val;
break;
@@ -303,6 +309,7 @@ _dl_show_auxv (void)
[AT_SYSINFO - 2] = { "SYSINFO: 0x", hex },
[AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex },
[AT_RANDOM - 2] = { "RANDOM: 0x", hex },
+ [AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex },
};
unsigned int idx = (unsigned int) (av->a_type - 2);
@@ -314,10 +321,14 @@ _dl_show_auxv (void)
assert (AT_NULL == 0);
assert (AT_IGNORE == 1);
+#if HWCAP2_AVAIL
+ if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2)
+#else
if (av->a_type == AT_HWCAP)
+#endif
{
- /* This is handled special. */
- if (_dl_procinfo (av->a_un.a_val) == 0)
+ /* These are handled in a special way per platform. */
+ if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
continue;
}
diff --git a/misc/getauxval.c b/misc/getauxval.c
index 4321e37..81474ee 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -17,7 +17,7 @@
#include <sys/auxv.h>
#include <ldsodefs.h>
-
+#include <dl-hwcap2.h>
unsigned long int
__getauxval (unsigned long int type)
@@ -26,6 +26,10 @@ __getauxval (unsigned long int type)
if (type == AT_HWCAP)
return GLRO(dl_hwcap);
+#if HWCAP2_AVAIL
+ else if (type == AT_HWCAP2)
+ return GLRO(dl_hwcap2);
+#endif
for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
if (p->a_type == type)
diff --git a/ports/sysdeps/alpha/dl-procinfo.h b/ports/sysdeps/alpha/dl-procinfo.h
index 523d966..0344dbc 100644
--- a/ports/sysdeps/alpha/dl-procinfo.h
+++ b/ports/sysdeps/alpha/dl-procinfo.h
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
};
/* We cannot provide a general printing function. */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
/* There are no hardware capabilities defined. */
#define _dl_hwcap_string(idx) ""
diff --git a/ports/sysdeps/mips/dl-procinfo.h b/ports/sysdeps/mips/dl-procinfo.h
index 5cc9a44..e96550c 100644
--- a/ports/sysdeps/mips/dl-procinfo.h
+++ b/ports/sysdeps/mips/dl-procinfo.h
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
};
/* We cannot provide a general printing function. */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
/* There are no hardware capabilities defined. */
#define _dl_hwcap_string(idx) ""
diff --git a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
index 161e86c..132ca4f 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
+++ b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
@@ -31,10 +31,14 @@
static inline int
__attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
{
int i;
+ /* Handle in a more sophisticated manner if HWCAP2 is supported. */
+ if (type == AT_HWCAP2)
+ return 0;
+
_dl_printf ("AT_HWCAP: ");
for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/generic/dl-hwcap2.h b/sysdeps/generic/dl-hwcap2.h
new file mode 100644
index 0000000..cd6fdf9
--- /dev/null
+++ b/sysdeps/generic/dl-hwcap2.h
@@ -0,0 +1,25 @@
+/* HWCAP2 Availability Test
+ Copyright (C) 1998-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _HWCAP2_H
+#define _HWCAP2_H 1
+
+/* Default to unavailable. */
+#define HWCAP2_AVAIL (0)
+
+#endif /* dl-hwcap2.h */
diff --git a/sysdeps/generic/dl-procinfo.h b/sysdeps/generic/dl-procinfo.h
index 90c87d9..a184a59 100644
--- a/sysdeps/generic/dl-procinfo.h
+++ b/sysdeps/generic/dl-procinfo.h
@@ -21,7 +21,7 @@
#define _DL_PROCINFO_H 1
/* We cannot provide a general printing function. */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
/* There are no hardware capabilities defined. */
#define _dl_hwcap_string(idx) ""
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index cb17204..edb6efd 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -408,6 +408,7 @@ struct rtld_global
size_t count;
void *list[50];
} *_dl_scope_free_list;
+
#ifdef SHARED
};
# define __rtld_global_attribute__
@@ -554,6 +555,14 @@ struct rtld_global_ro
EXTERN struct link_map *_dl_sysinfo_map;
#endif
+#include <dl-hwcap2.h>
+
+#if HWCAP2_AVAIL
+ /* Mask for more hardware capabilities that are available on some
+ platforms. */
+ EXTERN uint64_t _dl_hwcap2;
+#endif
+
#ifdef SHARED
/* We add a function table to _rtld_global which is then used to
call the function instead of going through the PLT. The result
diff --git a/sysdeps/i386/dl-procinfo.h b/sysdeps/i386/dl-procinfo.h
index 883fa7f..233a325 100644
--- a/sysdeps/i386/dl-procinfo.h
+++ b/sysdeps/i386/dl-procinfo.h
@@ -61,7 +61,7 @@ enum
};
/* We cannot provide a general printing function. */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
static inline const char *
__attribute__ ((unused))
diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h
index 1c978ba..73cd279 100644
--- a/sysdeps/powerpc/dl-procinfo.h
+++ b/sysdeps/powerpc/dl-procinfo.h
@@ -159,8 +159,12 @@ _dl_string_platform (const char *str)
#ifdef IS_IN_rtld
static inline int
__attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
{
+ /* Handle in a more sophisticated manner if HWCAP2 is supported. */
+ if (type == AT_HWCAP2)
+ return 0;
+
_dl_printf ("AT_HWCAP: ");
for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h
index 717f6f9..45e27f1 100644
--- a/sysdeps/s390/dl-procinfo.h
+++ b/sysdeps/s390/dl-procinfo.h
@@ -56,7 +56,7 @@ enum
| HWCAP_S390_EIMM | HWCAP_S390_DFP)
/* We cannot provide a general printing function. */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
static inline const char *
__attribute__ ((unused))
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index a18b099..35065c4 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -27,10 +27,14 @@
static inline int
__attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
{
int i;
+ /* Handle in a more sophisticated manner if HWCAP2 is supported. */
+ if (type == AT_HWCAP2)
+ return 0;
+
_dl_printf ("AT_HWCAP: ");
for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
index a82f8f5..17d87ab 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
@@ -24,12 +24,16 @@
#undef _dl_procinfo
static inline int
__attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
{
/* This table should match the information from arch/i386/kernel/setup.c
in the kernel sources. */
int i;
+ /* Handle in a more sophisticated manner if HWCAP2 is supported. */
+ if (type == AT_HWCAP2)
+ return 0;
+
_dl_printf ("AT_HWCAP: ");
for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
index 5ca4b76..f4a36e0 100644
--- a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
@@ -24,12 +24,16 @@
#undef _dl_procinfo
static inline int
__attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
{
/* This table should match the information from arch/s390/kernel/setup.c
in the kernel sources. */
int i;
+ /* Handle in a more sophisticated manner if HWCAP2 is supported. */
+ if (type == AT_HWCAP2)
+ return 0;
+
_dl_printf ("AT_HWCAP: ");
for (i = 0; i < _DL_HWCAP_COUNT; ++i)