Coverage Report

Created: 2025-06-24 06:45

/src/binutils-gdb/bfd/coff-riscv64.c
Line
Count
Source (jump to first uncovered line)
1
/* BFD back-end for RISC-V 64-bit COFF files.
2
   Copyright (C) 2023-2025 Free Software Foundation, Inc.
3
4
   This file is part of BFD, the Binary File Descriptor library.
5
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
   MA 02110-1301, USA.  */
20
21
#include "sysdep.h"
22
#include "bfd.h"
23
#include "libbfd.h"
24
#include "coff/riscv64.h"
25
#include "coff/internal.h"
26
#include "coff/pe.h"
27
#include "libcoff.h"
28
#include "libiberty.h"
29
30
618k
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER  2
31
32
#ifndef bfd_pe_print_pdata
33
#define bfd_pe_print_pdata      NULL
34
#endif
35
36
#define RTYPE2HOWTO(cache_ptr, dst)             \
37
0
  (cache_ptr)->howto = NULL
38
39
/* Return TRUE if this relocation should
40
   appear in the output .reloc section.  */
41
42
static bool
43
in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED,
44
      reloc_howto_type *howto)
45
0
{
46
0
  return !howto->pc_relative;
47
0
}
48
49
#include "coffcode.h"
50
51
/* Target vectors.  */
52
const bfd_target
53
#ifdef TARGET_SYM
54
  TARGET_SYM =
55
#else
56
  riscv64_coff_vec =
57
#endif
58
{
59
#ifdef TARGET_NAME
60
  TARGET_NAME,
61
#else
62
 "coff-riscv64-little",   /* Name.  */
63
#endif
64
  bfd_target_coff_flavour,
65
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */
66
  BFD_ENDIAN_LITTLE,    /* Header byte order is little.  */
67
68
  (HAS_RELOC | EXEC_P   /* Object flags.  */
69
   | HAS_LINENO | HAS_DEBUG
70
   | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
71
72
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags.  */
73
#if defined(COFF_WITH_PE)
74
   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
75
#endif
76
   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
77
78
#ifdef TARGET_UNDERSCORE
79
  TARGET_UNDERSCORE,    /* Leading underscore.  */
80
#else
81
  0,        /* Leading underscore.  */
82
#endif
83
  '/',        /* Ar_pad_char.  */
84
  15,       /* Ar_max_namelen.  */
85
  0,        /* match priority.  */
86
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
87
88
     /* Data conversion functions.  */
89
     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
90
     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
91
     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data.  */
92
     /* Header conversion functions.  */
93
     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
94
     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
95
     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs.  */
96
97
  /* Note that we allow an object file to be treated as a core file as well.  */
98
  {       /* bfd_check_format.  */
99
    _bfd_dummy_target,
100
    coff_object_p,
101
    bfd_generic_archive_p,
102
    coff_object_p
103
  },
104
  {       /* bfd_set_format.  */
105
    _bfd_bool_bfd_false_error,
106
    coff_mkobject,
107
    _bfd_generic_mkarchive,
108
    _bfd_bool_bfd_false_error
109
  },
110
  {       /* bfd_write_contents.  */
111
    _bfd_bool_bfd_false_error,
112
    coff_write_object_contents,
113
    _bfd_write_archive_contents,
114
    _bfd_bool_bfd_false_error
115
  },
116
117
  BFD_JUMP_TABLE_GENERIC (coff),
118
  BFD_JUMP_TABLE_COPY (coff),
119
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
120
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
121
  BFD_JUMP_TABLE_SYMBOLS (coff),
122
  BFD_JUMP_TABLE_RELOCS (coff),
123
  BFD_JUMP_TABLE_WRITE (coff),
124
  BFD_JUMP_TABLE_LINK (coff),
125
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
126
127
  NULL,
128
129
  COFF_SWAP_TABLE
130
};