summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2016-08-24 06:47:57 -0700
committerJose E. Marchesi <jose.marchesi@oracle.com>2016-08-24 06:47:57 -0700
commitb944b65f55869d47f986f035211e088ee0d2a7b7 (patch)
tree090301c51452c56a685dec092e78704e708af120
parentb584da5ae7259d4923eb3f993de87cf55bef71b8 (diff)
downloadelfutils-b944b65f55869d47f986f035211e088ee0d2a7b7.tar.gz
sparc: fix the printing of hw capabilities object attributes.
The GNU_Sparc_HWCAPS and GNU_Sparc_HWCAPS2 object attributes comprise a set of hardware capabilities that may (or not) be present in the target machine for which the object was compiled. This patch adds the support for printing a nicely formatted comma-separated list with the selected hw capabilities. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
-rw-r--r--backends/ChangeLog7
-rw-r--r--backends/sparc_attrs.c74
-rw-r--r--tests/ChangeLog5
-rwxr-xr-xtests/run-readelf-A.sh19
-rw-r--r--tests/testfilesparc64attrs.o.bz2bin0 -> 242 bytes
5 files changed, 81 insertions, 24 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index af32d8f9..53d29081 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-09 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * sparc_attrs.c (sparc_check_object_attribute): Fix the
+ calculation of GNU_SParc_HWCAPS and GNU_SParc_HWCAPS2 values as
+ comma-separated list of hw capability names.
+
2016-07-10 Andreas Schwab <schwab@linux-m68k.org>
* m68k_corenote.c (ALIGN_PRSTATUS): Define.
@@ -13,7 +19,6 @@
* common-reloc.c (copy_reloc_p): Honor NO_COPY_RELOC.
(init_reloc): Likewise.
-
2016-05-20 Andreas Schwab <schwab@linux-m68k.org>
* Makefile.am (modules): Add m68k.
diff --git a/backends/sparc_attrs.c b/backends/sparc_attrs.c
index e95b577b..974e8fb0 100644
--- a/backends/sparc_attrs.c
+++ b/backends/sparc_attrs.c
@@ -41,33 +41,63 @@ sparc_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
const char *vendor, int tag, uint64_t value,
const char **tag_name, const char **value_name)
{
+ static const char *hwcaps[32] =
+ {
+ "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
+ "asi_blk_init", "fmaf", "vis3", "hpc", "random", "trans",
+ "fjfmau", "ima", "asi_cache_sparing", "aes", "des", "kasumi",
+ "camellia", "md5", "sha1", "sha256", "sha512", "mpmul", "mont",
+ "pause", "cbcond", "crc32c", "resv30", "resv31"
+ };
+
+
+ static const char *hwcaps2[32] =
+ {
+ "fjathplus", "vis3b", "adp", "sparc5", "mwait", "xmpmul", "xmont",
+ "nsec", "resv8", "resv9" , "resv10", "resv11", "fjathhpc", "fjdes",
+ "fjaes", "resv15", "resv16", "resv17", "resv18", "resv19", "resv20",
+ "resv21", "resv22", "resv23", "resv24", "resv25", "resv26", "resv27",
+ "resv28", "resv29", "resv30", "resv31",
+ };
+
+ /* NAME should be big enough to hold any possible comma-separated
+ list (no repetitions allowed) of attribute names from one of the
+ arrays above. */
+ static char name[32*17+32+1];
+ name[0] = '\0';
+
if (!strcmp (vendor, "gnu"))
switch (tag)
{
case 4:
- *tag_name = "GNU_Sparc_HWCAPS";
- static const char *hwcaps[30] =
- {
- "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
- "asi_blk_init", "fmaf", NULL, "vis3", "hpc", "random", "trans", "fjfmau",
- "ima", "asi_cache_sparing", "aes", "des", "kasumi", "camellia",
- "md5", "sha1", "sha256", "sha512", "mpmul", "mont", "pause",
- "cbcond", "crc32c"
- };
- if (value < 30 && hwcaps[value] != NULL)
- *value_name = hwcaps[value];
- return true;
-
case 8:
- *tag_name = "GNU_Sparc_HWCAPS2";
- static const char *hwcaps2[11] =
- {
- "fjathplus", "vis3b", "adp", "sparc5", "mwait", "xmpmul",
- "xmont", "nsec", "fjathhpc", "fjdes", "fjaes"
- };
- if (value < 11)
- *value_name = hwcaps2[value];
- return true;
+ {
+ const char **caps;
+ int cap;
+
+ if (tag == 4)
+ {
+ *tag_name = "GNU_Sparc_HWCAPS";
+ caps = hwcaps;
+ }
+ else
+ {
+ *tag_name = "GNU_Sparc_HWCAPS2";
+ caps = hwcaps2;
+ }
+
+ char *s = name;
+ for (cap = 0; cap < 32; cap++)
+ if (value & (1U << cap))
+ {
+ if (*s != '\0')
+ s = strcat (s, ",");
+ s = strcat (s, caps[cap]);
+ }
+
+ *value_name = s;
+ return true;
+ }
}
return false;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index f21a0b79..98a31ddd 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-09 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * testfilesparc64attrs.o.bz2: New file.
+ * run-readelf-A.sh: Check attributes in a sparc object.
+
2016-08-06 Mark Wielaard <mjw@redhat.com>
* run-strip-reloc.sh: Add explicit compressed and uncompressed
diff --git a/tests/run-readelf-A.sh b/tests/run-readelf-A.sh
index 6ca9be89..03d511c9 100755
--- a/tests/run-readelf-A.sh
+++ b/tests/run-readelf-A.sh
@@ -1,5 +1,6 @@
#! /bin/sh
# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2016 Oracle, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
@@ -25,7 +26,13 @@
#
# gcc -m32 -c testfileppc32attrs.s
-testfiles testfilearm testfileppc32attrs.o
+# = testfilesparc64attrs.s =
+# .gnu_attribute 4,0x0aaaaaaa
+# .gnu_attribute 8,0x00000055
+#
+# gcc -c testfilesparc64attrs.s
+
+testfiles testfilearm testfileppc32attrs.o testfilesparc64attrs.o
testrun_compare ${abs_top_builddir}/src/readelf -A testfilearm <<\EOF
@@ -62,4 +69,14 @@ Object attributes section [ 4] '.gnu.attributes' of 18 bytes at offset 0x34:
GNU_Power_ABI_Struct_Return: r3/r4
EOF
+testrun_compare ${abs_top_builddir}/src/readelf -A testfilesparc64attrs.o <<\EOF
+
+Object attributes section [ 4] '.gnu.attributes' of 21 bytes at offset 0x40:
+ Owner Size
+ gnu 20
+ File: 12
+ GNU_Sparc_HWCAPS: div32,v8plus,vis,asi_blk_init,vis3,random,fjfmau,asi_cache_sparing,des,camellia,sha1,sha512,mont,cbcond
+ GNU_Sparc_HWCAPS2: fjathplus,adp,mwait,xmont
+EOF
+
exit 0
diff --git a/tests/testfilesparc64attrs.o.bz2 b/tests/testfilesparc64attrs.o.bz2
new file mode 100644
index 00000000..7be7f88d
--- /dev/null
+++ b/tests/testfilesparc64attrs.o.bz2
Binary files differ