]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/coff-mcore.c
fix set but unused variable warnings
[thirdparty/binutils-gdb.git] / bfd / coff-mcore.c
CommitLineData
3442f309 1/* BFD back-end for Motorola MCore COFF/PE
c7e2358a 2 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2010
d003868e 3 Free Software Foundation, Inc.
252b5132 4
cd123cb7
NC
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, 51 Franklin Street - Fifth Floor,
20 Boston, MA 02110-1301, USA. */
252b5132 21
252b5132 22#include "sysdep.h"
3db64b00 23#include "bfd.h"
252b5132
RH
24#include "libbfd.h"
25#include "coff/mcore.h"
26#include "coff/internal.h"
27#include "coff/pe.h"
28#include "libcoff.h"
29
30#ifdef BADMAG
31#undef BADMAG
32#endif
33#define BADMAG(x) MCOREBADMAG(x)
34
35#ifndef NUM_ELEM
36#define NUM_ELEM(A) (sizeof (A) / sizeof (A)[0])
37#endif
38
39/* This file is compiled more than once, but we only compile the
40 final_link routine once. */
b34976b6 41extern bfd_boolean mcore_bfd_coff_final_link
252b5132 42 PARAMS ((bfd *, struct bfd_link_info *));
b34976b6 43static bfd_reloc_status_type mcore_coff_unsupported_reloc
252b5132 44 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
b34976b6 45static bfd_boolean coff_mcore_relocate_section
252b5132
RH
46 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
47 struct internal_reloc *, struct internal_syment *, asection **));
b34976b6 48static reloc_howto_type *mcore_coff_reloc_type_lookup
252b5132 49 PARAMS ((bfd *, bfd_reloc_code_real_type));
b34976b6 50static reloc_howto_type *coff_mcore_rtype_to_howto
252b5132 51 PARAMS ((bfd *, asection *, struct internal_reloc *,
b34976b6
AM
52 struct coff_link_hash_entry *, struct internal_syment *,
53 bfd_vma *));
b34976b6 54static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
252b5132
RH
55\f
56/* The NT loader points the toc register to &toc + 32768, in order to
57 use the complete range of a 16-bit displacement. We have to adjust
58 for this when we fix up loads displaced off the toc reg. */
59#define TOC_LOAD_ADJUSTMENT (-32768)
60#define TOC_SECTION_NAME ".private.toc"
61
62/* The main body of code is in coffcode.h. */
f45fbf87 63#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
252b5132
RH
64
65/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
66 from smaller values. Start with zero, widen, *then* decrement. */
67#define MINUS_ONE (((bfd_vma)0) - 1)
252b5132
RH
68\f
69static reloc_howto_type mcore_coff_howto_table[] =
70{
71 /* Unused: */
b48499ec
KH
72 HOWTO (IMAGE_REL_MCORE_ABSOLUTE,/* type */
73 0, /* rightshift */
74 0, /* size (0 = byte, 1 = short, 2 = long) */
75 0, /* bitsize */
b34976b6 76 FALSE, /* pc_relative */
b48499ec 77 0, /* bitpos */
252b5132 78 complain_overflow_dont, /* dont complain_on_overflow */
b48499ec 79 NULL, /* special_function */
252b5132 80 "ABSOLUTE", /* name */
b34976b6 81 FALSE, /* partial_inplace */
b48499ec
KH
82 0x00, /* src_mask */
83 0x00, /* dst_mask */
b34976b6 84 FALSE), /* pcrel_offset */
b48499ec 85
252b5132 86 HOWTO (IMAGE_REL_MCORE_ADDR32,/* type */
b48499ec
KH
87 0, /* rightshift */
88 2, /* size (0 = byte, 1 = short, 2 = long) */
89 32, /* bitsize */
b34976b6 90 FALSE, /* pc_relative */
b48499ec 91 0, /* bitpos */
252b5132 92 complain_overflow_bitfield, /* complain_on_overflow */
b48499ec 93 NULL, /* special_function */
252b5132 94 "ADDR32", /* name */
b34976b6 95 TRUE, /* partial_inplace */
b48499ec
KH
96 0xffffffff, /* src_mask */
97 0xffffffff, /* dst_mask */
b34976b6 98 FALSE), /* pcrel_offset */
b48499ec 99
252b5132 100 /* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
b48499ec 101 Should not appear in object files. */
252b5132
RH
102 HOWTO (IMAGE_REL_MCORE_PCREL_IMM8BY4, /* type */
103 2, /* rightshift */
104 1, /* size (0 = byte, 1 = short, 2 = long) */
105 8, /* bitsize */
b34976b6 106 TRUE, /* pc_relative */
252b5132
RH
107 0, /* bitpos */
108 complain_overflow_bitfield, /* complain_on_overflow */
36797d47 109 mcore_coff_unsupported_reloc, /* special_function */
252b5132 110 "IMM8BY4", /* name */
b34976b6 111 FALSE, /* partial_inplace */
252b5132
RH
112 0, /* src_mask */
113 0, /* dst_mask */
b34976b6 114 TRUE), /* pcrel_offset */
252b5132 115
b48499ec 116 /* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
252b5132
RH
117 Span 2k instructions == 4k bytes.
118 Only useful pieces at the relocated address are the opcode (5 bits) */
119 HOWTO (IMAGE_REL_MCORE_PCREL_IMM11BY2,/* type */
120 1, /* rightshift */
121 1, /* size (0 = byte, 1 = short, 2 = long) */
122 11, /* bitsize */
b34976b6 123 TRUE, /* pc_relative */
252b5132
RH
124 0, /* bitpos */
125 complain_overflow_signed, /* complain_on_overflow */
126 NULL, /* special_function */
127 "IMM11BY2", /* name */
b34976b6 128 FALSE, /* partial_inplace */
252b5132
RH
129 0x0, /* src_mask */
130 0x7ff, /* dst_mask */
b34976b6 131 TRUE), /* pcrel_offset */
252b5132 132
b48499ec 133 /* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
252b5132
RH
134 HOWTO (IMAGE_REL_MCORE_PCREL_IMM4BY2, /* type */
135 1, /* rightshift */
136 1, /* size (0 = byte, 1 = short, 2 = long) */
137 4, /* bitsize */
b34976b6 138 TRUE, /* pc_relative */
252b5132
RH
139 0, /* bitpos */
140 complain_overflow_bitfield, /* complain_on_overflow */
36797d47 141 mcore_coff_unsupported_reloc, /* special_function */
252b5132 142 "IMM4BY2", /* name */
b34976b6 143 FALSE, /* partial_inplace */
252b5132
RH
144 0, /* src_mask */
145 0, /* dst_mask */
b34976b6 146 TRUE), /* pcrel_offset */
252b5132 147
b48499ec 148 /* 32-bit pc-relative. Eventually this will help support PIC code. */
252b5132
RH
149 HOWTO (IMAGE_REL_MCORE_PCREL_32,/* type */
150 0, /* rightshift */
151 2, /* size (0 = byte, 1 = short, 2 = long) */
152 32, /* bitsize */
b34976b6 153 TRUE, /* pc_relative */
252b5132
RH
154 0, /* bitpos */
155 complain_overflow_bitfield, /* complain_on_overflow */
156 NULL, /* special_function */
157 "PCREL_32", /* name */
b34976b6 158 FALSE, /* partial_inplace */
252b5132
RH
159 0x0, /* src_mask */
160 0xffffffff, /* dst_mask */
b34976b6 161 TRUE), /* pcrel_offset */
252b5132
RH
162
163 /* Like PCREL_IMM11BY2, this relocation indicates that there is a
164 'jsri' at the specified address. There is a separate relocation
b48499ec 165 entry for the literal pool entry that it references, but we
252b5132
RH
166 might be able to change the jsri to a bsr if the target turns out
167 to be close enough [even though we won't reclaim the literal pool
168 entry, we'll get some runtime efficiency back]. Note that this
b48499ec 169 is a relocation that we are allowed to safely ignore. */
252b5132
RH
170 HOWTO (IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2,/* type */
171 1, /* rightshift */
172 1, /* size (0 = byte, 1 = short, 2 = long) */
173 11, /* bitsize */
b34976b6 174 TRUE, /* pc_relative */
252b5132
RH
175 0, /* bitpos */
176 complain_overflow_signed, /* complain_on_overflow */
177 NULL, /* special_function */
178 "JSR_IMM11BY2", /* name */
b34976b6 179 FALSE, /* partial_inplace */
252b5132
RH
180 0x0, /* src_mask */
181 0x7ff, /* dst_mask */
b34976b6 182 TRUE), /* pcrel_offset */
b48499ec 183
36797d47
NC
184 HOWTO (IMAGE_REL_MCORE_RVA, /* type */
185 0, /* rightshift */
186 2, /* size (0 = byte, 1 = short, 2 = long) */
187 32, /* bitsize */
b34976b6 188 FALSE, /* pc_relative */
36797d47
NC
189 0, /* bitpos */
190 complain_overflow_signed, /* complain_on_overflow */
191 NULL, /* special_function */
192 "MCORE_RVA", /* name */
b34976b6 193 TRUE, /* partial_inplace */
36797d47
NC
194 0xffffffff, /* src_mask */
195 0xffffffff, /* dst_mask */
b34976b6 196 TRUE) /* pcrel_offset */
252b5132
RH
197};
198\f
199/* Extend the coff_link_hash_table structure with a few M*Core specific fields.
200 This allows us to store global data here without actually creating any
201 global variables, which is a no-no in the BFD world. */
202typedef struct coff_mcore_link_hash_table
203{
204 /* The original coff_link_hash_table structure. MUST be first field. */
205 struct coff_link_hash_table root;
206
207 bfd * bfd_of_toc_owner;
208 long int global_toc_size;
209 long int import_table_size;
210 long int first_thunk_address;
211 long int thunk_size;
212}
213mcore_hash_table;
214
215/* Get the MCore coff linker hash table from a link_info structure. */
216#define coff_mcore_hash_table(info) \
217 ((mcore_hash_table *) ((info)->hash))
218
252b5132 219\f
69e70d30 220/* Add an entry to the base file. */
42ef282f 221
b1657152
AM
222static bfd_boolean
223mcore_emit_base_file_entry (struct bfd_link_info *info,
224 bfd *output_bfd,
225 asection *input_section,
226 bfd_vma reloc_offset)
69e70d30
NC
227{
228 bfd_vma addr = reloc_offset
229 - input_section->vma
230 + input_section->output_offset
231 + input_section->output_section->vma;
232
233 if (coff_data (output_bfd)->pe)
234 addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
b48499ec 235
b1657152
AM
236 if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
237 return TRUE;
238
239 bfd_set_error (bfd_error_system_call);
240 return FALSE;
69e70d30
NC
241}
242\f
252b5132
RH
243static bfd_reloc_status_type
244mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
245 output_bfd, error_message)
246 bfd * abfd;
247 arelent * reloc_entry;
5f771d47
ILT
248 asymbol * symbol ATTRIBUTE_UNUSED;
249 PTR data ATTRIBUTE_UNUSED;
250 asection * input_section ATTRIBUTE_UNUSED;
251 bfd * output_bfd ATTRIBUTE_UNUSED;
252 char ** error_message ATTRIBUTE_UNUSED;
252b5132
RH
253{
254 BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
b48499ec 255
d003868e
AM
256 _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
257 abfd,
252b5132
RH
258 reloc_entry->howto->name,
259 reloc_entry->howto->type);
b48499ec 260
252b5132
RH
261 return bfd_reloc_notsupported;
262}
252b5132 263\f
b48499ec 264/* A cheesy little macro to make the code a little more readable. */
252b5132
RH
265#define HOW2MAP(bfd_rtype, mcore_rtype) \
266 case bfd_rtype: return & mcore_coff_howto_table [mcore_rtype]
267
268static reloc_howto_type *
269mcore_coff_reloc_type_lookup (abfd, code)
5f771d47 270 bfd * abfd ATTRIBUTE_UNUSED;
252b5132
RH
271 bfd_reloc_code_real_type code;
272{
273 switch (code)
b48499ec 274 {
252b5132
RH
275 HOW2MAP (BFD_RELOC_32, IMAGE_REL_MCORE_ADDR32);
276 HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM8BY4, IMAGE_REL_MCORE_PCREL_IMM8BY4);
277 HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM11BY2, IMAGE_REL_MCORE_PCREL_IMM11BY2);
278 HOW2MAP (BFD_RELOC_MCORE_PCREL_IMM4BY2, IMAGE_REL_MCORE_PCREL_IMM4BY2);
279 HOW2MAP (BFD_RELOC_32_PCREL, IMAGE_REL_MCORE_PCREL_32);
280 HOW2MAP (BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2);
36797d47 281 HOW2MAP (BFD_RELOC_RVA, IMAGE_REL_MCORE_RVA);
b48499ec 282 default:
252b5132
RH
283 return NULL;
284 }
285 /*NOTREACHED*/
286}
252b5132
RH
287#undef HOW2MAP
288
157090f7
AM
289static reloc_howto_type *
290mcore_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
291 const char *r_name)
292{
293 unsigned int i;
294
295 for (i = 0;
296 i < (sizeof (mcore_coff_howto_table)
297 / sizeof (mcore_coff_howto_table[0]));
298 i++)
299 if (mcore_coff_howto_table[i].name != NULL
300 && strcasecmp (mcore_coff_howto_table[i].name, r_name) == 0)
301 return &mcore_coff_howto_table[i];
302
303 return NULL;
304}
305
252b5132
RH
306#define RTYPE2HOWTO(cache_ptr, dst) \
307 (cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
308
309static reloc_howto_type *
310coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
5f771d47 311 bfd * abfd ATTRIBUTE_UNUSED;
252b5132
RH
312 asection * sec;
313 struct internal_reloc * rel;
5f771d47 314 struct coff_link_hash_entry * h ATTRIBUTE_UNUSED;
252b5132
RH
315 struct internal_syment * sym;
316 bfd_vma * addendp;
317{
318 reloc_howto_type * howto;
319
252b5132
RH
320 if (rel->r_type >= NUM_ELEM (mcore_coff_howto_table))
321 return NULL;
b48499ec 322
252b5132 323 howto = mcore_coff_howto_table + rel->r_type;
36797d47
NC
324
325 if (rel->r_type == IMAGE_REL_MCORE_RVA)
326 * addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
b48499ec 327
078c8694 328 else if (howto->pc_relative)
252b5132
RH
329 {
330 * addendp = sec->vma - 2; /* XXX guess - is this right ? */
b48499ec 331
252b5132
RH
332 /* If the symbol is defined, then the generic code is going to
333 add back the symbol value in order to cancel out an
334 adjustment it made to the addend. However, we set the addend
335 to 0 at the start of this function. We need to adjust here,
336 to avoid the adjustment the generic code will make. FIXME:
337 This is getting a bit hackish. */
338 if (sym != NULL && sym->n_scnum != 0)
339 * addendp -= sym->n_value;
340 }
341 else
342 * addendp = 0;
b48499ec 343
252b5132
RH
344 return howto;
345}
1349dd65 346
b34976b6 347/* Return TRUE if this relocation should appear in the output .reloc section.
1349dd65 348 This function is referenced in pe_mkobject in peicode.h. */
42ef282f 349
b34976b6 350static bfd_boolean
1349dd65 351in_reloc_p (abfd, howto)
5f771d47 352 bfd * abfd ATTRIBUTE_UNUSED;
1349dd65
NC
353 reloc_howto_type * howto;
354{
355 return ! howto->pc_relative && howto->type != IMAGE_REL_MCORE_RVA;
b48499ec 356}
252b5132 357\f
252b5132 358/* The reloc processing routine for the optimized COFF linker. */
b34976b6 359static bfd_boolean
252b5132
RH
360coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section,
361 contents, relocs, syms, sections)
362 bfd * output_bfd;
363 struct bfd_link_info * info;
364 bfd * input_bfd;
365 asection * input_section;
366 bfd_byte * contents;
367 struct internal_reloc * relocs;
368 struct internal_syment * syms;
369 asection ** sections;
370{
371 struct internal_reloc * rel;
372 struct internal_reloc * relend;
b48499ec 373
1049f94e 374 /* If we are performing a relocatable link, we don't need to do a
252b5132
RH
375 thing. The caller will take care of adjusting the reloc
376 addresses and symbol indices. */
1049f94e 377 if (info->relocatable)
b34976b6 378 return TRUE;
b48499ec 379
b23f908b
NC
380 /* Check if we have the same endianess */
381 if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder
382 && output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
383 {
384 (*_bfd_error_handler)
d003868e
AM
385 (_("%B: compiled for a %s system and target is %s.\n"),
386 input_bfd,
8f615d07
AM
387 bfd_big_endian (input_bfd) ? _("big endian") : _("little endian"),
388 bfd_big_endian (output_bfd) ? _("big endian") : _("little endian"));
b23f908b
NC
389
390 bfd_set_error (bfd_error_wrong_format);
b34976b6 391 return FALSE;
b23f908b 392 }
252b5132 393
252b5132
RH
394 rel = relocs;
395 relend = rel + input_section->reloc_count;
b48499ec 396
252b5132
RH
397 for (; rel < relend; rel++)
398 {
252b5132
RH
399 long symndx;
400 struct internal_syment * sym;
401 bfd_vma val;
402 bfd_vma addend;
403 bfd_reloc_status_type rstat;
404 bfd_byte * loc;
405 unsigned short r_type = rel->r_type;
406 reloc_howto_type * howto = NULL;
407 struct coff_link_hash_entry * h;
408 const char * my_name;
b48499ec 409
252b5132
RH
410 symndx = rel->r_symndx;
411 loc = contents + rel->r_vaddr - input_section->vma;
412
413 if (symndx == -1)
414 {
415 h = NULL;
416 sym = NULL;
417 }
418 else
419 {
420 h = obj_coff_sym_hashes (input_bfd)[symndx];
421 sym = syms + symndx;
422 }
423
078c8694 424 addend = 0;
b48499ec 425
252b5132
RH
426 /* Get the howto and initialise the addend. */
427 howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
428 sym, & addend);
429 if (howto == NULL)
b34976b6 430 return FALSE;
252b5132
RH
431
432 val = 0;
b48499ec 433
252b5132
RH
434 if (h == NULL)
435 {
436 if (symndx == -1)
437 my_name = "*ABS*";
438 else
439 {
440 asection * sec = sections[symndx];
b48499ec
KH
441
442 val = (sym->n_value
252b5132
RH
443 + sec->output_section->vma
444 + sec->output_offset);
445
446 if (sym == NULL)
447 my_name = "*unknown*";
448 else if ( sym->_n._n_n._n_zeroes == 0
449 && sym->_n._n_n._n_offset != 0)
450 my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
b48499ec 451 else
252b5132
RH
452 {
453 static char buf [SYMNMLEN + 1];
b48499ec 454
252b5132
RH
455 strncpy (buf, sym->_n._n_name, SYMNMLEN);
456 buf[SYMNMLEN] = '\0';
457 my_name = buf;
458 }
459 }
460 }
461 else
462 {
463 if ( h->root.type == bfd_link_hash_defined
464 || h->root.type == bfd_link_hash_defweak)
465 {
466 asection * sec = h->root.u.def.section;
b48499ec 467
252b5132
RH
468 val = (h->root.u.def.value
469 + sec->output_section->vma
470 + sec->output_offset);
471 }
472 else
473 {
474 if (! ((*info->callbacks->undefined_symbol)
475 (info, h->root.root.string, input_bfd, input_section,
b34976b6
AM
476 rel->r_vaddr - input_section->vma, TRUE)))
477 return FALSE;
252b5132 478 }
b48499ec 479
252b5132 480 my_name = h->root.root.string;
b48499ec 481 }
252b5132
RH
482
483 rstat = bfd_reloc_ok;
b48499ec 484
252b5132
RH
485 /* Each case must do its own relocation, setting rstat appropriately. */
486 switch (r_type)
487 {
488 default:
d003868e
AM
489 _bfd_error_handler (_("%B: unsupported relocation type 0x%02x"),
490 input_bfd, r_type);
252b5132 491 bfd_set_error (bfd_error_bad_value);
b34976b6 492 return FALSE;
b48499ec 493
252b5132 494 case IMAGE_REL_MCORE_ABSOLUTE:
d003868e
AM
495 _bfd_error_handler
496 (_("Warning: unsupported reloc %s <file %B, section %A>\n"
497 "sym %ld (%s), r_vaddr %ld (%lx)"),
498 input_bfd, input_section, howto->name,
499 rel->r_symndx, my_name, (long) rel->r_vaddr,
500 (unsigned long) rel->r_vaddr);
252b5132 501 break;
b48499ec 502
252b5132
RH
503 case IMAGE_REL_MCORE_PCREL_IMM8BY4:
504 case IMAGE_REL_MCORE_PCREL_IMM11BY2:
505 case IMAGE_REL_MCORE_PCREL_IMM4BY2:
506 case IMAGE_REL_MCORE_PCREL_32:
507 case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2:
508 case IMAGE_REL_MCORE_ADDR32:
078c8694 509 /* XXX fixme - shouldn't this be like the code for the RVA reloc ? */
252b5132
RH
510 rstat = _bfd_relocate_contents (howto, input_bfd, val, loc);
511 break;
b48499ec 512
078c8694
NC
513 case IMAGE_REL_MCORE_RVA:
514 rstat = _bfd_final_link_relocate
515 (howto, input_bfd,
516 input_section, contents, rel->r_vaddr - input_section->vma,
517 val, addend);
518 break;
252b5132 519 }
b48499ec 520
b1657152
AM
521 /* Emit a reloc if the backend thinks it needs it. */
522 if (info->base_file
523 && sym
524 && pe_data (output_bfd)->in_reloc_p (output_bfd, howto)
525 && !mcore_emit_base_file_entry (info, output_bfd, input_section,
526 rel->r_vaddr))
527 return FALSE;
b48499ec 528
252b5132
RH
529 switch (rstat)
530 {
531 default:
532 abort ();
b48499ec 533
252b5132
RH
534 case bfd_reloc_ok:
535 break;
b48499ec 536
252b5132
RH
537 case bfd_reloc_overflow:
538 if (! ((*info->callbacks->reloc_overflow)
dfeffb9f 539 (info, (h ? &h->root : NULL), my_name, howto->name,
252b5132
RH
540 (bfd_vma) 0, input_bfd,
541 input_section, rel->r_vaddr - input_section->vma)))
b34976b6 542 return FALSE;
252b5132 543 }
b48499ec 544 }
252b5132 545
b34976b6 546 return TRUE;
252b5132 547}
252b5132 548\f
b48499ec 549/* Tailor coffcode.h -- macro heaven. */
252b5132
RH
550
551/* We use the special COFF backend linker, with our own special touch. */
552
553#define coff_bfd_reloc_type_lookup mcore_coff_reloc_type_lookup
157090f7 554#define coff_bfd_reloc_name_lookup mcore_coff_reloc_name_lookup
252b5132
RH
555#define coff_relocate_section coff_mcore_relocate_section
556#define coff_rtype_to_howto coff_mcore_rtype_to_howto
557
558#define SELECT_RELOC(internal, howto) {internal.r_type = howto->type;}
559
dc12c51f
AM
560/* Make sure that the 'r_offset' field is copied properly
561 so that identical binaries will compare the same. */
562#define SWAP_IN_RELOC_OFFSET H_GET_32
563#define SWAP_OUT_RELOC_OFFSET H_PUT_32
564
252b5132
RH
565#define COFF_PAGE_SIZE 0x1000
566
567#include "coffcode.h"
568\f
5c4491d3 569/* Forward declaration to initialise alternative_target field. */
c3c89269 570extern const bfd_target TARGET_LITTLE_SYM;
252b5132 571
b48499ec 572/* The transfer vectors that lead the outside world to all of the above. */
60bcf0fa
NC
573CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED,
574 (SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
3fa78519 575 0, & TARGET_LITTLE_SYM, COFF_SWAP_TABLE)
60bcf0fa
NC
576CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED,
577 (SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
3fa78519 578 0, & TARGET_BIG_SYM, COFF_SWAP_TABLE)