* v850-opc.c: Add notes about needing special insert/extract
[deliverable/binutils-gdb.git] / bfd / elf32-v850.c
CommitLineData
01b49cb3
C
1/* V850-specific support for 32-bit ELF
2 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#include "bfd.h"
21#include "sysdep.h"
22#include "libbfd.h"
23#include "elf-bfd.h"
24
25static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
26 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
27static void v850_info_to_howto_rel
28 PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
29
30
31/* Try to minimize the amount of space occupied by relocation tables
32 on the ROM (not that the ROM won't be swamped by other ELF overhead). */
33#define USE_REL
34
35enum reloc_type
36{
37 R_V850_NONE = 0,
38 R_V850_9_PCREL,
39 R_V850_22_PCREL,
40 R_V850_HI16_S,
41 R_V850_HI16,
42 R_V850_LO16,
43 R_V850_max
44};
45
46static reloc_howto_type elf_v850_howto_table[] =
47{
48 /* This reloc does nothing. */
49 HOWTO (R_V850_NONE, /* type */
50 0, /* rightshift */
51 2, /* size (0 = byte, 1 = short, 2 = long) */
52 32, /* bitsize */
53 false, /* pc_relative */
54 0, /* bitpos */
55 complain_overflow_bitfield, /* complain_on_overflow */
56 bfd_elf_generic_reloc, /* special_function */
57 "R_V850_NONE", /* name */
58 false, /* partial_inplace */
59 0, /* src_mask */
60 0, /* dst_mask */
61 false), /* pcrel_offset */
62
63 /* A PC relative 9 bit branch. */
64 HOWTO (R_V850_9_PCREL, /* type */
65 2, /* rightshift */
66 2, /* size (0 = byte, 1 = short, 2 = long) */
67 26, /* bitsize */
68 true, /* pc_relative */
69 0, /* bitpos */
70 complain_overflow_bitfield, /* complain_on_overflow */
71 bfd_elf_generic_reloc, /* special_function */
72 "R_V850_9_PCREL", /* name */
73 false, /* partial_inplace */
74 0x00ffffff, /* src_mask */
75 0x00ffffff, /* dst_mask */
76 true), /* pcrel_offset */
77
78 /* A PC relative 22 bit branch. */
79 HOWTO (R_V850_22_PCREL, /* type */
80 2, /* rightshift */
81 2, /* size (0 = byte, 1 = short, 2 = long) */
82 22, /* bitsize */
83 true, /* pc_relative */
84 7, /* bitpos */
85 complain_overflow_signed, /* complain_on_overflow */
86 bfd_elf_generic_reloc, /* special_function */
87 "R_V850_22_PCREL", /* name */
88 false, /* partial_inplace */
89 0x07ffff80, /* src_mask */
90 0x07ffff80, /* dst_mask */
91 true), /* pcrel_offset */
92
93 /* High 16 bits of symbol value. */
94 HOWTO (R_V850_HI16_S, /* type */
95 0, /* rightshift */
96 1, /* size (0 = byte, 1 = short, 2 = long) */
97 16, /* bitsize */
98 false, /* pc_relative */
99 16, /* bitpos */
100 complain_overflow_dont,/* complain_on_overflow */
101 bfd_elf_generic_reloc, /* special_function */
102 "R_V850_HI16_S", /* name */
103 true, /* partial_inplace */
104 0xffff, /* src_mask */
105 0xffff, /* dst_mask */
106 false), /* pcrel_offset */
107
108 /* High 16 bits of symbol value. */
109 HOWTO (R_V850_HI16, /* type */
110 0, /* rightshift */
111 1, /* size (0 = byte, 1 = short, 2 = long) */
112 16, /* bitsize */
113 false, /* pc_relative */
114 16, /* bitpos */
115 complain_overflow_dont,/* complain_on_overflow */
116 bfd_elf_generic_reloc, /* special_function */
117 "R_V850_HI16", /* name */
118 true, /* partial_inplace */
119 0xffff, /* src_mask */
120 0xffff, /* dst_mask */
121 false), /* pcrel_offset */
122
123 /* Low 16 bits of symbol value. */
124 HOWTO (R_V850_LO16, /* type */
125 0, /* rightshift */
126 1, /* size (0 = byte, 1 = short, 2 = long) */
127 16, /* bitsize */
128 false, /* pc_relative */
129 16, /* bitpos */
130 complain_overflow_dont,/* complain_on_overflow */
131 bfd_elf_generic_reloc, /* special_function */
132 "R_V850_LO16", /* name */
133 true, /* partial_inplace */
134 0xffff, /* src_mask */
135 0xffff, /* dst_mask */
136 false), /* pcrel_offset */
137};
138
139/* Map BFD reloc types to V850 ELF reloc types. */
140
141struct v850_reloc_map
142{
143 unsigned char bfd_reloc_val;
144 unsigned char elf_reloc_val;
145};
146
147static const struct v850_reloc_map v850_reloc_map[] =
148{
149 { BFD_RELOC_NONE, R_V850_NONE, },
150 { BFD_RELOC_V850_9_PCREL, R_V850_9_PCREL, },
151 { BFD_RELOC_V850_22_PCREL, R_V850_22_PCREL, },
152 { BFD_RELOC_HI16_S, R_V850_HI16_S, },
153 { BFD_RELOC_HI16, R_V850_HI16, },
154 { BFD_RELOC_LO16, R_V850_LO16, },
155};
156
157static reloc_howto_type *
158bfd_elf32_bfd_reloc_type_lookup (abfd, code)
159 bfd *abfd;
160 bfd_reloc_code_real_type code;
161{
162 unsigned int i;
163
164 for (i = 0;
165 i < sizeof (v850_reloc_map) / sizeof (struct v850_reloc_map);
166 i++)
167 {
168 if (v850_reloc_map[i].bfd_reloc_val == code)
169 return &elf_v850_howto_table[v850_reloc_map[i].elf_reloc_val];
170 }
171
172 return NULL;
173}
174
175/* Set the howto pointer for an V850 ELF reloc. */
176
177static void
178v850_info_to_howto_rel (abfd, cache_ptr, dst)
179 bfd *abfd;
180 arelent *cache_ptr;
181 Elf32_Internal_Rel *dst;
182{
183 unsigned int r_type;
184
185 r_type = ELF32_R_TYPE (dst->r_info);
186 BFD_ASSERT (r_type < (unsigned int) R_V850_max);
187 cache_ptr->howto = &elf_v850_howto_table[r_type];
188}
189
190#define TARGET_BIG_SYM bfd_elf32_v850_vec
191#define TARGET_BIG_NAME "elf32-v850"
192#define ELF_ARCH bfd_arch_v850
193#define ELF_MACHINE_CODE EM_CYGNUS_V850
194#define ELF_MAXPAGESIZE 0x1000
195
196#define elf_info_to_howto 0
197#define elf_info_to_howto_rel v850_info_to_howto_rel
198
199#include "elf32-target.h"
This page took 0.030394 seconds and 4 git commands to generate.