1 |
1617 |
phoenix |
/* OR32-specific support for 32-bit ELF
|
2 |
|
|
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
Contributed by Ivan Guzvinec <ivang@opencores.org>
|
5 |
|
|
Modified by Gyorgy Jeney <nog@sdf.lonestar.org>
|
6 |
|
|
Balint Cristian <rezso@rdsor.ro>
|
7 |
|
|
|
8 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
9 |
|
|
|
10 |
|
|
This program is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
This program is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with this program; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
23 |
|
|
|
24 |
|
|
#include "bfd.h"
|
25 |
|
|
#include "sysdep.h"
|
26 |
|
|
#include "libbfd.h"
|
27 |
|
|
#include "elf-bfd.h"
|
28 |
|
|
#include "elf/or32.h"
|
29 |
|
|
#include "elf/common.h"
|
30 |
|
|
#include "libiberty.h"
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
|
34 |
|
|
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
35 |
|
|
static void or32_info_to_howto_rel
|
36 |
|
|
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
37 |
|
|
static bfd_boolean or32_elf_object_p
|
38 |
|
|
PARAMS ((bfd *));
|
39 |
|
|
static void or32_elf_final_write_processing
|
40 |
|
|
PARAMS ((bfd *, bfd_boolean));
|
41 |
|
|
static bfd_reloc_status_type or32_elf_const_reloc
|
42 |
|
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
43 |
|
|
static bfd_reloc_status_type or32_elf_consth_reloc
|
44 |
|
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
45 |
|
|
static bfd_reloc_status_type _bfd_or32_elf_generic_reloc
|
46 |
|
|
PARAMS ((bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **));
|
47 |
|
|
|
48 |
|
|
#define ELF_R_SYM(i) (ELF32_R_SYM (i))
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
/* Try to minimize the amount of space occupied by relocation tables
|
52 |
|
|
on the ROM (not that the ROM won't be swamped by other ELF overhead). */
|
53 |
|
|
#define USE_REL 1
|
54 |
|
|
|
55 |
|
|
static reloc_howto_type elf_or32_howto_table[] =
|
56 |
|
|
{
|
57 |
|
|
/* This reloc does nothing. */
|
58 |
|
|
HOWTO (R_OR32_NONE, /* type */
|
59 |
|
|
0, /* rightshift */
|
60 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
61 |
|
|
32, /* bitsize */
|
62 |
|
|
FALSE, /* pc_relative */
|
63 |
|
|
0, /* bitpos */
|
64 |
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
65 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
66 |
|
|
"R_OR32_NONE", /* name */
|
67 |
|
|
FALSE, /* partial_inplace */
|
68 |
|
|
0, /* src_mask */
|
69 |
|
|
0, /* dst_mask */
|
70 |
|
|
FALSE), /* pcrel_offset */
|
71 |
|
|
|
72 |
|
|
/* A standard 32 bit relocation. */
|
73 |
|
|
HOWTO (R_OR32_32, /* type */
|
74 |
|
|
0, /* rightshift */
|
75 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
76 |
|
|
32, /* bitsize */
|
77 |
|
|
FALSE, /* pc_relative */
|
78 |
|
|
0, /* bitpos */
|
79 |
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
80 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
81 |
|
|
"R_OR32_32", /* name */
|
82 |
|
|
TRUE, /* partial_inplace */
|
83 |
|
|
0xffffffff, /* src_mask */
|
84 |
|
|
0xffffffff, /* dst_mask */
|
85 |
|
|
FALSE), /* pcrel_offset */
|
86 |
|
|
|
87 |
|
|
/* A standard 16 bit relocation. */
|
88 |
|
|
HOWTO (R_OR32_16, /* type */
|
89 |
|
|
0, /* rightshift */
|
90 |
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
91 |
|
|
16, /* bitsize */
|
92 |
|
|
FALSE, /* pc_relative */
|
93 |
|
|
0, /* bitpos */
|
94 |
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
95 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
96 |
|
|
"R_OR32_16", /* name */
|
97 |
|
|
TRUE, /* partial_inplace */
|
98 |
|
|
0x0000ffff, /* src_mask */
|
99 |
|
|
0x0000ffff, /* dst_mask */
|
100 |
|
|
FALSE), /* pcrel_offset */
|
101 |
|
|
|
102 |
|
|
/* A standard 8 bit relocation. */
|
103 |
|
|
HOWTO (R_OR32_8, /* type */
|
104 |
|
|
0, /* rightshift */
|
105 |
|
|
0, /* size (0 = byte, 1 = short, 2 = long) */
|
106 |
|
|
8, /* bitsize */
|
107 |
|
|
FALSE, /* pc_relative */
|
108 |
|
|
0, /* bitpos */
|
109 |
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
110 |
|
|
bfd_elf_generic_reloc, /* special_function */
|
111 |
|
|
"R_OR32_8", /* name */
|
112 |
|
|
TRUE, /* partial_inplace */
|
113 |
|
|
0x000000ff, /* src_mask */
|
114 |
|
|
0x000000ff, /* dst_mask */
|
115 |
|
|
FALSE), /* pcrel_offset */
|
116 |
|
|
|
117 |
|
|
/* A standard low 16 bit relocation. */
|
118 |
|
|
HOWTO (R_OR32_CONST, /* type */
|
119 |
|
|
0, /* rightshift */
|
120 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
121 |
|
|
16, /* bitsize */
|
122 |
|
|
FALSE, /* pc_relative */
|
123 |
|
|
0, /* bitpos */
|
124 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
125 |
|
|
or32_elf_const_reloc, /* special_function */
|
126 |
|
|
"R_OR32_CONST", /* name */
|
127 |
|
|
TRUE, /* partial_inplace */
|
128 |
|
|
0x0000ffff, /* src_mask */
|
129 |
|
|
0x0000ffff, /* dst_mask */
|
130 |
|
|
FALSE), /* pcrel_offset */
|
131 |
|
|
|
132 |
|
|
/* A standard high 16 bit relocation. */
|
133 |
|
|
HOWTO (R_OR32_CONSTH, /* type */
|
134 |
|
|
16, /* rightshift */
|
135 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
136 |
|
|
16, /* bitsize */
|
137 |
|
|
FALSE, /* pc_relative */
|
138 |
|
|
0, /* bitpos */
|
139 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
140 |
|
|
or32_elf_consth_reloc, /* special_function */
|
141 |
|
|
"R_OR32_CONSTH", /* name */
|
142 |
|
|
TRUE, /* partial_inplace */
|
143 |
|
|
0x0000ffff, /* src_mask */
|
144 |
|
|
0x0000ffff, /* dst_mask */
|
145 |
|
|
FALSE), /* pcrel_offset */
|
146 |
|
|
|
147 |
|
|
/* A standard branch relocation. */
|
148 |
|
|
HOWTO (R_OR32_JUMPTARG, /* type */
|
149 |
|
|
2, /* rightshift */
|
150 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
151 |
|
|
28, /* bitsize */
|
152 |
|
|
TRUE, /* pc_relative */
|
153 |
|
|
0, /* bitpos */
|
154 |
|
|
complain_overflow_signed, /* complain_on_overflow */
|
155 |
|
|
_bfd_or32_elf_generic_reloc, /* special_function */
|
156 |
|
|
"R_OR32_JUMPTARG", /* name */
|
157 |
|
|
TRUE, /* partial_inplace */
|
158 |
|
|
0x03ffffff, /* src_mask *//* markom, was: 0 */
|
159 |
|
|
0x03ffffff, /* dst_mask */
|
160 |
|
|
TRUE), /* pcrel_offset */
|
161 |
|
|
|
162 |
|
|
/* GNU extension to record C++ vtable hierarchy. */
|
163 |
|
|
HOWTO (R_OR32_GNU_VTINHERIT, /* type */
|
164 |
|
|
0, /* rightshift */
|
165 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
166 |
|
|
0, /* bitsize */
|
167 |
|
|
FALSE, /* pc_relative */
|
168 |
|
|
0, /* bitpos */
|
169 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
170 |
|
|
NULL, /* special_function */
|
171 |
|
|
"R_OR32_GNU_VTINHERIT", /* name */
|
172 |
|
|
FALSE, /* partial_inplace */
|
173 |
|
|
0, /* src_mask */
|
174 |
|
|
0, /* dst_mask */
|
175 |
|
|
FALSE), /* pcrel_offset */
|
176 |
|
|
|
177 |
|
|
/* GNU extension to record C++ vtable member usage. */
|
178 |
|
|
HOWTO (R_OR32_GNU_VTENTRY, /* type */
|
179 |
|
|
0, /* rightshift */
|
180 |
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
181 |
|
|
0, /* bitsize */
|
182 |
|
|
FALSE, /* pc_relative */
|
183 |
|
|
0, /* bitpos */
|
184 |
|
|
complain_overflow_dont, /* complain_on_overflow */
|
185 |
|
|
_bfd_elf_rel_vtable_reloc_fn, /* special_function */
|
186 |
|
|
"R_OR32_GNU_VTENTRY", /* name */
|
187 |
|
|
FALSE, /* partial_inplace */
|
188 |
|
|
0, /* src_mask */
|
189 |
|
|
0, /* dst_mask */
|
190 |
|
|
FALSE), /* pcrel_offset */
|
191 |
|
|
};
|
192 |
|
|
|
193 |
|
|
/* Map BFD reloc types to OR32 ELF reloc types. */
|
194 |
|
|
|
195 |
|
|
struct or32_reloc_map
|
196 |
|
|
{
|
197 |
|
|
bfd_reloc_code_real_type bfd_reloc_val;
|
198 |
|
|
unsigned char elf_reloc_val;
|
199 |
|
|
};
|
200 |
|
|
|
201 |
|
|
static const struct or32_reloc_map or32_reloc_map[] =
|
202 |
|
|
{
|
203 |
|
|
{ BFD_RELOC_NONE, R_OR32_NONE },
|
204 |
|
|
{ BFD_RELOC_32, R_OR32_32 },
|
205 |
|
|
{ BFD_RELOC_16, R_OR32_16 },
|
206 |
|
|
{ BFD_RELOC_8, R_OR32_8 },
|
207 |
|
|
{ BFD_RELOC_LO16, R_OR32_CONST },
|
208 |
|
|
{ BFD_RELOC_HI16, R_OR32_CONSTH },
|
209 |
|
|
{ BFD_RELOC_28_PCREL_S2, R_OR32_JUMPTARG },
|
210 |
|
|
{ BFD_RELOC_VTABLE_INHERIT, R_OR32_GNU_VTINHERIT },
|
211 |
|
|
{ BFD_RELOC_VTABLE_ENTRY, R_OR32_GNU_VTENTRY },
|
212 |
|
|
};
|
213 |
|
|
|
214 |
|
|
static reloc_howto_type *
|
215 |
|
|
bfd_elf32_bfd_reloc_type_lookup (abfd, code)
|
216 |
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
217 |
|
|
bfd_reloc_code_real_type code;
|
218 |
|
|
{
|
219 |
|
|
unsigned int i;
|
220 |
|
|
|
221 |
|
|
for (i = ARRAY_SIZE (or32_reloc_map); i--;)
|
222 |
|
|
{
|
223 |
|
|
if (or32_reloc_map[i].bfd_reloc_val == code)
|
224 |
|
|
return &elf_or32_howto_table[or32_reloc_map[i].elf_reloc_val];
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
return NULL;
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
/* Set the howto pointer for an OR32 ELF reloc. */
|
231 |
|
|
|
232 |
|
|
static void
|
233 |
|
|
or32_info_to_howto_rel (abfd, cache_ptr, dst)
|
234 |
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
235 |
|
|
arelent *cache_ptr;
|
236 |
|
|
Elf_Internal_Rela *dst;
|
237 |
|
|
{
|
238 |
|
|
unsigned int r_type;
|
239 |
|
|
|
240 |
|
|
//static void or32_elf_info_to_howto_rel
|
241 |
|
|
// (bfd *bfd,
|
242 |
|
|
// arelent *relent,
|
243 |
|
|
// Elf_Internal_Rela *rela)
|
244 |
|
|
|
245 |
|
|
r_type = ELF32_R_TYPE (dst->r_info);
|
246 |
|
|
BFD_ASSERT (r_type < (unsigned int) R_OR32_max);
|
247 |
|
|
cache_ptr->howto = &elf_or32_howto_table[r_type];
|
248 |
|
|
|
249 |
|
|
asymbol *s = *(cache_ptr->sym_ptr_ptr);
|
250 |
|
|
if(ELF_R_SYM(dst->r_info) && (s->flags & BSF_SECTION_SYM))
|
251 |
|
|
cache_ptr->sym_ptr_ptr = s->section->symbol_ptr_ptr;
|
252 |
|
|
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
/* Set the right machine number for an OR32 ELF file. */
|
256 |
|
|
|
257 |
|
|
static bfd_boolean
|
258 |
|
|
or32_elf_object_p (abfd)
|
259 |
|
|
bfd *abfd;
|
260 |
|
|
{
|
261 |
|
|
(void) bfd_default_set_arch_mach (abfd, bfd_arch_or32, 0);
|
262 |
|
|
return TRUE;
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
/* The final processing done just before writing out an OR32 ELF object file.
|
266 |
|
|
This gets the OR32 architecture right based on the machine number. */
|
267 |
|
|
|
268 |
|
|
static void
|
269 |
|
|
or32_elf_final_write_processing (abfd, linker)
|
270 |
|
|
bfd *abfd;
|
271 |
|
|
bfd_boolean linker ATTRIBUTE_UNUSED;
|
272 |
|
|
{
|
273 |
|
|
int mach;
|
274 |
|
|
unsigned long val;
|
275 |
|
|
|
276 |
|
|
switch (mach = bfd_get_mach (abfd))
|
277 |
|
|
{
|
278 |
|
|
/*
|
279 |
|
|
case bfd_mach_arc_base:
|
280 |
|
|
val = E_OR32_MACH_BASE;
|
281 |
|
|
break;
|
282 |
|
|
*/
|
283 |
|
|
default:
|
284 |
|
|
val = 0;
|
285 |
|
|
return;
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
elf_elfheader (abfd)->e_flags &=~ EF_OR32_MACH;
|
289 |
|
|
elf_elfheader (abfd)->e_flags |= val;
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
static bfd_reloc_status_type
|
293 |
|
|
_bfd_or32_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
|
294 |
|
|
asymbol *symbol, void *data ATTRIBUTE_UNUSED,
|
295 |
|
|
asection *input_section, bfd *output_bfd,
|
296 |
|
|
char **error_message ATTRIBUTE_UNUSED)
|
297 |
|
|
{
|
298 |
|
|
bfd_signed_vma val;
|
299 |
|
|
bfd_reloc_status_type status;
|
300 |
|
|
bfd_boolean relocatable;
|
301 |
|
|
|
302 |
|
|
relocatable = (output_bfd != NULL);
|
303 |
|
|
|
304 |
|
|
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
|
305 |
|
|
return bfd_reloc_outofrange;
|
306 |
|
|
|
307 |
|
|
/* Build up the field adjustment in VAL. */
|
308 |
|
|
val = 0;
|
309 |
|
|
if (!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0)
|
310 |
|
|
{
|
311 |
|
|
/* Either we're calculating the final field value or we have a
|
312 |
|
|
relocation against a section symbol. Add in the section's
|
313 |
|
|
offset or address. */
|
314 |
|
|
val += symbol->section->output_section->vma;
|
315 |
|
|
val += symbol->section->output_offset;
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
if (!relocatable)
|
319 |
|
|
{
|
320 |
|
|
/* We're calculating the final field value. Add in the symbol's value
|
321 |
|
|
and, if pc-relative, subtract the address of the field itself. */
|
322 |
|
|
val += symbol->value;
|
323 |
|
|
if (reloc_entry->howto->pc_relative)
|
324 |
|
|
val -= input_section->output_section->vma;
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
if (reloc_entry->howto->pc_relative)
|
328 |
|
|
val -= input_section->output_offset;
|
329 |
|
|
|
330 |
|
|
/* VAL is now the final adjustment. If we're keeping this relocation
|
331 |
|
|
in the output file, and if the relocation uses a separate addend,
|
332 |
|
|
we just need to add VAL to that addend. Otherwise we need to add
|
333 |
|
|
VAL to the relocation field itself. */
|
334 |
|
|
if (relocatable && !reloc_entry->howto->partial_inplace)
|
335 |
|
|
reloc_entry->addend += val;
|
336 |
|
|
else
|
337 |
|
|
{
|
338 |
|
|
/* Add in the separate addend, if any. */
|
339 |
|
|
val += reloc_entry->addend;
|
340 |
|
|
|
341 |
|
|
/* Add VAL to the relocation field. */
|
342 |
|
|
status = _bfd_relocate_contents (reloc_entry->howto, abfd, val,
|
343 |
|
|
(bfd_byte *) data
|
344 |
|
|
+ reloc_entry->address);
|
345 |
|
|
if (status != bfd_reloc_ok)
|
346 |
|
|
return status;
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
if (relocatable)
|
350 |
|
|
reloc_entry->address += input_section->output_offset;
|
351 |
|
|
|
352 |
|
|
return bfd_reloc_ok;
|
353 |
|
|
}
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
/* Do a R_OR32_CONSTH relocation. This has to be done in combination
|
357 |
|
|
with a R_OR32_CONST reloc, because there is a carry from the LO16 to
|
358 |
|
|
the HI16. Here we just save the information we need; we do the
|
359 |
|
|
actual relocation when we see the LO16. OR32 ELF requires that the
|
360 |
|
|
LO16 immediately follow the HI16. As a GNU extension, we permit an
|
361 |
|
|
arbitrary number of HI16 relocs to be associated with a single LO16
|
362 |
|
|
reloc. This extension permits gcc to output the HI and LO relocs
|
363 |
|
|
itself. This code is copied from the elf32-mips.c. */
|
364 |
|
|
|
365 |
|
|
struct or32_consth
|
366 |
|
|
{
|
367 |
|
|
struct or32_consth *next;
|
368 |
|
|
bfd_byte *data;
|
369 |
|
|
asection *input_section;
|
370 |
|
|
arelent rel;
|
371 |
|
|
};
|
372 |
|
|
|
373 |
|
|
/* FIXME: This should not be a static variable. */
|
374 |
|
|
|
375 |
|
|
static struct or32_consth *or32_consth_list;
|
376 |
|
|
|
377 |
|
|
bfd_reloc_status_type
|
378 |
|
|
or32_elf_consth_reloc (abfd, reloc_entry, symbol, data, input_section,
|
379 |
|
|
output_bfd, error_message)
|
380 |
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
381 |
|
|
arelent *reloc_entry;
|
382 |
|
|
asymbol *symbol ATTRIBUTE_UNUSED;
|
383 |
|
|
PTR data;
|
384 |
|
|
asection *input_section;
|
385 |
|
|
bfd *output_bfd;
|
386 |
|
|
char **error_message ATTRIBUTE_UNUSED;
|
387 |
|
|
{
|
388 |
|
|
struct or32_consth *n;
|
389 |
|
|
|
390 |
|
|
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
|
391 |
|
|
return bfd_reloc_outofrange;
|
392 |
|
|
|
393 |
|
|
/* Save the information, and let LO16 do the actual relocation. */
|
394 |
|
|
n = (struct or32_consth *) bfd_malloc (sizeof *n);
|
395 |
|
|
if (n == NULL)
|
396 |
|
|
return bfd_reloc_outofrange;
|
397 |
|
|
|
398 |
|
|
/* Push this reloc on the list of pending relocations */
|
399 |
|
|
n->next = or32_consth_list;
|
400 |
|
|
n->data = data;
|
401 |
|
|
n->input_section = input_section;
|
402 |
|
|
n->rel = *reloc_entry;
|
403 |
|
|
or32_consth_list = n;
|
404 |
|
|
|
405 |
|
|
if (output_bfd != NULL)
|
406 |
|
|
reloc_entry->address += input_section->output_offset;
|
407 |
|
|
|
408 |
|
|
return bfd_reloc_ok;
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
/* Do a R_OR32_CONST relocation. This is a straightforward 16 bit
|
412 |
|
|
inplace relocation; this function exists in order to do the
|
413 |
|
|
R_OR32_CONSTH relocation described above. */
|
414 |
|
|
|
415 |
|
|
bfd_reloc_status_type
|
416 |
|
|
or32_elf_const_reloc (abfd, reloc_entry, symbol, data, input_section,
|
417 |
|
|
output_bfd, error_message)
|
418 |
|
|
bfd *abfd;
|
419 |
|
|
arelent *reloc_entry;
|
420 |
|
|
asymbol *symbol;
|
421 |
|
|
PTR data;
|
422 |
|
|
asection *input_section;
|
423 |
|
|
bfd *output_bfd;
|
424 |
|
|
char **error_message;
|
425 |
|
|
{
|
426 |
|
|
bfd_vma vallo;
|
427 |
|
|
|
428 |
|
|
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
|
429 |
|
|
return bfd_reloc_outofrange;
|
430 |
|
|
|
431 |
|
|
vallo = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) & 0xffff;
|
432 |
|
|
|
433 |
|
|
while (or32_consth_list != NULL)
|
434 |
|
|
{
|
435 |
|
|
bfd_reloc_status_type ret;
|
436 |
|
|
struct or32_consth *hi;
|
437 |
|
|
|
438 |
|
|
hi = or32_consth_list;
|
439 |
|
|
|
440 |
|
|
/* VALLO is a signed 16-bit number. Bias it by 0x8000 so that any
|
441 |
|
|
carry or borrow will induce a change of +1 or -1 in the high part. */
|
442 |
|
|
hi->rel.addend += vallo;
|
443 |
|
|
|
444 |
|
|
ret = _bfd_or32_elf_generic_reloc (abfd, &hi->rel, symbol, hi->data,
|
445 |
|
|
hi->input_section, output_bfd,
|
446 |
|
|
error_message);
|
447 |
|
|
if (ret != bfd_reloc_ok)
|
448 |
|
|
return ret;
|
449 |
|
|
|
450 |
|
|
or32_consth_list = hi->next;
|
451 |
|
|
free (hi);
|
452 |
|
|
}
|
453 |
|
|
|
454 |
|
|
return _bfd_or32_elf_generic_reloc (abfd, reloc_entry, symbol, data,
|
455 |
|
|
input_section, output_bfd,
|
456 |
|
|
error_message);
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
#define TARGET_LITTLE_SYM bfd_elf32_or32_little_vec
|
460 |
|
|
#define TARGET_LITTLE_NAME "elf32-littleor32"
|
461 |
|
|
#define TARGET_BIG_SYM bfd_elf32_or32_big_vec
|
462 |
|
|
#define TARGET_BIG_NAME "elf32-or32"
|
463 |
|
|
#define ELF_ARCH bfd_arch_or32
|
464 |
|
|
#define ELF_MACHINE_CODE EM_OPENRISC
|
465 |
|
|
#define ELF_MACHINE_ALT1 EM_OR32
|
466 |
|
|
#define ELF_MAXPAGESIZE 0x2000
|
467 |
|
|
|
468 |
|
|
#define elf_info_to_howto 0
|
469 |
|
|
#define elf_info_to_howto_rel or32_info_to_howto_rel
|
470 |
|
|
//#define bfd_elf32_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
|
471 |
|
|
//#define elf_backend_can_gc_sections 1
|
472 |
|
|
//#define elf_backend_check_relocs or32_elf_check_relocs
|
473 |
|
|
#define elf_backend_object_p or32_elf_object_p
|
474 |
|
|
#define elf_backend_final_write_processing \
|
475 |
|
|
or32_elf_final_write_processing
|
476 |
|
|
|
477 |
|
|
#include "elf32-target.h"
|