Coverage Report

Created: 2025-10-10 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/elfutils/backends/sparc_attrs.c
Line
Count
Source
1
/* Object attribute tags for SPARC.
2
   Copyright (C) 2015 Oracle, Inc.
3
   This file is part of elfutils.
4
5
   This file is free software; you can redistribute it and/or modify
6
   it under the terms of either
7
8
     * the GNU Lesser General Public License as published by the Free
9
       Software Foundation; either version 3 of the License, or (at
10
       your option) any later version
11
12
   or
13
14
     * the GNU General Public License as published by the Free
15
       Software Foundation; either version 2 of the License, or (at
16
       your option) any later version
17
18
   or both in parallel, as here.
19
20
   elfutils is distributed in the hope that it will be useful, but
21
   WITHOUT ANY WARRANTY; without even the implied warranty of
22
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
   General Public License for more details.
24
25
   You should have received copies of the GNU General Public License and
26
   the GNU Lesser General Public License along with this program.  If
27
   not, see <http://www.gnu.org/licenses/>.  */
28
29
#ifdef HAVE_CONFIG_H
30
# include <config.h>
31
#endif
32
33
#include <string.h>
34
#include <dwarf.h>
35
36
#define BACKEND sparc_
37
#include "libebl_CPU.h"
38
39
bool
40
sparc_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
41
            const char *vendor, int tag, uint64_t value,
42
            const char **tag_name, const char **value_name)
43
0
{
44
0
  static const char *hwcaps[32] =
45
0
    {
46
0
      "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
47
0
      "asi_blk_init", "fmaf", "vis3", "hpc", "random", "trans",
48
0
      "fjfmau", "ima", "asi_cache_sparing", "aes", "des", "kasumi",
49
0
      "camellia", "md5", "sha1", "sha256", "sha512", "mpmul", "mont",
50
0
      "pause", "cbcond", "crc32c", "resv30", "resv31"
51
0
    };
52
53
  
54
0
  static const char *hwcaps2[32] =
55
0
    {
56
0
      "fjathplus", "vis3b", "adp", "sparc5", "mwait", "xmpmul", "xmont",
57
0
      "nsec", "resv8", "resv9" , "resv10", "resv11", "fjathhpc", "fjdes",
58
0
      "fjaes", "resv15", "resv16", "resv17", "resv18", "resv19", "resv20",
59
0
      "resv21", "resv22", "resv23", "resv24", "resv25", "resv26", "resv27",
60
0
      "resv28", "resv29", "resv30", "resv31",
61
0
    };
62
63
  /* NAME should be big enough to hold any possible comma-separated
64
     list (no repetitions allowed) of attribute names from one of the
65
     arrays above.  */
66
0
  static char name[32*17+32+1];
67
0
  name[0] = '\0';
68
69
0
  if (!strcmp (vendor, "gnu"))
70
0
    switch (tag)
71
0
      {
72
0
      case 4:
73
0
      case 8:
74
0
        {
75
0
          const char **caps;
76
0
          int cap;
77
          
78
0
          if (tag == 4)
79
0
            {
80
0
              *tag_name = "GNU_Sparc_HWCAPS";
81
0
              caps = hwcaps;
82
0
            }
83
0
          else
84
0
            {
85
0
              *tag_name = "GNU_Sparc_HWCAPS2";
86
0
              caps = hwcaps2;
87
0
            }
88
          
89
0
          char *s = name;
90
0
          for (cap = 0; cap < 32; cap++)
91
0
            if (value & (1U << cap))
92
0
              {
93
0
                if (*s != '\0')
94
0
                  s = strcat (s, ",");
95
0
                s = strcat (s, caps[cap]);
96
0
              }
97
          
98
0
          *value_name = s;
99
0
          return true;
100
0
        }
101
0
      }
102
103
0
  return false;
104
0
}
105