Coverage Report

Created: 2026-03-10 08:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/bfd/coff-riscv64.c
Line
Count
Source
1
/* BFD back-end for RISC-V 64-bit COFF files.
2
   Copyright (C) 2023-2026 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
#ifndef COFF_WITH_PE
22
#error non-PE COFF unsupported
23
#endif
24
25
#include "sysdep.h"
26
#include "bfd.h"
27
#include "libbfd.h"
28
#include "coff/riscv64.h"
29
#include "coff/internal.h"
30
#include "coff/pe.h"
31
#include "libcoff.h"
32
#include "libiberty.h"
33
34
108k
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER  2
35
36
#ifndef bfd_pe_print_pdata
37
#define bfd_pe_print_pdata      NULL
38
#endif
39
40
#define RTYPE2HOWTO(cache_ptr, dst)             \
41
0
  (cache_ptr)->howto = NULL
42
43
/* Return TRUE if this relocation should
44
   appear in the output .reloc section.  */
45
46
static bool
47
in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED,
48
      reloc_howto_type *howto)
49
0
{
50
0
  return !howto->pc_relative;
51
0
}
52
53
#include "coffcode.h"
54
55
/* Target vectors.  */
56
const bfd_target
57
#ifdef TARGET_SYM
58
  TARGET_SYM =
59
#else
60
  riscv64_coff_vec =
61
#endif
62
{
63
#ifdef TARGET_NAME
64
  TARGET_NAME,
65
#else
66
 "coff-riscv64-little",   /* Name.  */
67
#endif
68
  bfd_target_coff_flavour,
69
  BFD_ENDIAN_LITTLE,    /* Data byte order is little.  */
70
  BFD_ENDIAN_LITTLE,    /* Header byte order is little.  */
71
72
  (HAS_RELOC | EXEC_P   /* Object flags.  */
73
   | HAS_LINENO | HAS_DEBUG
74
   | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
75
76
  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags.  */
77
#if defined(COFF_WITH_PE)
78
   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
79
#endif
80
   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
81
82
#ifdef TARGET_UNDERSCORE
83
  TARGET_UNDERSCORE,    /* Leading underscore.  */
84
#else
85
  0,        /* Leading underscore.  */
86
#endif
87
  '/',        /* Ar_pad_char.  */
88
  15,       /* Ar_max_namelen.  */
89
  0,        /* match priority.  */
90
  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
91
  TARGET_MERGE_SECTIONS,
92
93
     /* Data conversion functions.  */
94
     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
95
     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
96
     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data.  */
97
     /* Header conversion functions.  */
98
     bfd_getl64, bfd_getl_signed_64, bfd_putl64,
99
     bfd_getl32, bfd_getl_signed_32, bfd_putl32,
100
     bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs.  */
101
102
  /* Note that we allow an object file to be treated as a core file as well.  */
103
  {       /* bfd_check_format.  */
104
    _bfd_dummy_target,
105
    coff_object_p,
106
    bfd_generic_archive_p,
107
    coff_object_p
108
  },
109
  {       /* bfd_set_format.  */
110
    _bfd_bool_bfd_false_error,
111
    coff_mkobject,
112
    _bfd_generic_mkarchive,
113
    _bfd_bool_bfd_false_error
114
  },
115
  {       /* bfd_write_contents.  */
116
    _bfd_bool_bfd_false_error,
117
    coff_write_object_contents,
118
    _bfd_write_archive_contents,
119
    _bfd_bool_bfd_false_error
120
  },
121
122
  BFD_JUMP_TABLE_GENERIC (coff),
123
  BFD_JUMP_TABLE_COPY (coff),
124
  BFD_JUMP_TABLE_CORE (_bfd_nocore),
125
  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
126
  BFD_JUMP_TABLE_SYMBOLS (coff),
127
  BFD_JUMP_TABLE_RELOCS (coff),
128
  BFD_JUMP_TABLE_WRITE (coff),
129
  BFD_JUMP_TABLE_LINK (coff),
130
  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
131
132
  NULL,
133
134
  COFF_SWAP_TABLE
135
};