1 /* BFD back-end for MIPS PE COFF files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 Modified from coff-i386.c by DJ Delorie, dj@cygnus.com
6 This file is part of BFD, the Binary File Descriptor library.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #define COFF_LONG_SECTION_NAMES
24 #define PCRELOFFSET TRUE
30 #include "coff/mipspe.h"
32 #include "coff/internal.h"
38 static bfd_reloc_status_type coff_mips_reloc
39 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
40 static reloc_howto_type
*coff_mips_rtype_to_howto
41 PARAMS ((bfd
*, asection
*, struct internal_reloc
*,
42 struct coff_link_hash_entry
*, struct internal_syment
*,
45 static bfd_boolean in_reloc_p
46 PARAMS ((bfd
*, reloc_howto_type
*));
47 static reloc_howto_type
* coff_mips_reloc_type_lookup
48 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
49 static void mips_swap_reloc_in
50 PARAMS ((bfd
*, PTR
, PTR
));
51 static unsigned int mips_swap_reloc_out
52 PARAMS ((bfd
*, PTR
, PTR
));
53 static bfd_boolean coff_pe_mips_relocate_section
54 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
55 struct internal_reloc
*, struct internal_syment
*, asection
**));
57 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
58 /* The page size is a guess based on ELF. */
60 #define COFF_PAGE_SIZE 0x1000
62 /* For some reason when using mips COFF the value stored in the .text
63 section for a reference to a common symbol is the value itself plus
64 any desired offset. Ian Taylor, Cygnus Support. */
66 /* If we are producing relocatable output, we need to do some
67 adjustments to the object file that are not done by the
68 bfd_perform_relocation function. This function is called by every
69 reloc type to make any required adjustments. */
71 static bfd_reloc_status_type
72 coff_mips_reloc (abfd
, reloc_entry
, symbol
, data
, input_section
, output_bfd
,
78 asection
*input_section ATTRIBUTE_UNUSED
;
80 char **error_message ATTRIBUTE_UNUSED
;
84 if (output_bfd
== (bfd
*) NULL
)
85 return bfd_reloc_continue
;
87 if (bfd_is_com_section (symbol
->section
))
90 /* We are relocating a common symbol. The current value in the
91 object file is ORIG + OFFSET, where ORIG is the value of the
92 common symbol as seen by the object file when it was compiled
93 (this may be zero if the symbol was undefined) and OFFSET is
94 the offset into the common symbol (normally zero, but may be
95 non-zero when referring to a field in a common structure).
96 ORIG is the negative of reloc_entry->addend, which is set by
97 the CALC_ADDEND macro below. We want to replace the value in
98 the object file with NEW + OFFSET, where NEW is the value of
99 the common symbol which we are going to put in the final
100 object file. NEW is symbol->value. */
101 diff
= symbol
->value
+ reloc_entry
->addend
;
103 /* In PE mode, we do not offset the common symbol. */
104 diff
= reloc_entry
->addend
;
109 /* For some reason bfd_perform_relocation always effectively
110 ignores the addend for a COFF target when producing
111 relocatable output. This seems to be always wrong for 386
112 COFF, so we handle the addend here instead. */
113 diff
= reloc_entry
->addend
;
118 /* dj - handle it like any other reloc? */
119 /* FIXME: How should this case be handled? */
120 if (reloc_entry
->howto
->type
== MIPS_R_RVA
&& diff
!= 0)
126 x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + (diff >> howto->rightshift)) & howto->dst_mask))
130 reloc_howto_type
*howto
= reloc_entry
->howto
;
131 unsigned char *addr
= (unsigned char *) data
+ reloc_entry
->address
;
137 char x
= bfd_get_8 (abfd
, addr
);
139 bfd_put_8 (abfd
, x
, addr
);
145 short x
= bfd_get_16 (abfd
, addr
);
147 bfd_put_16 (abfd
, (bfd_vma
) x
, addr
);
153 long x
= bfd_get_32 (abfd
, addr
);
155 bfd_put_32 (abfd
, (bfd_vma
) x
, addr
);
164 /* Now let bfd_perform_relocation finish everything up. */
165 return bfd_reloc_continue
;
169 /* Return TRUE if this relocation should
170 appear in the output .reloc section. */
173 in_reloc_p (abfd
, howto
)
174 bfd
* abfd ATTRIBUTE_UNUSED
;
175 reloc_howto_type
*howto
;
177 return ! howto
->pc_relative
&& howto
->type
!= MIPS_R_RVA
;
182 #define PCRELOFFSET FALSE
185 static reloc_howto_type howto_table
[] =
187 /* Reloc type 0 is ignored. The reloc reading code ensures that
188 this is a reference to the .abs section, which will cause
189 bfd_perform_relocation to do nothing. */
190 HOWTO (MIPS_R_ABSOLUTE
, /* type */
192 0, /* size (0 = byte, 1 = short, 2 = long) */
194 FALSE
, /* pc_relative */
196 complain_overflow_dont
, /* complain_on_overflow */
197 0, /* special_function */
199 FALSE
, /* partial_inplace */
202 FALSE
), /* pcrel_offset */
204 /* A 16 bit reference to a symbol, normally from a data section. */
205 HOWTO (MIPS_R_REFHALF
, /* type */
207 1, /* size (0 = byte, 1 = short, 2 = long) */
209 FALSE
, /* pc_relative */
211 complain_overflow_bitfield
, /* complain_on_overflow */
212 coff_mips_reloc
, /* special_function */
213 "REFHALF", /* name */
214 TRUE
, /* partial_inplace */
215 0xffff, /* src_mask */
216 0xffff, /* dst_mask */
217 FALSE
), /* pcrel_offset */
219 /* A 32 bit reference to a symbol, normally from a data section. */
220 HOWTO (MIPS_R_REFWORD
, /* type */
222 2, /* size (0 = byte, 1 = short, 2 = long) */
224 FALSE
, /* pc_relative */
226 complain_overflow_bitfield
, /* complain_on_overflow */
227 coff_mips_reloc
, /* special_function */
228 "REFWORD", /* name */
229 TRUE
, /* partial_inplace */
230 0xffffffff, /* src_mask */
231 0xffffffff, /* dst_mask */
232 FALSE
), /* pcrel_offset */
234 /* A 26 bit absolute jump address. */
235 HOWTO (MIPS_R_JMPADDR
, /* type */
237 2, /* size (0 = byte, 1 = short, 2 = long) */
239 FALSE
, /* pc_relative */
241 complain_overflow_dont
, /* complain_on_overflow */
242 /* This needs complex overflow
243 detection, because the upper four
244 bits must match the PC. */
245 coff_mips_reloc
, /* special_function */
246 "JMPADDR", /* name */
247 TRUE
, /* partial_inplace */
248 0x3ffffff, /* src_mask */
249 0x3ffffff, /* dst_mask */
250 FALSE
), /* pcrel_offset */
252 /* The high 16 bits of a symbol value. Handled by the function
254 HOWTO (MIPS_R_REFHI
, /* type */
256 2, /* size (0 = byte, 1 = short, 2 = long) */
258 FALSE
, /* pc_relative */
260 complain_overflow_bitfield
, /* complain_on_overflow */
261 coff_mips_reloc
, /* special_function */
263 TRUE
, /* partial_inplace */
264 0xffff, /* src_mask */
265 0xffff, /* dst_mask */
266 FALSE
), /* pcrel_offset */
268 /* The low 16 bits of a symbol value. */
269 HOWTO (MIPS_R_REFLO
, /* type */
271 2, /* size (0 = byte, 1 = short, 2 = long) */
273 FALSE
, /* pc_relative */
275 complain_overflow_dont
, /* complain_on_overflow */
276 coff_mips_reloc
, /* special_function */
278 TRUE
, /* partial_inplace */
279 0xffff, /* src_mask */
280 0xffff, /* dst_mask */
281 FALSE
), /* pcrel_offset */
283 /* A reference to an offset from the gp register. Handled by the
284 function mips_gprel_reloc. */
285 HOWTO (MIPS_R_GPREL
, /* type */
287 2, /* size (0 = byte, 1 = short, 2 = long) */
289 FALSE
, /* pc_relative */
291 complain_overflow_signed
, /* complain_on_overflow */
292 coff_mips_reloc
, /* special_function */
294 TRUE
, /* partial_inplace */
295 0xffff, /* src_mask */
296 0xffff, /* dst_mask */
297 FALSE
), /* pcrel_offset */
299 /* A reference to a literal using an offset from the gp register.
300 Handled by the function mips_gprel_reloc. */
301 HOWTO (MIPS_R_LITERAL
, /* type */
303 2, /* size (0 = byte, 1 = short, 2 = long) */
305 FALSE
, /* pc_relative */
307 complain_overflow_signed
, /* complain_on_overflow */
308 coff_mips_reloc
, /* special_function */
309 "LITERAL", /* name */
310 TRUE
, /* partial_inplace */
311 0xffff, /* src_mask */
312 0xffff, /* dst_mask */
313 FALSE
), /* pcrel_offset */
341 HOWTO (MIPS_R_RVA
, /* type */
343 2, /* size (0 = byte, 1 = short, 2 = long) */
345 FALSE
, /* pc_relative */
347 complain_overflow_bitfield
, /* complain_on_overflow */
348 coff_mips_reloc
, /* special_function */
350 TRUE
, /* partial_inplace */
351 0xffffffff, /* src_mask */
352 0xffffffff, /* dst_mask */
353 FALSE
), /* pcrel_offset */
356 HOWTO (MIPS_R_PAIR
, /* type */
358 2, /* size (0 = byte, 1 = short, 2 = long) */
360 FALSE
, /* pc_relative */
362 complain_overflow_bitfield
, /* complain_on_overflow */
363 coff_mips_reloc
, /* special_function */
365 TRUE
, /* partial_inplace */
366 0xffffffff, /* src_mask */
367 0xffffffff, /* dst_mask */
368 FALSE
), /* pcrel_offset */
371 /* Turn a howto into a reloc nunmber */
373 #define SELECT_RELOC(x,howto) { x.r_type = howto->type; }
374 #define BADMAG(x) MIPSBADMAG(x)
375 #define MIPS 1 /* Customize coffcode.h */
377 #define RTYPE2HOWTO(cache_ptr, dst) \
378 (cache_ptr)->howto = howto_table + (dst)->r_type;
380 /* Compute the addend of a reloc. If the reloc is to a common symbol,
381 the object file contains the value of the common symbol. By the
382 time this is called, the linker may be using a different symbol
383 from a different object file with a different value. Therefore, we
384 hack wildly to locate the original symbol from this file so that we
385 can make the correct adjustment. This macro sets coffsym to the
386 symbol from the original file, and uses it to set the addend value
387 correctly. If this is not a common symbol, the usual addend
388 calculation is done, except that an additional tweak is needed for
390 FIXME: This macro refers to symbols and asect; these are from the
391 calling function, not the macro arguments. */
393 #define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
395 coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \
396 if (ptr && bfd_asymbol_bfd (ptr) != abfd) \
397 coffsym = (obj_symbols (abfd) \
398 + (cache_ptr->sym_ptr_ptr - symbols)); \
400 coffsym = coff_symbol_from (abfd, ptr); \
401 if (coffsym != (coff_symbol_type *) NULL \
402 && coffsym->native->u.syment.n_scnum == 0) \
403 cache_ptr->addend = - coffsym->native->u.syment.n_value; \
404 else if (ptr && bfd_asymbol_bfd (ptr) == abfd \
405 && ptr->section != (asection *) NULL) \
406 cache_ptr->addend = - (ptr->section->vma + ptr->value); \
408 cache_ptr->addend = 0; \
409 if (ptr && howto_table[reloc.r_type].pc_relative) \
410 cache_ptr->addend += asect->vma; \
413 /* Convert an rtype to howto for the COFF backend linker. */
415 static reloc_howto_type
*
416 coff_mips_rtype_to_howto (abfd
, sec
, rel
, h
, sym
, addendp
)
417 bfd
*abfd ATTRIBUTE_UNUSED
;
419 struct internal_reloc
*rel
;
420 struct coff_link_hash_entry
*h
;
421 struct internal_syment
*sym
;
425 reloc_howto_type
*howto
;
427 howto
= howto_table
+ rel
->r_type
;
433 if (howto
->pc_relative
)
434 *addendp
+= sec
->vma
;
436 if (sym
!= NULL
&& sym
->n_scnum
== 0 && sym
->n_value
!= 0)
438 /* This is a common symbol. The section contents include the
439 size (sym->n_value) as an addend. The relocate_section
440 function will be adding in the final value of the symbol. We
441 need to subtract out the current size in order to get the
444 BFD_ASSERT (h
!= NULL
);
447 /* I think we *do* want to bypass this. If we don't, I have
448 seen some data parameters get the wrong relocation address.
449 If I link two versions with and without this section bypassed
450 and then do a binary comparison, the addresses which are
451 different can be looked up in the map. The case in which
452 this section has been bypassed has addresses which correspond
453 to values I can find in the map. */
454 *addendp
-= sym
->n_value
;
459 /* If the output symbol is common (in which case this must be a
460 relocatable link), we need to add in the final size of the
462 if (h
!= NULL
&& h
->root
.type
== bfd_link_hash_common
)
463 *addendp
+= h
->root
.u
.c
.size
;
467 if (howto
->pc_relative
)
471 /* If the symbol is defined, then the generic code is going to
472 add back the symbol value in order to cancel out an
473 adjustment it made to the addend. However, we set the addend
474 to 0 at the start of this function. We need to adjust here,
475 to avoid the adjustment the generic code will make. FIXME:
476 This is getting a bit hackish. */
477 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
478 *addendp
-= sym
->n_value
;
481 if (rel
->r_type
== MIPS_R_RVA
)
483 *addendp
-= pe_data(sec
->output_section
->owner
)->pe_opthdr
.ImageBase
;
490 #define coff_rtype_to_howto coff_mips_rtype_to_howto
492 #define coff_bfd_reloc_type_lookup coff_mips_reloc_type_lookup
494 /* Get the howto structure for a generic reloc type. */
496 static reloc_howto_type
*
497 coff_mips_reloc_type_lookup (abfd
, code
)
498 bfd
*abfd ATTRIBUTE_UNUSED
;
499 bfd_reloc_code_real_type code
;
506 mips_type
= MIPS_R_REFHALF
;
510 mips_type
= MIPS_R_REFWORD
;
512 case BFD_RELOC_MIPS_JMP
:
513 mips_type
= MIPS_R_JMPADDR
;
515 case BFD_RELOC_HI16_S
:
516 mips_type
= MIPS_R_REFHI
;
519 mips_type
= MIPS_R_REFLO
;
521 case BFD_RELOC_GPREL16
:
522 mips_type
= MIPS_R_GPREL
;
524 case BFD_RELOC_MIPS_LITERAL
:
525 mips_type
= MIPS_R_LITERAL
;
528 mips_type
= MIPS_R_RVA
;
531 return (reloc_howto_type
*) NULL
;
534 return &howto_table
[mips_type
];
538 mips_swap_reloc_in (abfd
, src
, dst
)
543 static struct internal_reloc pair_prev
;
544 RELOC
*reloc_src
= (RELOC
*) src
;
545 struct internal_reloc
*reloc_dst
= (struct internal_reloc
*) dst
;
547 reloc_dst
->r_vaddr
= H_GET_32 (abfd
, reloc_src
->r_vaddr
);
548 reloc_dst
->r_symndx
= H_GET_S32 (abfd
, reloc_src
->r_symndx
);
549 reloc_dst
->r_type
= H_GET_16 (abfd
, reloc_src
->r_type
);
550 reloc_dst
->r_size
= 0;
551 reloc_dst
->r_extern
= 0;
552 reloc_dst
->r_offset
= 0;
554 switch (reloc_dst
->r_type
)
557 pair_prev
= *reloc_dst
;
560 reloc_dst
->r_offset
= reloc_dst
->r_symndx
;
561 if (reloc_dst
->r_offset
& 0x8000)
562 reloc_dst
->r_offset
-= 0x10000;
563 /*printf ("dj: pair offset is %08x\n", reloc_dst->r_offset);*/
564 reloc_dst
->r_symndx
= pair_prev
.r_symndx
;
570 mips_swap_reloc_out (abfd
, src
, dst
)
575 static int prev_offset
= 1;
576 static bfd_vma prev_addr
= 0;
577 struct internal_reloc
*reloc_src
= (struct internal_reloc
*)src
;
578 struct external_reloc
*reloc_dst
= (struct external_reloc
*)dst
;
580 switch (reloc_src
->r_type
)
583 prev_addr
= reloc_src
->r_vaddr
;
584 prev_offset
= reloc_src
->r_offset
;
587 if (reloc_src
->r_vaddr
== prev_addr
)
589 /* FIXME: only slightly hackish. If we see a REFLO pointing to
590 the same address as a REFHI, we assume this is the matching
591 PAIR reloc and output it accordingly. The symndx is really
592 the low 16 bits of the addend */
593 H_PUT_32 (abfd
, reloc_src
->r_vaddr
, reloc_dst
->r_vaddr
);
594 H_PUT_32 (abfd
, reloc_src
->r_symndx
, reloc_dst
->r_symndx
);
595 H_PUT_16 (abfd
, MIPS_R_PAIR
, reloc_dst
->r_type
);
601 H_PUT_32 (abfd
, reloc_src
->r_vaddr
, reloc_dst
->r_vaddr
);
602 H_PUT_32 (abfd
, reloc_src
->r_symndx
, reloc_dst
->r_symndx
);
604 H_PUT_16 (abfd
, reloc_src
->r_type
, reloc_dst
->r_type
);
608 #define coff_swap_reloc_in mips_swap_reloc_in
609 #define coff_swap_reloc_out mips_swap_reloc_out
610 #define NO_COFF_RELOCS
613 coff_pe_mips_relocate_section (output_bfd
, info
, input_bfd
,
614 input_section
, contents
, relocs
, syms
,
617 struct bfd_link_info
*info
;
619 asection
*input_section
;
621 struct internal_reloc
*relocs
;
622 struct internal_syment
*syms
;
626 bfd_boolean gp_undefined
;
628 struct internal_reloc
*rel
;
629 struct internal_reloc
*rel_end
;
633 if (info
->relocatable
)
635 (*_bfd_error_handler
)
636 (_("%B: `ld -r' not supported with PE MIPS objects\n"), input_bfd
);
637 bfd_set_error (bfd_error_bad_value
);
641 BFD_ASSERT (input_bfd
->xvec
->byteorder
642 == output_bfd
->xvec
->byteorder
);
645 printf ("dj: relocate %s(%s) %08x\n",
646 input_bfd
->filename
, input_section
->name
,
647 input_section
->output_section
->vma
+ input_section
->output_offset
);
650 gp
= _bfd_get_gp_value (output_bfd
);
654 gp_undefined
= FALSE
;
661 rel_end
= rel
+ input_section
->reloc_count
;
662 for (i
= 0; rel
< rel_end
; rel
++, i
++)
665 struct coff_link_hash_entry
*h
;
666 struct internal_syment
*sym
;
668 bfd_vma val
, tmp
, targ
, src
, low
;
669 reloc_howto_type
*howto
;
670 unsigned char *mem
= contents
+ rel
->r_vaddr
;
672 symndx
= rel
->r_symndx
;
681 h
= obj_coff_sym_hashes (input_bfd
)[symndx
];
685 /* COFF treats common symbols in one of two ways. Either the
686 size of the symbol is included in the section contents, or it
687 is not. We assume that the size is not included, and force
688 the rtype_to_howto function to adjust the addend as needed. */
690 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
691 addend
= - sym
->n_value
;
695 howto
= bfd_coff_rtype_to_howto (input_bfd
, input_section
, rel
, h
,
700 /* If we are doing a relocatable link, then we can just ignore
701 a PC relative reloc that is pcrel_offset. It will already
702 have the correct value. If this is not a relocatable link,
703 then we should ignore the symbol value. */
704 if (howto
->pc_relative
&& howto
->pcrel_offset
)
706 if (info
->relocatable
)
708 if (sym
!= NULL
&& sym
->n_scnum
!= 0)
709 addend
+= sym
->n_value
;
720 sec
= bfd_abs_section_ptr
;
725 sec
= sections
[symndx
];
726 val
= (sec
->output_section
->vma
729 if (! obj_pe (input_bfd
))
735 if (h
->root
.type
== bfd_link_hash_defined
736 || h
->root
.type
== bfd_link_hash_defweak
)
740 sec
= h
->root
.u
.def
.section
;
741 val
= (h
->root
.u
.def
.value
742 + sec
->output_section
->vma
743 + sec
->output_offset
);
746 else if (! info
->relocatable
)
748 if (! ((*info
->callbacks
->undefined_symbol
)
749 (info
, h
->root
.root
.string
, input_bfd
, input_section
,
750 rel
->r_vaddr
- input_section
->vma
, TRUE
)))
755 src
= rel
->r_vaddr
+ input_section
->output_section
->vma
756 + input_section
->output_offset
;
758 printf ("dj: reloc %02x %-8s a=%08x/%08x(%08x) v=%08x+%08x %s\n",
759 rel
->r_type
, howto_table
[rel
->r_type
].name
,
760 src
, rel
->r_vaddr
, *(unsigned long *)mem
, val
, rel
->r_offset
,
761 h
?h
->root
.root
.string
:"(none)");
764 /* OK, at this point the following variables are set up:
765 src = VMA of the memory we're fixing up
766 mem = pointer to memory we're fixing up
767 val = VMA of what we need to refer to
770 #define UI(x) (*_bfd_error_handler) (_("%B: unimplemented %s\n"), \
772 bfd_set_error (bfd_error_bad_value);
776 case MIPS_R_ABSOLUTE
:
785 tmp
= bfd_get_32(input_bfd
, mem
);
786 /* printf ("refword: src=%08x targ=%08x+%08x\n", src, tmp, val); */
788 bfd_put_32(input_bfd
, tmp
, mem
);
792 tmp
= bfd_get_32(input_bfd
, mem
);
793 targ
= val
+ (tmp
&0x03ffffff)*4;
794 if ((src
& 0xf0000000) != (targ
& 0xf0000000))
796 (*_bfd_error_handler
) (_("%B: jump too far away\n"), input_bfd
);
797 bfd_set_error (bfd_error_bad_value
);
801 tmp
|= (targ
/4) & 0x3ffffff;
802 bfd_put_32(input_bfd
, tmp
, mem
);
806 tmp
= bfd_get_32(input_bfd
, mem
);
807 switch (rel
[1].r_type
)
811 targ
= val
+ rel
[1].r_offset
+ ((tmp
& 0xffff) << 16);
814 /* GNU COFF object */
815 low
= bfd_get_32(input_bfd
, contents
+ rel
[1].r_vaddr
);
819 targ
= val
+ low
+ ((tmp
& 0xffff) << 16);
822 (*_bfd_error_handler
) (_("%B: bad pair/reflo after refhi\n"),
824 bfd_set_error (bfd_error_bad_value
);
828 tmp
|= (targ
>> 16) & 0xffff;
829 bfd_put_32(input_bfd
, tmp
, mem
);
833 tmp
= bfd_get_32(input_bfd
, mem
);
834 targ
= val
+ (tmp
& 0xffff);
835 /* printf ("refword: src=%08x targ=%08x\n", src, targ); */
837 tmp
|= targ
& 0xffff;
838 bfd_put_32(input_bfd
, tmp
, mem
);
854 case MIPS_R_SECRELLO
:
858 case MIPS_R_SECRELHI
:
863 tmp
= bfd_get_32 (input_bfd
, mem
);
864 /* printf ("rva: src=%08x targ=%08x+%08x\n", src, tmp, val); */
866 - pe_data (input_section
->output_section
->owner
)->pe_opthdr
.ImageBase
;
867 bfd_put_32 (input_bfd
, tmp
, mem
);
879 #define coff_relocate_section coff_pe_mips_relocate_section
881 #ifdef TARGET_UNDERSCORE
883 /* If mips gcc uses underscores for symbol names, then it does not use
884 a leading dot for local labels, so if TARGET_UNDERSCORE is defined
885 we treat all symbols starting with L as local. */
887 static bfd_boolean coff_mips_is_local_label_name
888 PARAMS ((bfd
*, const char *));
891 coff_mips_is_local_label_name (abfd
, name
)
898 return _bfd_coff_is_local_label_name (abfd
, name
);
901 #define coff_bfd_is_local_label_name coff_mips_is_local_label_name
903 #endif /* TARGET_UNDERSCORE */
905 #define COFF_NO_HACK_SCNHDR_SIZE
907 #include "coffcode.h"
919 "pe-mips", /* name */
921 bfd_target_coff_flavour
,
922 BFD_ENDIAN_LITTLE
, /* data byte order is little */
923 BFD_ENDIAN_LITTLE
, /* header byte order is little */
925 (HAS_RELOC
| EXEC_P
| /* object flags */
926 HAS_LINENO
| HAS_DEBUG
|
927 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| D_PAGED
),
930 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
/* section flags */
931 | SEC_CODE
| SEC_DATA
),
933 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
/* section flags */
934 | SEC_CODE
| SEC_DATA
935 | SEC_LINK_ONCE
| SEC_LINK_DUPLICATES
),
938 #ifdef TARGET_UNDERSCORE
939 TARGET_UNDERSCORE
, /* leading underscore */
941 0, /* leading underscore */
943 '/', /* ar_pad_char */
944 15, /* ar_max_namelen */
946 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
947 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
948 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
949 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
950 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
951 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
953 /* Note that we allow an object file to be treated as a core file as well. */
954 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
955 bfd_generic_archive_p
, coff_object_p
},
956 {bfd_false
, coff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
958 {bfd_false
, coff_write_object_contents
, /* bfd_write_contents */
959 _bfd_write_archive_contents
, bfd_false
},
961 BFD_JUMP_TABLE_GENERIC (coff
),
962 BFD_JUMP_TABLE_COPY (coff
),
963 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
964 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
965 BFD_JUMP_TABLE_SYMBOLS (coff
),
966 BFD_JUMP_TABLE_RELOCS (coff
),
967 BFD_JUMP_TABLE_WRITE (coff
),
968 BFD_JUMP_TABLE_LINK (coff
),
969 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),