Set no file contents PT_LOAD p_offset to first page
[deliverable/binutils-gdb.git] / bfd / cpu-riscv.c
CommitLineData
e23eba97 1/* BFD backend for RISC-V
82704155 2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
e23eba97
NC
3
4 Contributed by Andrew Waterman (andrew@sifive.com).
5 Based on MIPS target.
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING3. If not,
21 see <http://www.gnu.org/licenses/>. */
22
23#include "sysdep.h"
24#include "bfd.h"
25#include "libbfd.h"
26
27/* This routine is provided two arch_infos and returns an arch_info
28 that is compatible with both, or NULL if none exists. */
29
30static const bfd_arch_info_type *
31riscv_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
32{
33 if (a->arch != b->arch)
34 return NULL;
35
36 /* Machine compatibility is checked in
37 _bfd_riscv_elf_merge_private_bfd_data. */
38
39 return a;
40}
41
aebcfb76 42#define N(BITS, NUMBER, PRINT, DEFAULT, NEXT) \
e23eba97 43 { \
aebcfb76
NC
44 BITS, /* Bits in a word. */ \
45 BITS, /* Bits in an address. */ \
46 8, /* Bits in a byte. */ \
e23eba97
NC
47 bfd_arch_riscv, \
48 NUMBER, \
49 "riscv", \
50 PRINT, \
51 3, \
52 DEFAULT, \
53 riscv_compatible, \
54 bfd_default_scan, \
55 bfd_arch_default_fill, \
56 NEXT, \
aebcfb76 57 0 /* Maximum offset of a reloc from the start of an insn. */\
e23eba97
NC
58 }
59
60/* This enum must be kept in the same order as arch_info_struct. */
61enum
62{
63 I_riscv64,
64 I_riscv32
65};
66
67#define NN(index) (&arch_info_struct[(index) + 1])
68
69/* This array must be kept in the same order as the anonymous enum above,
70 and each entry except the last should end with NN (my enum value). */
71static const bfd_arch_info_type arch_info_struct[] =
72{
aebcfb76
NC
73 N (64, bfd_mach_riscv64, "riscv:rv64", FALSE, NN (I_riscv64)),
74 N (32, bfd_mach_riscv32, "riscv:rv32", FALSE, NULL)
e23eba97
NC
75};
76
77/* The default architecture is riscv:rv64. */
78
79const bfd_arch_info_type bfd_riscv_arch =
aebcfb76 80 N (64, 0, "riscv", TRUE, &arch_info_struct[0]);
This page took 0.196749 seconds and 4 git commands to generate.