Coverage Report

Created: 2025-08-29 06:11

/src/elfutils/backends/arm_regs.c
Line
Count
Source (jump to first uncovered line)
1
/* Register names and numbers for ARM DWARF.
2
   Copyright (C) 2009 Red Hat, 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 arm_
37
#include "libebl_CPU.h"
38
39
ssize_t
40
arm_register_info (Ebl *ebl __attribute__ ((unused)),
41
       int regno, char *name, size_t namelen,
42
       const char **prefix, const char **setname,
43
       int *bits, int *type)
44
0
{
45
0
  if (name == NULL)
46
0
    return 320;
47
48
0
  if (regno < 0 || regno > 320 || namelen < 5)
49
0
    return -1;
50
51
0
  *prefix = "";
52
0
  *bits = 32;
53
0
  *type = DW_ATE_signed;
54
0
  *setname = "integer";
55
56
0
  switch (regno)
57
0
    {
58
0
    case 0 ... 9:
59
0
      name[0] = 'r';
60
0
      name[1] = regno + '0';
61
0
      namelen = 2;
62
0
      break;
63
64
0
    case 10 ... 12:
65
0
      name[0] = 'r';
66
0
      name[1] = '1';
67
0
      name[2] = regno % 10 + '0';
68
0
      namelen = 3;
69
0
      break;
70
71
0
    case 13 ... 15:
72
0
      *type = DW_ATE_address;
73
0
      name[0] = "slp"[regno - 13];
74
0
      name[1] = "prc"[regno - 13];
75
0
      namelen = 2;
76
0
      break;
77
78
0
    case 16 + 0 ... 16 + 7:
79
0
      regno += 96 - 16;
80
0
      FALLTHROUGH;
81
0
    case 96 + 0 ... 96 + 7:
82
0
      *setname = "FPA";
83
0
      *type = DW_ATE_float;
84
0
      *bits = 96;
85
0
      name[0] = 'f';
86
0
      name[1] = regno - 96 + '0';
87
0
      namelen = 2;
88
0
      break;
89
90
0
    case 128:
91
0
      *type = DW_ATE_unsigned;
92
0
      return stpcpy (name, "spsr") + 1 - name;
93
94
0
    case 256 + 0 ... 256 + 9:
95
0
      *setname = "VFP";
96
0
      *type = DW_ATE_float;
97
0
      *bits = 64;
98
0
      name[0] = 'd';
99
0
      name[1] = regno - 256 + '0';
100
0
      namelen = 2;
101
0
      break;
102
103
0
    case 256 + 10 ... 256 + 31:
104
0
      *setname = "VFP";
105
0
      *type = DW_ATE_float;
106
0
      *bits = 64;
107
0
      name[0] = 'd';
108
0
      name[1] = (regno - 256) / 10 + '0';
109
0
      name[2] = (regno - 256) % 10 + '0';
110
0
      namelen = 3;
111
0
      break;
112
113
0
    default:
114
0
      *setname = NULL;
115
0
      return 0;
116
0
    }
117
118
0
  name[namelen++] = '\0';
119
0
  return namelen;
120
0
}