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