This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][SPARC] Fix GNU_Sparc_HWCAPS and GNU_Sparc_HWCAPS2 tag values


On Wed, 2016-06-08 at 16:29 +0200, Jose E. Marchesi wrote:
> Hi people!  Just a little patch to make readelf -A to print a nice list
> of comma-separated hwcap names, instead of rubbish :)
> 
> 2016-06-08  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 tags values.

A simple testcase for inclusion into tests/run-readelf-A.sh would be
appreciated.

> diff --git a/backends/sparc_attrs.c b/backends/sparc_attrs.c
> index e95b577..505a01d 100644
> --- a/backends/sparc_attrs.c
> +++ b/backends/sparc_attrs.c
> @@ -41,33 +41,60 @@ 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[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"
> +    };
> +
> +  static const char *hwcaps2[11] =
> +    {
> +      "fjathplus", "vis3b", "adp", "sparc5", "mwait", "xmpmul",
> +      "xmont", "nsec", "fjathhpc", "fjdes", "fjaes"
> +    };
> +
> +  /* NAME must be large enough to contain up to N comma-separated list
> +     of atributes in the arrays defined above.  */
> +  static char name [30 * 16 + 30];
> +  name[0] = '\0';

This approach is not thread-safe. But if we keep the current interface
(which expects it can return a pointer to a non-mutable static string in
value_name) I don't see a good alternative. Given that it is only used
in readelf, which isn't multi-threaded, I think it is fine for now.

Given that you have made more than 10 commits now we probably should
give you commit access and appoint you sparc maintainer. Do you have a
FAS account? https://admin.fedoraproject.org/accounts

Thanks,

Mark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]