]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/coff-mcore.c
This commit was manufactured by cvs2svn to create branch 'gdb_7_0-branch'.
[thirdparty/binutils-gdb.git] / bfd / coff-mcore.c
CommitLineData
3442f309 1/* BFD back-end for Motorola MCore COFF/PE
157090f7 2 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
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;
b34976b6 373 bfd_boolean hihalf;
252b5132 374 bfd_vma hihalf_val;
b48499ec 375
1049f94e 376 /* If we are performing a relocatable link, we don't need to do a
252b5132
RH
377 thing. The caller will take care of adjusting the reloc
378 addresses and symbol indices. */
1049f94e 379 if (info->relocatable)
b34976b6 380 return TRUE;
b48499ec 381
b23f908b
NC
382 /* Check if we have the same endianess */
383 if ( input_bfd->xvec->byteorder != output_bfd->xvec->byteorder
384 && output_bfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
385 {
386 (*_bfd_error_handler)
d003868e
AM
387 (_("%B: compiled for a %s system and target is %s.\n"),
388 input_bfd,
8f615d07
AM
389 bfd_big_endian (input_bfd) ? _("big endian") : _("little endian"),
390 bfd_big_endian (output_bfd) ? _("big endian") : _("little endian"));
b23f908b
NC
391
392 bfd_set_error (bfd_error_wrong_format);
b34976b6 393 return FALSE;
b23f908b 394 }
252b5132 395
b34976b6 396 hihalf = FALSE;
252b5132
RH
397 hihalf_val = 0;
398
399 rel = relocs;
400 relend = rel + input_section->reloc_count;
b48499ec 401
252b5132
RH
402 for (; rel < relend; rel++)
403 {
252b5132
RH
404 long symndx;
405 struct internal_syment * sym;
406 bfd_vma val;
407 bfd_vma addend;
408 bfd_reloc_status_type rstat;
409 bfd_byte * loc;
410 unsigned short r_type = rel->r_type;
411 reloc_howto_type * howto = NULL;
412 struct coff_link_hash_entry * h;
413 const char * my_name;
b48499ec 414
252b5132
RH
415 symndx = rel->r_symndx;
416 loc = contents + rel->r_vaddr - input_section->vma;
417
418 if (symndx == -1)
419 {
420 h = NULL;
421 sym = NULL;
422 }
423 else
424 {
425 h = obj_coff_sym_hashes (input_bfd)[symndx];
426 sym = syms + symndx;
427 }
428
078c8694 429 addend = 0;
b48499ec 430
252b5132
RH
431 /* Get the howto and initialise the addend. */
432 howto = bfd_coff_rtype_to_howto (input_bfd, input_section, rel, h,
433 sym, & addend);
434 if (howto == NULL)
b34976b6 435 return FALSE;
252b5132
RH
436
437 val = 0;
b48499ec 438
252b5132
RH
439 if (h == NULL)
440 {
441 if (symndx == -1)
442 my_name = "*ABS*";
443 else
444 {
445 asection * sec = sections[symndx];
b48499ec
KH
446
447 val = (sym->n_value
252b5132
RH
448 + sec->output_section->vma
449 + sec->output_offset);
450
451 if (sym == NULL)
452 my_name = "*unknown*";
453 else if ( sym->_n._n_n._n_zeroes == 0
454 && sym->_n._n_n._n_offset != 0)
455 my_name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset;
b48499ec 456 else
252b5132
RH
457 {
458 static char buf [SYMNMLEN + 1];
b48499ec 459
252b5132
RH
460 strncpy (buf, sym->_n._n_name, SYMNMLEN);
461 buf[SYMNMLEN] = '\0';
462 my_name = buf;
463 }
464 }
465 }
466 else
467 {
468 if ( h->root.type == bfd_link_hash_defined
469 || h->root.type == bfd_link_hash_defweak)
470 {
471 asection * sec = h->root.u.def.section;
b48499ec 472
252b5132
RH
473 val = (h->root.u.def.value
474 + sec->output_section->vma
475 + sec->output_offset);
476 }
477 else
478 {
479 if (! ((*info->callbacks->undefined_symbol)
480 (info, h->root.root.string, input_bfd, input_section,
b34976b6
AM
481 rel->r_vaddr - input_section->vma, TRUE)))
482 return FALSE;
252b5132 483 }
b48499ec 484
252b5132 485 my_name = h->root.root.string;
b48499ec 486 }
252b5132
RH
487
488 rstat = bfd_reloc_ok;
b48499ec 489
252b5132
RH
490 /* Each case must do its own relocation, setting rstat appropriately. */
491 switch (r_type)
492 {
493 default:
d003868e
AM
494 _bfd_error_handler (_("%B: unsupported relocation type 0x%02x"),
495 input_bfd, r_type);
252b5132 496 bfd_set_error (bfd_error_bad_value);
b34976b6 497 return FALSE;
b48499ec 498
252b5132 499 case IMAGE_REL_MCORE_ABSOLUTE:
d003868e
AM
500 _bfd_error_handler
501 (_("Warning: unsupported reloc %s <file %B, section %A>\n"
502 "sym %ld (%s), r_vaddr %ld (%lx)"),
503 input_bfd, input_section, howto->name,
504 rel->r_symndx, my_name, (long) rel->r_vaddr,
505 (unsigned long) rel->r_vaddr);
252b5132 506 break;
b48499ec 507
252b5132
RH
508 case IMAGE_REL_MCORE_PCREL_IMM8BY4:
509 case IMAGE_REL_MCORE_PCREL_IMM11BY2:
510 case IMAGE_REL_MCORE_PCREL_IMM4BY2:
511 case IMAGE_REL_MCORE_PCREL_32:
512 case IMAGE_REL_MCORE_PCREL_JSR_IMM11BY2:
513 case IMAGE_REL_MCORE_ADDR32:
078c8694 514 /* XXX fixme - shouldn't this be like the code for the RVA reloc ? */
252b5132
RH
515 rstat = _bfd_relocate_contents (howto, input_bfd, val, loc);
516 break;
b48499ec 517
078c8694
NC
518 case IMAGE_REL_MCORE_RVA:
519 rstat = _bfd_final_link_relocate
520 (howto, input_bfd,
521 input_section, contents, rel->r_vaddr - input_section->vma,
522 val, addend);
523 break;
252b5132 524 }
b48499ec 525
b1657152
AM
526 /* Emit a reloc if the backend thinks it needs it. */
527 if (info->base_file
528 && sym
529 && pe_data (output_bfd)->in_reloc_p (output_bfd, howto)
530 && !mcore_emit_base_file_entry (info, output_bfd, input_section,
531 rel->r_vaddr))
532 return FALSE;
b48499ec 533
252b5132
RH
534 switch (rstat)
535 {
536 default:
537 abort ();
b48499ec 538
252b5132
RH
539 case bfd_reloc_ok:
540 break;
b48499ec 541
252b5132
RH
542 case bfd_reloc_overflow:
543 if (! ((*info->callbacks->reloc_overflow)
dfeffb9f 544 (info, (h ? &h->root : NULL), my_name, howto->name,
252b5132
RH
545 (bfd_vma) 0, input_bfd,
546 input_section, rel->r_vaddr - input_section->vma)))
b34976b6 547 return FALSE;
252b5132 548 }
b48499ec 549 }
252b5132 550
b34976b6 551 return TRUE;
252b5132 552}
252b5132 553\f
b48499ec 554/* Tailor coffcode.h -- macro heaven. */
252b5132
RH
555
556/* We use the special COFF backend linker, with our own special touch. */
557
558#define coff_bfd_reloc_type_lookup mcore_coff_reloc_type_lookup
157090f7 559#define coff_bfd_reloc_name_lookup mcore_coff_reloc_name_lookup
252b5132
RH
560#define coff_relocate_section coff_mcore_relocate_section
561#define coff_rtype_to_howto coff_mcore_rtype_to_howto
562
563#define SELECT_RELOC(internal, howto) {internal.r_type = howto->type;}
564
dc12c51f
AM
565/* Make sure that the 'r_offset' field is copied properly
566 so that identical binaries will compare the same. */
567#define SWAP_IN_RELOC_OFFSET H_GET_32
568#define SWAP_OUT_RELOC_OFFSET H_PUT_32
569
252b5132
RH
570#define COFF_PAGE_SIZE 0x1000
571
572#include "coffcode.h"
573\f
5c4491d3 574/* Forward declaration to initialise alternative_target field. */
c3c89269 575extern const bfd_target TARGET_LITTLE_SYM;
252b5132 576
b48499ec 577/* The transfer vectors that lead the outside world to all of the above. */
60bcf0fa
NC
578CREATE_BIG_COFF_TARGET_VEC (TARGET_BIG_SYM, TARGET_BIG_NAME, D_PAGED,
579 (SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
3fa78519 580 0, & TARGET_LITTLE_SYM, COFF_SWAP_TABLE)
60bcf0fa
NC
581CREATE_LITTLE_COFF_TARGET_VEC (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, D_PAGED,
582 (SEC_CODE | SEC_DATA | SEC_DEBUGGING | SEC_READONLY | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
3fa78519 583 0, & TARGET_BIG_SYM, COFF_SWAP_TABLE)