Coverage Report

Created: 2025-07-11 06:46

/src/elfutils/backends/arm_symbol.c
Line
Count
Source (jump to first uncovered line)
1
/* Arm specific symbolic name handling.
2
   Copyright (C) 2002-2009, 2014, 2015, 2017 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 <system.h>
34
35
#include <elf.h>
36
#include <stddef.h>
37
#include <string.h>
38
39
#define BACKEND   arm_
40
#include "libebl_CPU.h"
41
42
43
const char *
44
arm_segment_type_name (int segment, char *buf __attribute__ ((unused)),
45
           size_t len __attribute__ ((unused)))
46
0
{
47
0
  switch (segment)
48
0
    {
49
0
    case PT_ARM_EXIDX:
50
0
      return "ARM_EXIDX";
51
0
    }
52
0
  return NULL;
53
0
}
54
55
/* Return symbolic representation of section type.  */
56
const char *
57
arm_section_type_name (int type,
58
           char *buf __attribute__ ((unused)),
59
           size_t len __attribute__ ((unused)))
60
0
{
61
0
  switch (type)
62
0
    {
63
0
    case SHT_ARM_EXIDX:
64
0
      return "ARM_EXIDX";
65
0
    case SHT_ARM_PREEMPTMAP:
66
0
      return "ARM_PREEMPTMAP";
67
0
    case SHT_ARM_ATTRIBUTES:
68
0
      return "ARM_ATTRIBUTES";
69
0
    }
70
71
0
  return NULL;
72
0
}
73
74
/* Check whether machine flags are valid.  */
75
bool
76
arm_machine_flag_check (GElf_Word flags)
77
0
{
78
0
  switch (flags & EF_ARM_EABIMASK)
79
0
    {
80
0
    case EF_ARM_EABI_UNKNOWN:
81
0
    case EF_ARM_EABI_VER1:
82
0
    case EF_ARM_EABI_VER2:
83
0
    case EF_ARM_EABI_VER3:
84
0
    case EF_ARM_EABI_VER4:
85
0
    case EF_ARM_EABI_VER5:
86
0
      break;
87
0
    default:
88
0
      return false;
89
0
    }
90
91
0
  return ((flags &~ (EF_ARM_EABIMASK
92
0
         | EF_ARM_RELEXEC
93
0
         | EF_ARM_HASENTRY
94
0
         | EF_ARM_INTERWORK
95
0
         | EF_ARM_APCS_26
96
0
         | EF_ARM_APCS_FLOAT
97
0
         | EF_ARM_PIC
98
0
         | EF_ARM_ALIGN8
99
0
         | EF_ARM_NEW_ABI
100
0
         | EF_ARM_OLD_ABI
101
0
         | EF_ARM_SOFT_FLOAT
102
0
         | EF_ARM_VFP_FLOAT
103
0
         | EF_ARM_MAVERICK_FLOAT
104
0
         | EF_ARM_SYMSARESORTED
105
0
         | EF_ARM_DYNSYMSUSESEGIDX
106
0
         | EF_ARM_MAPSYMSFIRST
107
0
         | EF_ARM_EABIMASK
108
0
         | EF_ARM_BE8
109
0
         | EF_ARM_LE8)) == 0);
110
0
}
111
112
/* Check for the simple reloc types.  */
113
Elf_Type
114
arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
115
           int *addsub __attribute__ ((unused)))
116
0
{
117
0
  switch (type)
118
0
    {
119
0
    case R_ARM_ABS32:
120
0
      return ELF_T_WORD;
121
0
    case R_ARM_ABS16:
122
0
      return ELF_T_HALF;
123
0
    case R_ARM_ABS8:
124
0
      return ELF_T_BYTE;
125
0
    default:
126
0
      return ELF_T_NUM;
127
0
    }
128
0
}
129
130
/* The SHT_ARM_EXIDX section type is a valid target for relocation.  */
131
bool
132
arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
133
0
{
134
0
  return sh_type == SHT_ARM_EXIDX;
135
0
}
136
137
const char *
138
arm_symbol_type_name (int type,
139
          char *buf __attribute__ ((unused)),
140
          size_t len __attribute__ ((unused)))
141
0
{
142
0
  switch (type)
143
0
    {
144
0
    case STT_ARM_TFUNC:
145
0
      return "ARM_TFUNC";
146
0
    }
147
0
  return NULL;
148
0
}
149
150
/* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name,
151
 *    STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a
152
 *       sequence of data items.  */
153
bool
154
arm_data_marker_symbol (const GElf_Sym *sym, const char *sname)
155
0
{
156
0
  return (sym != NULL && sname != NULL
157
0
          && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL
158
0
          && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE
159
0
          && (strcmp (sname, "$d") == 0 || startswith (sname, "$d.")));
160
0
}