1 /* BFD back-end for MIPS PE COFF files.
2 Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
3 Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
5 This file is part of BFD, the Binary File Descriptor library.
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 2 of the License, or
10 (at your option) any later version.
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.
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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #define COFF_LONG_SECTION_NAMES
23 #define PCRELOFFSET true
29 #include "coff/mipspe.h"
31 #include "coff/internal.h"
37 static bfd_reloc_status_type coff_mips_reloc
38 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
39 static reloc_howto_type
*coff_mips_rtype_to_howto
40 PARAMS ((bfd
*, asection
*, struct internal_reloc
*,
41 struct coff_link_hash_entry
*, struct internal_syment
*,
45 static void mips_ecoff_swap_reloc_in
PARAMS ((bfd
*, PTR
,
46 struct internal_reloc
*));
47 static void mips_ecoff_swap_reloc_out
PARAMS ((bfd
*,
48 const struct internal_reloc
*,
50 static void mips_adjust_reloc_in
PARAMS ((bfd
*,
51 const struct internal_reloc
*,
53 static void mips_adjust_reloc_out
PARAMS ((bfd
*, const arelent
*,
54 struct internal_reloc
*));
56 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
57 /* The page size is a guess based on ELF. */
59 #define COFF_PAGE_SIZE 0x1000
61 /* For some reason when using mips COFF the value stored in the .text
62 section for a reference to a common symbol is the value itself plus
63 any desired offset. Ian Taylor, Cygnus Support. */
65 /* If we are producing relocateable output, we need to do some
66 adjustments to the object file that are not done by the
67 bfd_perform_relocation function. This function is called by every
68 reloc type to make any required adjustments. */
70 static bfd_reloc_status_type
71 coff_mips_reloc (abfd
, reloc_entry
, symbol
, data
, input_section
, output_bfd
,
77 asection
*input_section ATTRIBUTE_UNUSED
;
79 char **error_message ATTRIBUTE_UNUSED
;
83 if (output_bfd
== (bfd
*) NULL
)
84 return bfd_reloc_continue
;
86 if (bfd_is_com_section (symbol
->section
))
89 /* We are relocating a common symbol. The current value in the
90 object file is ORIG + OFFSET, where ORIG is the value of the
91 common symbol as seen by the object file when it was compiled
92 (this may be zero if the symbol was undefined) and OFFSET is
93 the offset into the common symbol (normally zero, but may be
94 non-zero when referring to a field in a common structure).
95 ORIG is the negative of reloc_entry->addend, which is set by
96 the CALC_ADDEND macro below. We want to replace the value in
97 the object file with NEW + OFFSET, where NEW is the value of
98 the common symbol which we are going to put in the final
99 object file. NEW is symbol->value. */
100 diff
= symbol
->value
+ reloc_entry
->addend
;
102 /* In PE mode, we do not offset the common symbol. */
103 diff
= reloc_entry
->addend
;
108 /* For some reason bfd_perform_relocation always effectively
109 ignores the addend for a COFF target when producing
110 relocateable output. This seems to be always wrong for 386
111 COFF, so we handle the addend here instead. */
112 diff
= reloc_entry
->addend
;
117 /* dj - handle it like any other reloc? */
118 /* FIXME: How should this case be handled? */
119 if (reloc_entry
->howto
->type
== MIPS_R_RVA
&& diff
!= 0)
125 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & howto->dst_mask))
129 reloc_howto_type
*howto
= reloc_entry
->howto
;
130 unsigned char *addr
= (unsigned char *) data
+ reloc_entry
->address
;
136 char x
= bfd_get_8 (abfd
, addr
);
138 bfd_put_8 (abfd
, x
, addr
);
144 short x
= bfd_get_16 (abfd
, addr
);
146 bfd_put_16 (abfd
, x
, addr
);
152 long x
= bfd_get_32 (abfd
, addr
);
154 bfd_put_32 (abfd
, x
, addr
);
163 /* Now let bfd_perform_relocation finish everything up. */
164 return bfd_reloc_continue
;
168 /* Return true if this relocation should
169 appear in the output .reloc section. */
171 static boolean
in_reloc_p(abfd
, howto
)
172 bfd
* abfd ATTRIBUTE_UNUSED
;
173 reloc_howto_type
*howto
;
175 return ! howto
->pc_relative
&& howto
->type
!= MIPS_R_RVA
;
180 #define PCRELOFFSET false
183 static reloc_howto_type howto_table
[] =
185 /* Reloc type 0 is ignored. The reloc reading code ensures that
186 this is a reference to the .abs section, which will cause
187 bfd_perform_relocation to do nothing. */
188 HOWTO (MIPS_R_ABSOLUTE
, /* type */
190 0, /* size (0 = byte, 1 = short, 2 = long) */
192 false, /* pc_relative */
194 complain_overflow_dont
, /* complain_on_overflow */
195 0, /* special_function */
197 false, /* partial_inplace */
200 false), /* pcrel_offset */
202 /* A 16 bit reference to a symbol, normally from a data section. */
203 HOWTO (MIPS_R_REFHALF
, /* type */
205 1, /* size (0 = byte, 1 = short, 2 = long) */
207 false, /* pc_relative */
209 complain_overflow_bitfield
, /* complain_on_overflow */
210 coff_mips_reloc
, /* special_function */
211 "REFHALF", /* name */
212 true, /* partial_inplace */
213 0xffff, /* src_mask */
214 0xffff, /* dst_mask */
215 false), /* pcrel_offset */
217 /* A 32 bit reference to a symbol, normally from a data section. */
218 HOWTO (MIPS_R_REFWORD
, /* type */
220 2, /* size (0 = byte, 1 = short, 2 = long) */
222 false, /* pc_relative */
224 complain_overflow_bitfield
, /* complain_on_overflow */
225 coff_mips_reloc
, /* special_function */
226 "REFWORD", /* name */
227 true, /* partial_inplace */
228 0xffffffff, /* src_mask */
229 0xffffffff, /* dst_mask */
230 false), /* pcrel_offset */
232 /* A 26 bit absolute jump address. */
233 HOWTO (MIPS_R_JMPADDR
, /* type */
235 2, /* size (0 = byte, 1 = short, 2 = long) */
237 false, /* pc_relative */
239 complain_overflow_dont
, /* complain_on_overflow */
240 /* This needs complex overflow
241 detection, because the upper four
242 bits must match the PC. */
243 coff_mips_reloc
, /* special_function */
244 "JMPADDR", /* name */
245 true, /* partial_inplace */
246 0x3ffffff, /* src_mask */
247 0x3ffffff, /* dst_mask */
248 false), /* pcrel_offset */
250 /* The high 16 bits of a symbol value. Handled by the function
252 HOWTO (MIPS_R_REFHI
, /* type */
254 2, /* size (0 = byte, 1 = short, 2 = long) */
256 false, /* pc_relative */
258 complain_overflow_bitfield
, /* complain_on_overflow */
259 coff_mips_reloc
, /* special_function */
261 true, /* partial_inplace */
262 0xffff, /* src_mask */
263 0xffff, /* dst_mask */
264 false), /* pcrel_offset */
266 /* The low 16 bits of a symbol value. */
267 HOWTO (MIPS_R_REFLO
, /* type */
269 2, /* size (0 = byte, 1 = short, 2 = long) */
271 false, /* pc_relative */
273 complain_overflow_dont
, /* complain_on_overflow */
274 coff_mips_reloc
, /* special_function */
276 true, /* partial_inplace */
277 0xffff, /* src_mask */
278 0xffff, /* dst_mask */
279 false), /* pcrel_offset */
281 /* A reference to an offset from the gp register. Handled by the
282 function mips_gprel_reloc. */
283 HOWTO (MIPS_R_GPREL
, /* type */
285 2, /* size (0 = byte, 1 = short, 2 = long) */
287 false, /* pc_relative */
289 complain_overflow_signed
, /* complain_on_overflow */
290 coff_mips_reloc
, /* special_function */
292 true, /* partial_inplace */
293 0xffff, /* src_mask */
294 0xffff, /* dst_mask */
295 false), /* pcrel_offset */
297 /* A reference to a literal using an offset from the gp register.
298 Handled by the function mips_gprel_reloc. */
299 HOWTO (MIPS_R_LITERAL
, /* type */
301 2, /* size (0 = byte, 1 = short, 2 = long) */
303 false, /* pc_relative */
305 complain_overflow_signed
, /* complain_on_overflow */
306 coff_mips_reloc
, /* special_function */
307 "LITERAL", /* name */
308 true, /* partial_inplace */
309 0xffff, /* src_mask */
310 0xffff, /* dst_mask */
311 false), /* pcrel_offset */
339 HOWTO (MIPS_R_RVA
, /* type */
341 2, /* size (0 = byte, 1 = short, 2 = long) */
343 false, /* pc_relative */
345 complain_overflow_bitfield
, /* complain_on_overflow */
346 coff_mips_reloc
, /* special_function */
348 true, /* partial_inplace */
349 0xffffffff, /* src_mask */
350 0xffffffff, /* dst_mask */
351 false), /* pcrel_offset */
354 HOWTO (MIPS_R_PAIR
, /* type */
356 2, /* size (0 = byte, 1 = short, 2 = long) */
358 false, /* pc_relative */
360 complain_overflow_bitfield
, /* complain_on_overflow */
361 coff_mips_reloc
, /* special_function */
363 true, /* partial_inplace */
364 0xffffffff, /* src_mask */
365 0xffffffff, /* dst_mask */
366 false), /* pcrel_offset */
369 /* Turn a howto into a reloc nunmber */
371 #define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
372 #define BADMAG(x) MIPSBADMAG(x)
373 #define MIPS 1 /* Customize coffcode.h */
375 #define RTYPE2HOWTO(cache_ptr, dst) \
376 (cache_ptr)->howto = howto_table + (dst)->r_type;
378 /* Compute the addend of a reloc. If the reloc is to a common symbol,
379 the object file contains the value of the common symbol. By the
380 time this is called, the linker may be using a different symbol
381 from a different object file with a different value. Therefore, we
382 hack wildly to locate the original symbol from this file so that we
383 can make the correct adjustment. This macro sets coffsym to the
384 symbol from the original file, and uses it to set the addend value
385 correctly. If this is not a common symbol, the usual addend
386 calculation is done, except that an additional tweak is needed for
388 FIXME: This macro refers to symbols and asect; these are from the
389 calling function, not the macro arguments. */
391 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
393 coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
394 if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
395 coffsym = (obj_symbols (abfd) \
396 + (cache_ptr->sym_ptr_ptr - symbols)); \
398 coffsym = coff_symbol_from (abfd, ptr); \
399 if (coffsym != (coff_symbol_type *) NULL \
400 && coffsym->native->u.syment.n_scnum == 0) \
401 cache_ptr->addend = - coffsym->native->u.syment.n_value; \
402 else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
403 && ptr->section != (asection *) NULL) \
404 cache_ptr->addend = - (ptr->section->vma + ptr->value); \
406 cache_ptr->addend = 0; \
407 if (ptr && howto_table[reloc.r_type].pc_relative) \
408 cache_ptr->addend += asect->vma; \
411 /* Convert an rtype to howto for the COFF backend linker. */
413 static reloc_howto_type
*
414 coff_mips_rtype_to_howto (abfd
, sec
, rel
, h
, sym
, addendp
)
415 bfd
*abfd ATTRIBUTE_UNUSED
;
417 struct internal_reloc
*rel
;
418 struct coff_link_hash_entry
*h
;
419 struct internal_syment
*sym
;
423 reloc_howto_type
*howto
;
425 howto
= howto_table
+ rel
->r_type
;
431 if (howto
->pc_relative
)
432 *addendp
+= sec
->vma
;
434 if (sym
!= NULL
&& sym
->n_scnum
== 0 && sym
->n_value
!= 0)
436 /* This is a common symbol. The section contents include the
437 size (sym->n_value) as an addend. The relocate_section
438 function will be adding in the final value of the symbol. We
439 need to subtract out the current size in order to get the
442 BFD_ASSERT (h
!= NULL
);
445 /* I think we *do* want to bypass this. If we don't, I have
446 seen some data parameters get the wrong relocation address.
447 If I link two versions with and without this section bypassed
448 and then do a binary comparison, the addresses which are
449 different can be looked up in the map. The case in which
450 this section has been bypassed has addresses which correspond
451 to values I can find in the map. */
452 *addendp
-= sym
->n_value
;
457 /* If the output symbol is common (in which case this must be a
458 relocateable link), we need to add in the final size of the
460 if (h
!= NULL
&& h
->root
.type
== bfd_link_hash_common
)
461 *addendp
+= h
->root
.u
.c
.size
;
465 if (howto
->pc_relative
)
469 /* If the symbol is defined, then the generic code is going to
470 add back the symbol value in order to cancel out an
471 adjustment it made to the addend. However, we set the addend
472 to 0 at the start of this function. We need to adjust here,
473 to avoid the adjustment the generic code will make. FIXME:
474 This is getting a bit hackish. */
475 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
476 *addendp
-= sym
->n_value
;
479 if (rel
->r_type
== MIPS_R_RVA
)
481 *addendp
-= pe_data(sec
->output_section
->owner
)->pe_opthdr
.ImageBase
;
488 #define coff_rtype_to_howto coff_mips_rtype_to_howto
490 #define coff_bfd_reloc_type_lookup coff_mips_reloc_type_lookup
492 /* Get the howto structure for a generic reloc type. */
494 static reloc_howto_type
*
495 coff_mips_reloc_type_lookup (abfd
, code
)
496 bfd
*abfd ATTRIBUTE_UNUSED
;
497 bfd_reloc_code_real_type code
;
504 mips_type
= MIPS_R_REFHALF
;
508 mips_type
= MIPS_R_REFWORD
;
510 case BFD_RELOC_MIPS_JMP
:
511 mips_type
= MIPS_R_JMPADDR
;
513 case BFD_RELOC_HI16_S
:
514 mips_type
= MIPS_R_REFHI
;
517 mips_type
= MIPS_R_REFLO
;
519 case BFD_RELOC_MIPS_GPREL
:
520 mips_type
= MIPS_R_GPREL
;
522 case BFD_RELOC_MIPS_LITERAL
:
523 mips_type
= MIPS_R_LITERAL
;
526 case BFD_RELOC_16_PCREL_S2:
527 mips_type = MIPS_R_PCREL16;
529 case BFD_RELOC_PCREL_HI16_S:
530 mips_type = MIPS_R_RELHI;
532 case BFD_RELOC_PCREL_LO16:
533 mips_type = MIPS_R_RELLO;
535 case BFD_RELOC_GPREL32:
536 mips_type = MIPS_R_SWITCH;
540 mips_type
= MIPS_R_RVA
;
543 return (reloc_howto_type
*) NULL
;
546 return &howto_table
[mips_type
];
550 mips_swap_reloc_in (abfd
, src
, dst
)
555 static struct internal_reloc pair_prev
;
556 RELOC
*reloc_src
= (RELOC
*) src
;
557 struct internal_reloc
*reloc_dst
= (struct internal_reloc
*) dst
;
559 reloc_dst
->r_vaddr
= bfd_h_get_32(abfd
, (bfd_byte
*)reloc_src
->r_vaddr
);
560 reloc_dst
->r_symndx
=
561 bfd_h_get_signed_32(abfd
, (bfd_byte
*) reloc_src
->r_symndx
);
562 reloc_dst
->r_type
= bfd_h_get_16(abfd
, (bfd_byte
*) reloc_src
->r_type
);
563 reloc_dst
->r_size
= 0;
564 reloc_dst
->r_extern
= 0;
565 reloc_dst
->r_offset
= 0;
567 switch (reloc_dst
->r_type
)
570 pair_prev
= *reloc_dst
;
573 reloc_dst
->r_offset
= reloc_dst
->r_symndx
;
574 if (reloc_dst
->r_offset
& 0x8000)
575 reloc_dst
->r_offset
-= 0x10000;
576 /*printf ("dj: pair offset is %08x\n", reloc_dst->r_offset);*/
577 reloc_dst
->r_symndx
= pair_prev
.r_symndx
;
583 mips_swap_reloc_out (abfd
, src
, dst
)
588 static int prev_offset
= 1;
589 static bfd_vma prev_addr
= 0;
590 struct internal_reloc
*reloc_src
= (struct internal_reloc
*)src
;
591 struct external_reloc
*reloc_dst
= (struct external_reloc
*)dst
;
593 switch (reloc_src
->r_type
)
596 prev_addr
= reloc_src
->r_vaddr
;
597 prev_offset
= reloc_src
->r_offset
;
600 if (reloc_src
->r_vaddr
== prev_addr
)
602 /* FIXME: only slightly hackish. If we see a REFLO pointing to
603 the same address as a REFHI, we assume this is the matching
604 PAIR reloc and output it accordingly. The symndx is really
605 the low 16 bits of the addend */
606 bfd_h_put_32 (abfd
, reloc_src
->r_vaddr
,
607 (bfd_byte
*) reloc_dst
->r_vaddr
);
608 bfd_h_put_32 (abfd
, reloc_src
->r_symndx
,
609 (bfd_byte
*) reloc_dst
->r_symndx
);
611 bfd_h_put_16(abfd
, MIPS_R_PAIR
, (bfd_byte
*)
618 bfd_h_put_32(abfd
, reloc_src
->r_vaddr
, (bfd_byte
*) reloc_dst
->r_vaddr
);
619 bfd_h_put_32(abfd
, reloc_src
->r_symndx
, (bfd_byte
*) reloc_dst
->r_symndx
);
621 bfd_h_put_16(abfd
, reloc_src
->r_type
, (bfd_byte
*)
626 #define coff_swap_reloc_in mips_swap_reloc_in
627 #define coff_swap_reloc_out mips_swap_reloc_out
628 #define NO_COFF_RELOCS
631 coff_pe_mips_relocate_section (output_bfd
, info
, input_bfd
,
632 input_section
, contents
, relocs
, syms
,
635 struct bfd_link_info
*info
;
637 asection
*input_section
;
639 struct internal_reloc
*relocs
;
640 struct internal_syment
*syms
;
644 boolean gp_undefined
;
646 struct internal_reloc
*rel
;
647 struct internal_reloc
*rel_end
;
651 if (info
->relocateable
)
653 (*_bfd_error_handler
) (_("\
654 %s: `ld -r' not supported with PE MIPS objects\n"),
655 bfd_get_filename (input_bfd
));
656 bfd_set_error (bfd_error_bad_value
);
660 BFD_ASSERT (input_bfd
->xvec
->byteorder
661 == output_bfd
->xvec
->byteorder
);
664 printf ("dj: relocate %s(%s) %08x\n",
665 input_bfd
->filename
, input_section
->name
,
666 input_section
->output_section
->vma
+ input_section
->output_offset
);
669 gp
= _bfd_get_gp_value (output_bfd
);
673 gp_undefined
= false;
680 rel_end
= rel
+ input_section
->reloc_count
;
681 for (i
= 0; rel
< rel_end
; rel
++, i
++)
684 struct coff_link_hash_entry
*h
;
685 struct internal_syment
*sym
;
687 bfd_vma val
, tmp
, targ
, src
, low
;
688 reloc_howto_type
*howto
;
689 unsigned char *mem
= contents
+ rel
->r_vaddr
;
691 symndx
= rel
->r_symndx
;
700 h
= obj_coff_sym_hashes (input_bfd
)[symndx
];
704 /* COFF treats common symbols in one of two ways. Either the
705 size of the symbol is included in the section contents, or it
706 is not. We assume that the size is not included, and force
707 the rtype_to_howto function to adjust the addend as needed. */
709 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
710 addend
= - sym
->n_value
;
714 howto
= bfd_coff_rtype_to_howto (input_bfd
, input_section
, rel
, h
,
719 /* If we are doing a relocateable link, then we can just ignore
720 a PC relative reloc that is pcrel_offset. It will already
721 have the correct value. If this is not a relocateable link,
722 then we should ignore the symbol value. */
723 if (howto
->pc_relative
&& howto
->pcrel_offset
)
725 if (info
->relocateable
)
727 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
728 addend
+= sym
->n_value
;
739 sec
= bfd_abs_section_ptr
;
744 sec
= sections
[symndx
];
745 val
= (sec
->output_section
->vma
748 if (! obj_pe (input_bfd
))
754 if (h
->root
.type
== bfd_link_hash_defined
755 || h
->root
.type
== bfd_link_hash_defweak
)
759 sec
= h
->root
.u
.def
.section
;
760 val
= (h
->root
.u
.def
.value
761 + sec
->output_section
->vma
762 + sec
->output_offset
);
765 else if (! info
->relocateable
)
767 if (! ((*info
->callbacks
->undefined_symbol
)
768 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
769 rel
->r_vaddr
- input_section
->vma
, true)))
774 src
= rel
->r_vaddr
+ input_section
->output_section
->vma
775 + input_section
->output_offset
;
777 printf ("dj: reloc %02x %-8s a=%08x/%08x(%08x) v=%08x+%08x %s\n",
778 rel
->r_type
, howto_table
[rel
->r_type
].name
,
779 src
, rel
->r_vaddr
, *(unsigned long *)mem
, val
, rel
->r_offset
,
780 h
?h
->root
.root
.string
:"(none)");
783 /* OK, at this point the following variables are set up:
784 src = VMA of the memory we're fixing up
785 mem = pointer to memory we're fixing up
786 val = VMA of what we need to refer to
789 #define UI(x) (*_bfd_error_handler) (_("%s: unimplemented %s\n"), \
790 bfd_get_filename (input_bfd), x); \
791 bfd_set_error (bfd_error_bad_value);
795 case MIPS_R_ABSOLUTE
:
804 tmp
= bfd_get_32(input_bfd
, mem
);
805 /* printf ("refword: src=%08x targ=%08x+%08x\n", src, tmp, val); */
807 bfd_put_32(input_bfd
, tmp
, mem
);
811 tmp
= bfd_get_32(input_bfd
, mem
);
812 targ
= val
+ (tmp
&0x03ffffff)*4;
813 if ((src
& 0xf0000000) != (targ
& 0xf0000000))
815 (*_bfd_error_handler
) (_("%s: jump too far away\n"),
816 bfd_get_filename (input_bfd
));
817 bfd_set_error (bfd_error_bad_value
);
821 tmp
|= (targ
/4) & 0x3ffffff;
822 bfd_put_32(input_bfd
, tmp
, mem
);
826 tmp
= bfd_get_32(input_bfd
, mem
);
827 switch (rel
[1].r_type
)
831 targ
= val
+ rel
[1].r_offset
+ ((tmp
& 0xffff) << 16);
834 /* GNU COFF object */
835 low
= bfd_get_32(input_bfd
, contents
+ rel
[1].r_vaddr
);
839 targ
= val
+ low
+ ((tmp
& 0xffff) << 16);
842 (*_bfd_error_handler
) (_("%s: bad pair/reflo after refhi\n"),
843 bfd_get_filename (input_bfd
));
844 bfd_set_error (bfd_error_bad_value
);
848 tmp
|= (targ
>> 16) & 0xffff;
849 bfd_put_32(input_bfd
, tmp
, mem
);
853 tmp
= bfd_get_32(input_bfd
, mem
);
854 targ
= val
+ (tmp
& 0xffff);
855 /* printf ("refword: src=%08x targ=%08x\n", src, targ); */
857 tmp
|= targ
& 0xffff;
858 bfd_put_32(input_bfd
, tmp
, mem
);
874 case MIPS_R_SECRELLO
:
878 case MIPS_R_SECRELHI
:
883 tmp
= bfd_get_32 (input_bfd
, mem
);
884 /* printf ("rva: src=%08x targ=%08x+%08x\n", src, tmp, val); */
886 - pe_data (input_section
->output_section
->owner
)->pe_opthdr
.ImageBase
;
887 bfd_put_32 (input_bfd
, tmp
, mem
);
899 #define coff_relocate_section coff_pe_mips_relocate_section
901 #ifdef TARGET_UNDERSCORE
903 /* If mips gcc uses underscores for symbol names, then it does not use
904 a leading dot for local labels, so if TARGET_UNDERSCORE is defined
905 we treat all symbols starting with L as local. */
907 static boolean coff_mips_is_local_label_name
PARAMS ((bfd
*, const char *));
910 coff_mips_is_local_label_name (abfd
, name
)
917 return _bfd_coff_is_local_label_name (abfd
, name
);
920 #define coff_bfd_is_local_label_name coff_mips_is_local_label_name
922 #endif /* TARGET_UNDERSCORE */
924 #define COFF_NO_HACK_SCNHDR_SIZE
926 #include "coffcode.h"
938 "pe-mips", /* name */
940 bfd_target_coff_flavour
,
941 BFD_ENDIAN_LITTLE
, /* data byte order is little */
942 BFD_ENDIAN_LITTLE
, /* header byte order is little */
944 (HAS_RELOC
| EXEC_P
| /* object flags */
945 HAS_LINENO
| HAS_DEBUG
|
946 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
949 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
/* section flags */
950 | SEC_CODE
| SEC_DATA
),
952 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
/* section flags */
953 | SEC_CODE
| SEC_DATA
954 | SEC_LINK_ONCE
| SEC_LINK_DUPLICATES
),
957 #ifdef TARGET_UNDERSCORE
958 TARGET_UNDERSCORE
, /* leading underscore */
960 0, /* leading underscore */
962 '/', /* ar_pad_char */
963 15, /* ar_max_namelen */
965 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
966 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
967 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
968 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
969 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
970 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
972 /* Note that we allow an object file to be treated as a core file as well. */
973 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
974 bfd_generic_archive_p
, coff_object_p
},
975 {bfd_false
, coff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
977 {bfd_false
, coff_write_object_contents
, /* bfd_write_contents */
978 _bfd_write_archive_contents
, bfd_false
},
980 BFD_JUMP_TABLE_GENERIC (coff
),
981 BFD_JUMP_TABLE_COPY (coff
),
982 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
983 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
984 BFD_JUMP_TABLE_SYMBOLS (coff
),
985 BFD_JUMP_TABLE_RELOCS (coff
),
986 BFD_JUMP_TABLE_WRITE (coff
),
987 BFD_JUMP_TABLE_LINK (coff
),
988 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),