Coverage Report

Created: 2025-06-24 06:45

/src/binutils-gdb/bfd/cpu-kvx.c
Line
Count
Source (jump to first uncovered line)
1
/* BFD support for KVX.
2
   Copyright (C) 2009-2025 Free Software Foundation, Inc.
3
   Contributed by Kalray SA.
4
5
   This file is part of BFD, the Binary File Descriptor library.
6
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; see the file COPYING3. If not,
19
   see <http://www.gnu.org/licenses/>.  */
20
21
#include "sysdep.h"
22
#include "bfd.h"
23
#include "libbfd.h"
24
25
/* This routine is provided two arch_infos and returns if machines
26
   are compatible.
27
*/
28
29
static const bfd_arch_info_type *
30
kvx_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
31
0
{
32
0
  long amach =  a->mach, bmach =  b->mach;
33
  /* If a & b are for different architecture we can do nothing.  */
34
0
  if (a->arch != b->arch)
35
0
    return NULL;
36
37
0
  if ((amach == bfd_mach_kv3_1_64 && bmach == bfd_mach_kv3_1_usr)
38
0
      || (amach == bfd_mach_kv3_2_64 && bmach == bfd_mach_kv3_2_usr))
39
0
    return b;
40
41
0
  if ((bmach == bfd_mach_kv3_1_64 && amach == bfd_mach_kv3_1_usr)
42
0
      || (bmach == bfd_mach_kv3_2_64 && amach == bfd_mach_kv3_2_usr))
43
0
    return a;
44
45
  /* Otherwise if either a or b is the 'default' machine
46
   * then it can be polymorphed into the other.
47
   * This will enable to execute merge_private_bfd_data
48
   */
49
0
  if (a->the_default)
50
0
    return b;
51
52
0
  if (b->the_default)
53
0
    return a;
54
55
  /* We do not want to transmute some machine into another one */
56
0
  if (amach != bmach)
57
0
    return NULL;
58
59
  /* If a & b are for the same machine then all is well.  */
60
0
  if (amach == bmach)
61
0
    return a;
62
63
0
  return NULL;
64
0
}
65
66
static bool
67
scan (const struct bfd_arch_info *info, const char *string)
68
0
{
69
  /* First test for an exact match.  */
70
0
  if (strcasecmp (string, info->printable_name) == 0)
71
0
    return true;
72
73
  /* Finally check for the default architecture.  */
74
0
  if (strcasecmp (string, "kvx") == 0)
75
0
    return info->the_default;
76
77
0
  return false;
78
0
}
79
80
#define N(addr_bits, machine, print, default, next)            \
81
{                                                              \
82
  32,                          /* 32 bits in a word.  */       \
83
  addr_bits,                   /* bits in an address.  */      \
84
  8,                           /* 8 bits in a byte.  */        \
85
  bfd_arch_kvx,                                                 \
86
  machine,                     /* Machine number.  */          \
87
  "kvx",                        /* Architecture name.   */      \
88
  print,                       /* Printable name.  */          \
89
  4,                           /* Section align power.  */     \
90
  default,                     /* Is this the default ?  */    \
91
  kvx_compatible,                \
92
  scan,                                                        \
93
  bfd_arch_default_fill,                                       \
94
  next,                                                \
95
          0                                            \
96
}
97
98
99
const bfd_arch_info_type bfd_kv4_1_usr_arch =
100
  N (64 , bfd_mach_kv4_1_usr , "kvx:kv4-1:usr" , false , NULL);
101
102
const bfd_arch_info_type bfd_kv3_2_usr_arch =
103
  N (64 , bfd_mach_kv3_2_usr , "kvx:kv3-2:usr" , false , &bfd_kv4_1_usr_arch);
104
105
const bfd_arch_info_type bfd_kv3_1_usr_arch =
106
  N (64 , bfd_mach_kv3_1_usr , "kvx:kv3-1:usr" , false , &bfd_kv3_2_usr_arch);
107
108
const bfd_arch_info_type bfd_kv4_1_64_arch =
109
  N (64 , bfd_mach_kv4_1_64  , "kvx:kv4-1:64"  , false , &bfd_kv3_1_usr_arch);
110
111
const bfd_arch_info_type bfd_kv3_2_64_arch =
112
  N (64 , bfd_mach_kv3_2_64  , "kvx:kv3-2:64"  , false , &bfd_kv4_1_64_arch);
113
114
const bfd_arch_info_type bfd_kv3_1_64_arch =
115
  N (64 , bfd_mach_kv3_1_64  , "kvx:kv3-1:64"  , false , &bfd_kv3_2_64_arch);
116
117
const bfd_arch_info_type bfd_kv4_1_arch =
118
  N (32 , bfd_mach_kv4_1     , "kvx:kv4-1"     , false , &bfd_kv3_1_64_arch);
119
120
const bfd_arch_info_type bfd_kv3_2_arch =
121
  N (32 , bfd_mach_kv3_2     , "kvx:kv3-2"     , false , &bfd_kv4_1_arch);
122
123
const bfd_arch_info_type bfd_kvx_arch =
124
  N (32 , bfd_mach_kv3_1     , "kvx:kv3-1"     , true  , &bfd_kv3_2_arch);