1 /* Renesas RX specific support for 32-bit ELF.
2 Copyright (C) 2008, 2009, 2010, 2011
3 Free Software Foundation, Inc.
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 3 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. */
23 #include "bfd_stdint.h"
27 #include "libiberty.h"
29 #define RX_OPCODE_BIG_ENDIAN 0
31 /* This is a meta-target that's used only with objcopy, to avoid the
32 endian-swap we would otherwise get. We check for this in
34 const bfd_target bfd_elf32_rx_be_ns_vec
;
37 char * rx_get_reloc (long);
38 void rx_dump_symtab (bfd
*, void *, void *);
41 #define RXREL(n,sz,bit,shift,complain,pcrel) \
42 HOWTO (R_RX_##n, shift, sz, bit, pcrel, 0, complain_overflow_ ## complain, \
43 bfd_elf_generic_reloc, "R_RX_" #n, FALSE, 0, ~0, FALSE)
45 /* Note that the relocations around 0x7f are internal to this file;
46 feel free to move them as needed to avoid conflicts with published
47 relocation numbers. */
49 static reloc_howto_type rx_elf_howto_table
[] =
51 RXREL (NONE
, 0, 0, 0, dont
, FALSE
),
52 RXREL (DIR32
, 2, 32, 0, signed, FALSE
),
53 RXREL (DIR24S
, 2, 24, 0, signed, FALSE
),
54 RXREL (DIR16
, 1, 16, 0, dont
, FALSE
),
55 RXREL (DIR16U
, 1, 16, 0, unsigned, FALSE
),
56 RXREL (DIR16S
, 1, 16, 0, signed, FALSE
),
57 RXREL (DIR8
, 0, 8, 0, dont
, FALSE
),
58 RXREL (DIR8U
, 0, 8, 0, unsigned, FALSE
),
59 RXREL (DIR8S
, 0, 8, 0, signed, FALSE
),
60 RXREL (DIR24S_PCREL
, 2, 24, 0, signed, TRUE
),
61 RXREL (DIR16S_PCREL
, 1, 16, 0, signed, TRUE
),
62 RXREL (DIR8S_PCREL
, 0, 8, 0, signed, TRUE
),
63 RXREL (DIR16UL
, 1, 16, 2, unsigned, FALSE
),
64 RXREL (DIR16UW
, 1, 16, 1, unsigned, FALSE
),
65 RXREL (DIR8UL
, 0, 8, 2, unsigned, FALSE
),
66 RXREL (DIR8UW
, 0, 8, 1, unsigned, FALSE
),
67 RXREL (DIR32_REV
, 1, 16, 0, dont
, FALSE
),
68 RXREL (DIR16_REV
, 1, 16, 0, dont
, FALSE
),
69 RXREL (DIR3U_PCREL
, 0, 3, 0, dont
, TRUE
),
85 RXREL (RH_3_PCREL
, 0, 3, 0, signed, TRUE
),
86 RXREL (RH_16_OP
, 1, 16, 0, signed, FALSE
),
87 RXREL (RH_24_OP
, 2, 24, 0, signed, FALSE
),
88 RXREL (RH_32_OP
, 2, 32, 0, signed, FALSE
),
89 RXREL (RH_24_UNS
, 2, 24, 0, unsigned, FALSE
),
90 RXREL (RH_8_NEG
, 0, 8, 0, signed, FALSE
),
91 RXREL (RH_16_NEG
, 1, 16, 0, signed, FALSE
),
92 RXREL (RH_24_NEG
, 2, 24, 0, signed, FALSE
),
93 RXREL (RH_32_NEG
, 2, 32, 0, signed, FALSE
),
94 RXREL (RH_DIFF
, 2, 32, 0, signed, FALSE
),
95 RXREL (RH_GPRELB
, 1, 16, 0, unsigned, FALSE
),
96 RXREL (RH_GPRELW
, 1, 16, 0, unsigned, FALSE
),
97 RXREL (RH_GPRELL
, 1, 16, 0, unsigned, FALSE
),
98 RXREL (RH_RELAX
, 0, 0, 0, dont
, FALSE
),
120 RXREL (ABS32
, 2, 32, 0, dont
, FALSE
),
121 RXREL (ABS24S
, 2, 24, 0, signed, FALSE
),
122 RXREL (ABS16
, 1, 16, 0, dont
, FALSE
),
123 RXREL (ABS16U
, 1, 16, 0, unsigned, FALSE
),
124 RXREL (ABS16S
, 1, 16, 0, signed, FALSE
),
125 RXREL (ABS8
, 0, 8, 0, dont
, FALSE
),
126 RXREL (ABS8U
, 0, 8, 0, unsigned, FALSE
),
127 RXREL (ABS8S
, 0, 8, 0, signed, FALSE
),
128 RXREL (ABS24S_PCREL
, 2, 24, 0, signed, TRUE
),
129 RXREL (ABS16S_PCREL
, 1, 16, 0, signed, TRUE
),
130 RXREL (ABS8S_PCREL
, 0, 8, 0, signed, TRUE
),
131 RXREL (ABS16UL
, 1, 16, 0, unsigned, FALSE
),
132 RXREL (ABS16UW
, 1, 16, 0, unsigned, FALSE
),
133 RXREL (ABS8UL
, 0, 8, 0, unsigned, FALSE
),
134 RXREL (ABS8UW
, 0, 8, 0, unsigned, FALSE
),
135 RXREL (ABS32_REV
, 2, 32, 0, dont
, FALSE
),
136 RXREL (ABS16_REV
, 1, 16, 0, dont
, FALSE
),
138 #define STACK_REL_P(x) ((x) <= R_RX_ABS16_REV && (x) >= R_RX_ABS32)
179 /* These are internal. */
180 /* A 5-bit unsigned displacement to a B/W/L address, at bit position 8/12. */
181 /* ---- ---- 4--- 3210. */
182 #define R_RX_RH_ABS5p8B 0x78
183 RXREL (RH_ABS5p8B
, 0, 0, 0, dont
, FALSE
),
184 #define R_RX_RH_ABS5p8W 0x79
185 RXREL (RH_ABS5p8W
, 0, 0, 0, dont
, FALSE
),
186 #define R_RX_RH_ABS5p8L 0x7a
187 RXREL (RH_ABS5p8L
, 0, 0, 0, dont
, FALSE
),
188 /* A 5-bit unsigned displacement to a B/W/L address, at bit position 5/12. */
189 /* ---- -432 1--- 0---. */
190 #define R_RX_RH_ABS5p5B 0x7b
191 RXREL (RH_ABS5p5B
, 0, 0, 0, dont
, FALSE
),
192 #define R_RX_RH_ABS5p5W 0x7c
193 RXREL (RH_ABS5p5W
, 0, 0, 0, dont
, FALSE
),
194 #define R_RX_RH_ABS5p5L 0x7d
195 RXREL (RH_ABS5p5L
, 0, 0, 0, dont
, FALSE
),
196 /* A 4-bit unsigned immediate at bit position 8. */
197 #define R_RX_RH_UIMM4p8 0x7e
198 RXREL (RH_UIMM4p8
, 0, 0, 0, dont
, FALSE
),
199 /* A 4-bit negative unsigned immediate at bit position 8. */
200 #define R_RX_RH_UNEG4p8 0x7f
201 RXREL (RH_UNEG4p8
, 0, 0, 0, dont
, FALSE
),
202 /* End of internal relocs. */
204 RXREL (SYM
, 2, 32, 0, dont
, FALSE
),
205 RXREL (OPneg
, 2, 32, 0, dont
, FALSE
),
206 RXREL (OPadd
, 2, 32, 0, dont
, FALSE
),
207 RXREL (OPsub
, 2, 32, 0, dont
, FALSE
),
208 RXREL (OPmul
, 2, 32, 0, dont
, FALSE
),
209 RXREL (OPdiv
, 2, 32, 0, dont
, FALSE
),
210 RXREL (OPshla
, 2, 32, 0, dont
, FALSE
),
211 RXREL (OPshra
, 2, 32, 0, dont
, FALSE
),
212 RXREL (OPsctsize
, 2, 32, 0, dont
, FALSE
),
213 RXREL (OPscttop
, 2, 32, 0, dont
, FALSE
),
214 RXREL (OPand
, 2, 32, 0, dont
, FALSE
),
215 RXREL (OPor
, 2, 32, 0, dont
, FALSE
),
216 RXREL (OPxor
, 2, 32, 0, dont
, FALSE
),
217 RXREL (OPnot
, 2, 32, 0, dont
, FALSE
),
218 RXREL (OPmod
, 2, 32, 0, dont
, FALSE
),
219 RXREL (OPromtop
, 2, 32, 0, dont
, FALSE
),
220 RXREL (OPramtop
, 2, 32, 0, dont
, FALSE
)
223 /* Map BFD reloc types to RX ELF reloc types. */
227 bfd_reloc_code_real_type bfd_reloc_val
;
228 unsigned int rx_reloc_val
;
231 static const struct rx_reloc_map rx_reloc_map
[] =
233 { BFD_RELOC_NONE
, R_RX_NONE
},
234 { BFD_RELOC_8
, R_RX_DIR8S
},
235 { BFD_RELOC_16
, R_RX_DIR16S
},
236 { BFD_RELOC_24
, R_RX_DIR24S
},
237 { BFD_RELOC_32
, R_RX_DIR32
},
238 { BFD_RELOC_RX_16_OP
, R_RX_DIR16
},
239 { BFD_RELOC_RX_DIR3U_PCREL
, R_RX_DIR3U_PCREL
},
240 { BFD_RELOC_8_PCREL
, R_RX_DIR8S_PCREL
},
241 { BFD_RELOC_16_PCREL
, R_RX_DIR16S_PCREL
},
242 { BFD_RELOC_24_PCREL
, R_RX_DIR24S_PCREL
},
243 { BFD_RELOC_RX_8U
, R_RX_DIR8U
},
244 { BFD_RELOC_RX_16U
, R_RX_DIR16U
},
245 { BFD_RELOC_RX_24U
, R_RX_RH_24_UNS
},
246 { BFD_RELOC_RX_NEG8
, R_RX_RH_8_NEG
},
247 { BFD_RELOC_RX_NEG16
, R_RX_RH_16_NEG
},
248 { BFD_RELOC_RX_NEG24
, R_RX_RH_24_NEG
},
249 { BFD_RELOC_RX_NEG32
, R_RX_RH_32_NEG
},
250 { BFD_RELOC_RX_DIFF
, R_RX_RH_DIFF
},
251 { BFD_RELOC_RX_GPRELB
, R_RX_RH_GPRELB
},
252 { BFD_RELOC_RX_GPRELW
, R_RX_RH_GPRELW
},
253 { BFD_RELOC_RX_GPRELL
, R_RX_RH_GPRELL
},
254 { BFD_RELOC_RX_RELAX
, R_RX_RH_RELAX
},
255 { BFD_RELOC_RX_SYM
, R_RX_SYM
},
256 { BFD_RELOC_RX_OP_SUBTRACT
, R_RX_OPsub
},
257 { BFD_RELOC_RX_OP_NEG
, R_RX_OPneg
},
258 { BFD_RELOC_RX_ABS8
, R_RX_ABS8
},
259 { BFD_RELOC_RX_ABS16
, R_RX_ABS16
},
260 { BFD_RELOC_RX_ABS16_REV
, R_RX_ABS16_REV
},
261 { BFD_RELOC_RX_ABS32
, R_RX_ABS32
},
262 { BFD_RELOC_RX_ABS32_REV
, R_RX_ABS32_REV
},
263 { BFD_RELOC_RX_ABS16UL
, R_RX_ABS16UL
},
264 { BFD_RELOC_RX_ABS16UW
, R_RX_ABS16UW
},
265 { BFD_RELOC_RX_ABS16U
, R_RX_ABS16U
}
268 #define BIGE(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
270 static reloc_howto_type
*
271 rx_reloc_type_lookup (bfd
* abfd ATTRIBUTE_UNUSED
,
272 bfd_reloc_code_real_type code
)
276 if (code
== BFD_RELOC_RX_32_OP
)
277 return rx_elf_howto_table
+ R_RX_DIR32
;
279 for (i
= ARRAY_SIZE (rx_reloc_map
); --i
;)
280 if (rx_reloc_map
[i
].bfd_reloc_val
== code
)
281 return rx_elf_howto_table
+ rx_reloc_map
[i
].rx_reloc_val
;
286 static reloc_howto_type
*
287 rx_reloc_name_lookup (bfd
* abfd ATTRIBUTE_UNUSED
, const char * r_name
)
291 for (i
= 0; i
< ARRAY_SIZE (rx_elf_howto_table
); i
++)
292 if (rx_elf_howto_table
[i
].name
!= NULL
293 && strcasecmp (rx_elf_howto_table
[i
].name
, r_name
) == 0)
294 return rx_elf_howto_table
+ i
;
299 /* Set the howto pointer for an RX ELF reloc. */
302 rx_info_to_howto_rela (bfd
* abfd ATTRIBUTE_UNUSED
,
304 Elf_Internal_Rela
* dst
)
308 r_type
= ELF32_R_TYPE (dst
->r_info
);
309 BFD_ASSERT (r_type
< (unsigned int) R_RX_max
);
310 cache_ptr
->howto
= rx_elf_howto_table
+ r_type
;
314 get_symbol_value (const char * name
,
315 bfd_reloc_status_type
* status
,
316 struct bfd_link_info
* info
,
318 asection
* input_section
,
322 struct bfd_link_hash_entry
* h
;
324 h
= bfd_link_hash_lookup (info
->hash
, name
, FALSE
, FALSE
, TRUE
);
327 || (h
->type
!= bfd_link_hash_defined
328 && h
->type
!= bfd_link_hash_defweak
))
329 * status
= info
->callbacks
->undefined_symbol
330 (info
, name
, input_bfd
, input_section
, offset
, TRUE
);
332 value
= (h
->u
.def
.value
333 + h
->u
.def
.section
->output_section
->vma
334 + h
->u
.def
.section
->output_offset
);
340 get_gp (bfd_reloc_status_type
* status
,
341 struct bfd_link_info
* info
,
346 static bfd_boolean cached
= FALSE
;
347 static bfd_vma cached_value
= 0;
351 cached_value
= get_symbol_value ("__gp", status
, info
, abfd
, sec
, offset
);
358 get_romstart (bfd_reloc_status_type
* status
,
359 struct bfd_link_info
* info
,
364 static bfd_boolean cached
= FALSE
;
365 static bfd_vma cached_value
= 0;
369 cached_value
= get_symbol_value ("_start", status
, info
, abfd
, sec
, offset
);
376 get_ramstart (bfd_reloc_status_type
* status
,
377 struct bfd_link_info
* info
,
382 static bfd_boolean cached
= FALSE
;
383 static bfd_vma cached_value
= 0;
387 cached_value
= get_symbol_value ("__datastart", status
, info
, abfd
, sec
, offset
);
393 #define NUM_STACK_ENTRIES 16
394 static int32_t rx_stack
[ NUM_STACK_ENTRIES
];
395 static unsigned int rx_stack_top
;
397 #define RX_STACK_PUSH(val) \
400 if (rx_stack_top < NUM_STACK_ENTRIES) \
401 rx_stack [rx_stack_top ++] = (val); \
403 r = bfd_reloc_dangerous; \
407 #define RX_STACK_POP(dest) \
410 if (rx_stack_top > 0) \
411 (dest) = rx_stack [-- rx_stack_top]; \
413 (dest) = 0, r = bfd_reloc_dangerous; \
417 /* Relocate an RX ELF section.
418 There is some attempt to make this function usable for many architectures,
419 both USE_REL and USE_RELA ['twould be nice if such a critter existed],
420 if only to serve as a learning tool.
422 The RELOCATE_SECTION function is called by the new ELF backend linker
423 to handle the relocations for a section.
425 The relocs are always passed as Rela structures; if the section
426 actually uses Rel structures, the r_addend field will always be
429 This function is responsible for adjusting the section contents as
430 necessary, and (if using Rela relocs and generating a relocatable
431 output file) adjusting the reloc addend as necessary.
433 This function does not have to worry about setting the reloc
434 address or the reloc symbol index.
436 LOCAL_SYMS is a pointer to the swapped in local symbols.
438 LOCAL_SECTIONS is an array giving the section in the input file
439 corresponding to the st_shndx field of each local symbol.
441 The global hash table entry for the global symbols can be found
442 via elf_sym_hashes (input_bfd).
444 When generating relocatable output, this function must handle
445 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
446 going to be the section symbol corresponding to the output
447 section, which means that the addend must be adjusted
451 rx_elf_relocate_section
453 struct bfd_link_info
* info
,
455 asection
* input_section
,
457 Elf_Internal_Rela
* relocs
,
458 Elf_Internal_Sym
* local_syms
,
459 asection
** local_sections
)
461 Elf_Internal_Shdr
* symtab_hdr
;
462 struct elf_link_hash_entry
** sym_hashes
;
463 Elf_Internal_Rela
* rel
;
464 Elf_Internal_Rela
* relend
;
466 symtab_hdr
= & elf_tdata (input_bfd
)->symtab_hdr
;
467 sym_hashes
= elf_sym_hashes (input_bfd
);
468 relend
= relocs
+ input_section
->reloc_count
;
469 for (rel
= relocs
; rel
< relend
; rel
++)
471 reloc_howto_type
* howto
;
472 unsigned long r_symndx
;
473 Elf_Internal_Sym
* sym
;
475 struct elf_link_hash_entry
* h
;
477 bfd_reloc_status_type r
;
478 const char * name
= NULL
;
479 bfd_boolean unresolved_reloc
= TRUE
;
482 r_type
= ELF32_R_TYPE (rel
->r_info
);
483 r_symndx
= ELF32_R_SYM (rel
->r_info
);
485 howto
= rx_elf_howto_table
+ ELF32_R_TYPE (rel
->r_info
);
491 if (r_symndx
< symtab_hdr
->sh_info
)
493 sym
= local_syms
+ r_symndx
;
494 sec
= local_sections
[r_symndx
];
495 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, & sec
, rel
);
497 name
= bfd_elf_string_from_elf_section
498 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
);
499 name
= (sym
->st_name
== 0) ? bfd_section_name (input_bfd
, sec
) : name
;
505 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
506 r_symndx
, symtab_hdr
, sym_hashes
, h
,
507 sec
, relocation
, unresolved_reloc
,
510 name
= h
->root
.root
.string
;
513 if (sec
!= NULL
&& elf_discarded_section (sec
))
514 RELOC_AGAINST_DISCARDED_SECTION (info
, input_bfd
, input_section
,
515 rel
, relend
, howto
, contents
);
517 if (info
->relocatable
)
519 /* This is a relocatable link. We don't have to change
520 anything, unless the reloc is against a section symbol,
521 in which case we have to adjust according to where the
522 section symbol winds up in the output section. */
523 if (sym
!= NULL
&& ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
524 rel
->r_addend
+= sec
->output_offset
;
528 if (h
!= NULL
&& h
->root
.type
== bfd_link_hash_undefweak
)
529 /* If the symbol is undefined and weak
530 then the relocation resolves to zero. */
534 if (howto
->pc_relative
)
536 relocation
-= (input_section
->output_section
->vma
537 + input_section
->output_offset
539 if (r_type
!= R_RX_RH_3_PCREL
540 && r_type
!= R_RX_DIR3U_PCREL
)
544 relocation
+= rel
->r_addend
;
549 #define RANGE(a,b) if (a > (long) relocation || (long) relocation > b) r = bfd_reloc_overflow
550 #define ALIGN(m) if (relocation & m) r = bfd_reloc_other;
551 #define OP(i) (contents[rel->r_offset + (i)])
552 #define WARN_REDHAT(type) \
553 _bfd_error_handler (_("%B:%A: Warning: deprecated Red Hat reloc " type " detected against: %s."), \
554 input_bfd, input_section, name)
556 /* Opcode relocs are always big endian. Data relocs are bi-endian. */
565 case R_RX_RH_3_PCREL
:
566 WARN_REDHAT ("RX_RH_3_PCREL");
569 OP (0) |= relocation
& 0x07;
573 WARN_REDHAT ("RX_RH_8_NEG");
574 relocation
= - relocation
;
575 case R_RX_DIR8S_PCREL
:
591 WARN_REDHAT ("RX_RH_16_NEG");
592 relocation
= - relocation
;
593 case R_RX_DIR16S_PCREL
:
594 RANGE (-32768, 32767);
595 #if RX_OPCODE_BIG_ENDIAN
598 OP (1) = relocation
>> 8;
603 WARN_REDHAT ("RX_RH_16_OP");
604 RANGE (-32768, 32767);
605 #if RX_OPCODE_BIG_ENDIAN
607 OP (0) = relocation
>> 8;
610 OP (1) = relocation
>> 8;
615 RANGE (-32768, 65535);
616 if (BIGE (output_bfd
) && !(input_section
->flags
& SEC_CODE
))
619 OP (0) = relocation
>> 8;
624 OP (1) = relocation
>> 8;
630 #if RX_OPCODE_BIG_ENDIAN
632 OP (0) = relocation
>> 8;
635 OP (1) = relocation
>> 8;
640 RANGE (-32768, 65536);
641 #if RX_OPCODE_BIG_ENDIAN
643 OP (0) = relocation
>> 8;
646 OP (1) = relocation
>> 8;
651 RANGE (-32768, 65536);
652 #if RX_OPCODE_BIG_ENDIAN
654 OP (1) = relocation
>> 8;
657 OP (0) = relocation
>> 8;
661 case R_RX_DIR3U_PCREL
:
664 OP (0) |= relocation
& 0x07;
668 WARN_REDHAT ("RX_RH_24_NEG");
669 relocation
= - relocation
;
670 case R_RX_DIR24S_PCREL
:
671 RANGE (-0x800000, 0x7fffff);
672 #if RX_OPCODE_BIG_ENDIAN
674 OP (1) = relocation
>> 8;
675 OP (0) = relocation
>> 16;
678 OP (1) = relocation
>> 8;
679 OP (2) = relocation
>> 16;
684 WARN_REDHAT ("RX_RH_24_OP");
685 RANGE (-0x800000, 0x7fffff);
686 #if RX_OPCODE_BIG_ENDIAN
688 OP (1) = relocation
>> 8;
689 OP (0) = relocation
>> 16;
692 OP (1) = relocation
>> 8;
693 OP (2) = relocation
>> 16;
698 RANGE (-0x800000, 0x7fffff);
699 if (BIGE (output_bfd
) && !(input_section
->flags
& SEC_CODE
))
702 OP (1) = relocation
>> 8;
703 OP (0) = relocation
>> 16;
708 OP (1) = relocation
>> 8;
709 OP (2) = relocation
>> 16;
714 WARN_REDHAT ("RX_RH_24_UNS");
716 #if RX_OPCODE_BIG_ENDIAN
718 OP (1) = relocation
>> 8;
719 OP (0) = relocation
>> 16;
722 OP (1) = relocation
>> 8;
723 OP (2) = relocation
>> 16;
728 WARN_REDHAT ("RX_RH_32_NEG");
729 relocation
= - relocation
;
730 #if RX_OPCODE_BIG_ENDIAN
732 OP (2) = relocation
>> 8;
733 OP (1) = relocation
>> 16;
734 OP (0) = relocation
>> 24;
737 OP (1) = relocation
>> 8;
738 OP (2) = relocation
>> 16;
739 OP (3) = relocation
>> 24;
744 WARN_REDHAT ("RX_RH_32_OP");
745 #if RX_OPCODE_BIG_ENDIAN
747 OP (2) = relocation
>> 8;
748 OP (1) = relocation
>> 16;
749 OP (0) = relocation
>> 24;
752 OP (1) = relocation
>> 8;
753 OP (2) = relocation
>> 16;
754 OP (3) = relocation
>> 24;
759 if (BIGE (output_bfd
) && !(input_section
->flags
& SEC_CODE
))
762 OP (2) = relocation
>> 8;
763 OP (1) = relocation
>> 16;
764 OP (0) = relocation
>> 24;
769 OP (1) = relocation
>> 8;
770 OP (2) = relocation
>> 16;
771 OP (3) = relocation
>> 24;
776 if (BIGE (output_bfd
))
779 OP (1) = relocation
>> 8;
780 OP (2) = relocation
>> 16;
781 OP (3) = relocation
>> 24;
786 OP (2) = relocation
>> 8;
787 OP (1) = relocation
>> 16;
788 OP (0) = relocation
>> 24;
795 WARN_REDHAT ("RX_RH_DIFF");
796 val
= bfd_get_32 (output_bfd
, & OP (0));
798 bfd_put_32 (output_bfd
, val
, & OP (0));
803 WARN_REDHAT ("RX_RH_GPRELB");
804 relocation
-= get_gp (&r
, info
, input_bfd
, input_section
, rel
->r_offset
);
806 #if RX_OPCODE_BIG_ENDIAN
808 OP (0) = relocation
>> 8;
811 OP (1) = relocation
>> 8;
816 WARN_REDHAT ("RX_RH_GPRELW");
817 relocation
-= get_gp (&r
, info
, input_bfd
, input_section
, rel
->r_offset
);
821 #if RX_OPCODE_BIG_ENDIAN
823 OP (0) = relocation
>> 8;
826 OP (1) = relocation
>> 8;
831 WARN_REDHAT ("RX_RH_GPRELL");
832 relocation
-= get_gp (&r
, info
, input_bfd
, input_section
, rel
->r_offset
);
836 #if RX_OPCODE_BIG_ENDIAN
838 OP (0) = relocation
>> 8;
841 OP (1) = relocation
>> 8;
845 /* Internal relocations just for relaxation: */
846 case R_RX_RH_ABS5p5B
:
847 RX_STACK_POP (relocation
);
850 OP (0) |= relocation
>> 2;
852 OP (1) |= (relocation
<< 6) & 0x80;
853 OP (1) |= (relocation
<< 3) & 0x08;
856 case R_RX_RH_ABS5p5W
:
857 RX_STACK_POP (relocation
);
862 OP (0) |= relocation
>> 2;
864 OP (1) |= (relocation
<< 6) & 0x80;
865 OP (1) |= (relocation
<< 3) & 0x08;
868 case R_RX_RH_ABS5p5L
:
869 RX_STACK_POP (relocation
);
874 OP (0) |= relocation
>> 2;
876 OP (1) |= (relocation
<< 6) & 0x80;
877 OP (1) |= (relocation
<< 3) & 0x08;
880 case R_RX_RH_ABS5p8B
:
881 RX_STACK_POP (relocation
);
884 OP (0) |= (relocation
<< 3) & 0x80;
885 OP (0) |= relocation
& 0x0f;
888 case R_RX_RH_ABS5p8W
:
889 RX_STACK_POP (relocation
);
894 OP (0) |= (relocation
<< 3) & 0x80;
895 OP (0) |= relocation
& 0x0f;
898 case R_RX_RH_ABS5p8L
:
899 RX_STACK_POP (relocation
);
904 OP (0) |= (relocation
<< 3) & 0x80;
905 OP (0) |= relocation
& 0x0f;
908 case R_RX_RH_UIMM4p8
:
911 OP (0) |= relocation
<< 4;
914 case R_RX_RH_UNEG4p8
:
917 OP (0) |= (-relocation
) << 4;
920 /* Complex reloc handling: */
923 RX_STACK_POP (relocation
);
924 #if RX_OPCODE_BIG_ENDIAN
926 OP (2) = relocation
>> 8;
927 OP (1) = relocation
>> 16;
928 OP (0) = relocation
>> 24;
931 OP (1) = relocation
>> 8;
932 OP (2) = relocation
>> 16;
933 OP (3) = relocation
>> 24;
938 RX_STACK_POP (relocation
);
939 #if RX_OPCODE_BIG_ENDIAN
941 OP (1) = relocation
>> 8;
942 OP (2) = relocation
>> 16;
943 OP (3) = relocation
>> 24;
946 OP (2) = relocation
>> 8;
947 OP (1) = relocation
>> 16;
948 OP (0) = relocation
>> 24;
952 case R_RX_ABS24S_PCREL
:
954 RX_STACK_POP (relocation
);
955 RANGE (-0x800000, 0x7fffff);
956 if (BIGE (output_bfd
) && !(input_section
->flags
& SEC_CODE
))
959 OP (1) = relocation
>> 8;
960 OP (0) = relocation
>> 16;
965 OP (1) = relocation
>> 8;
966 OP (2) = relocation
>> 16;
971 RX_STACK_POP (relocation
);
972 RANGE (-32768, 65535);
973 #if RX_OPCODE_BIG_ENDIAN
975 OP (0) = relocation
>> 8;
978 OP (1) = relocation
>> 8;
983 RX_STACK_POP (relocation
);
984 RANGE (-32768, 65535);
985 #if RX_OPCODE_BIG_ENDIAN
987 OP (1) = relocation
>> 8;
990 OP (0) = relocation
>> 8;
994 case R_RX_ABS16S_PCREL
:
996 RX_STACK_POP (relocation
);
997 RANGE (-32768, 32767);
998 if (BIGE (output_bfd
) && !(input_section
->flags
& SEC_CODE
))
1000 OP (1) = relocation
;
1001 OP (0) = relocation
>> 8;
1005 OP (0) = relocation
;
1006 OP (1) = relocation
>> 8;
1011 RX_STACK_POP (relocation
);
1013 #if RX_OPCODE_BIG_ENDIAN
1014 OP (1) = relocation
;
1015 OP (0) = relocation
>> 8;
1017 OP (0) = relocation
;
1018 OP (1) = relocation
>> 8;
1023 RX_STACK_POP (relocation
);
1026 #if RX_OPCODE_BIG_ENDIAN
1027 OP (1) = relocation
;
1028 OP (0) = relocation
>> 8;
1030 OP (0) = relocation
;
1031 OP (1) = relocation
>> 8;
1036 RX_STACK_POP (relocation
);
1039 #if RX_OPCODE_BIG_ENDIAN
1040 OP (1) = relocation
;
1041 OP (0) = relocation
>> 8;
1043 OP (0) = relocation
;
1044 OP (1) = relocation
>> 8;
1049 RX_STACK_POP (relocation
);
1051 OP (0) = relocation
;
1055 RX_STACK_POP (relocation
);
1057 OP (0) = relocation
;
1061 RX_STACK_POP (relocation
);
1064 OP (0) = relocation
;
1068 RX_STACK_POP (relocation
);
1071 OP (0) = relocation
;
1074 case R_RX_ABS8S_PCREL
:
1076 RX_STACK_POP (relocation
);
1078 OP (0) = relocation
;
1082 if (r_symndx
< symtab_hdr
->sh_info
)
1083 RX_STACK_PUSH (sec
->output_section
->vma
1084 + sec
->output_offset
1089 && (h
->root
.type
== bfd_link_hash_defined
1090 || h
->root
.type
== bfd_link_hash_defweak
))
1091 RX_STACK_PUSH (h
->root
.u
.def
.value
1092 + sec
->output_section
->vma
1093 + sec
->output_offset
);
1095 _bfd_error_handler (_("Warning: RX_SYM reloc with an unknown symbol"));
1105 RX_STACK_PUSH (tmp
);
1113 RX_STACK_POP (tmp1
);
1114 RX_STACK_POP (tmp2
);
1116 RX_STACK_PUSH (tmp1
);
1124 RX_STACK_POP (tmp1
);
1125 RX_STACK_POP (tmp2
);
1127 RX_STACK_PUSH (tmp2
);
1135 RX_STACK_POP (tmp1
);
1136 RX_STACK_POP (tmp2
);
1138 RX_STACK_PUSH (tmp1
);
1146 RX_STACK_POP (tmp1
);
1147 RX_STACK_POP (tmp2
);
1149 RX_STACK_PUSH (tmp1
);
1157 RX_STACK_POP (tmp1
);
1158 RX_STACK_POP (tmp2
);
1160 RX_STACK_PUSH (tmp1
);
1168 RX_STACK_POP (tmp1
);
1169 RX_STACK_POP (tmp2
);
1171 RX_STACK_PUSH (tmp1
);
1175 case R_RX_OPsctsize
:
1176 RX_STACK_PUSH (input_section
->size
);
1180 RX_STACK_PUSH (input_section
->output_section
->vma
);
1187 RX_STACK_POP (tmp1
);
1188 RX_STACK_POP (tmp2
);
1190 RX_STACK_PUSH (tmp1
);
1198 RX_STACK_POP (tmp1
);
1199 RX_STACK_POP (tmp2
);
1201 RX_STACK_PUSH (tmp1
);
1209 RX_STACK_POP (tmp1
);
1210 RX_STACK_POP (tmp2
);
1212 RX_STACK_PUSH (tmp1
);
1222 RX_STACK_PUSH (tmp
);
1230 RX_STACK_POP (tmp1
);
1231 RX_STACK_POP (tmp2
);
1233 RX_STACK_PUSH (tmp1
);
1238 RX_STACK_PUSH (get_romstart (&r
, info
, input_bfd
, input_section
, rel
->r_offset
));
1242 RX_STACK_PUSH (get_ramstart (&r
, info
, input_bfd
, input_section
, rel
->r_offset
));
1246 r
= bfd_reloc_notsupported
;
1250 if (r
!= bfd_reloc_ok
)
1252 const char * msg
= NULL
;
1256 case bfd_reloc_overflow
:
1257 /* Catch the case of a missing function declaration
1258 and emit a more helpful error message. */
1259 if (r_type
== R_RX_DIR24S_PCREL
)
1260 msg
= _("%B(%A): error: call to undefined function '%s'");
1262 r
= info
->callbacks
->reloc_overflow
1263 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
, (bfd_vma
) 0,
1264 input_bfd
, input_section
, rel
->r_offset
);
1267 case bfd_reloc_undefined
:
1268 r
= info
->callbacks
->undefined_symbol
1269 (info
, name
, input_bfd
, input_section
, rel
->r_offset
,
1273 case bfd_reloc_other
:
1274 msg
= _("%B(%A): warning: unaligned access to symbol '%s' in the small data area");
1277 case bfd_reloc_outofrange
:
1278 msg
= _("%B(%A): internal error: out of range error");
1281 case bfd_reloc_notsupported
:
1282 msg
= _("%B(%A): internal error: unsupported relocation error");
1285 case bfd_reloc_dangerous
:
1286 msg
= _("%B(%A): internal error: dangerous relocation");
1290 msg
= _("%B(%A): internal error: unknown error");
1295 _bfd_error_handler (msg
, input_bfd
, input_section
, name
);
1305 /* Relaxation Support. */
1307 /* Progression of relocations from largest operand size to smallest
1311 next_smaller_reloc (int r
)
1315 case R_RX_DIR32
: return R_RX_DIR24S
;
1316 case R_RX_DIR24S
: return R_RX_DIR16S
;
1317 case R_RX_DIR16S
: return R_RX_DIR8S
;
1318 case R_RX_DIR8S
: return R_RX_NONE
;
1320 case R_RX_DIR16
: return R_RX_DIR8
;
1321 case R_RX_DIR8
: return R_RX_NONE
;
1323 case R_RX_DIR16U
: return R_RX_DIR8U
;
1324 case R_RX_DIR8U
: return R_RX_NONE
;
1326 case R_RX_DIR24S_PCREL
: return R_RX_DIR16S_PCREL
;
1327 case R_RX_DIR16S_PCREL
: return R_RX_DIR8S_PCREL
;
1328 case R_RX_DIR8S_PCREL
: return R_RX_DIR3U_PCREL
;
1330 case R_RX_DIR16UL
: return R_RX_DIR8UL
;
1331 case R_RX_DIR8UL
: return R_RX_NONE
;
1332 case R_RX_DIR16UW
: return R_RX_DIR8UW
;
1333 case R_RX_DIR8UW
: return R_RX_NONE
;
1335 case R_RX_RH_32_OP
: return R_RX_RH_24_OP
;
1336 case R_RX_RH_24_OP
: return R_RX_RH_16_OP
;
1337 case R_RX_RH_16_OP
: return R_RX_DIR8
;
1339 case R_RX_ABS32
: return R_RX_ABS24S
;
1340 case R_RX_ABS24S
: return R_RX_ABS16S
;
1341 case R_RX_ABS16
: return R_RX_ABS8
;
1342 case R_RX_ABS16U
: return R_RX_ABS8U
;
1343 case R_RX_ABS16S
: return R_RX_ABS8S
;
1344 case R_RX_ABS8
: return R_RX_NONE
;
1345 case R_RX_ABS8U
: return R_RX_NONE
;
1346 case R_RX_ABS8S
: return R_RX_NONE
;
1347 case R_RX_ABS24S_PCREL
: return R_RX_ABS16S_PCREL
;
1348 case R_RX_ABS16S_PCREL
: return R_RX_ABS8S_PCREL
;
1349 case R_RX_ABS8S_PCREL
: return R_RX_NONE
;
1350 case R_RX_ABS16UL
: return R_RX_ABS8UL
;
1351 case R_RX_ABS16UW
: return R_RX_ABS8UW
;
1352 case R_RX_ABS8UL
: return R_RX_NONE
;
1353 case R_RX_ABS8UW
: return R_RX_NONE
;
1358 /* Delete some bytes from a section while relaxing. */
1361 elf32_rx_relax_delete_bytes (bfd
*abfd
, asection
*sec
, bfd_vma addr
, int count
,
1362 Elf_Internal_Rela
*alignment_rel
, int force_snip
)
1364 Elf_Internal_Shdr
* symtab_hdr
;
1365 unsigned int sec_shndx
;
1366 bfd_byte
* contents
;
1367 Elf_Internal_Rela
* irel
;
1368 Elf_Internal_Rela
* irelend
;
1369 Elf_Internal_Sym
* isym
;
1370 Elf_Internal_Sym
* isymend
;
1372 unsigned int symcount
;
1373 struct elf_link_hash_entry
** sym_hashes
;
1374 struct elf_link_hash_entry
** end_hashes
;
1379 sec_shndx
= _bfd_elf_section_from_bfd_section (abfd
, sec
);
1381 contents
= elf_section_data (sec
)->this_hdr
.contents
;
1383 /* The deletion must stop at the next alignment boundary, if
1384 ALIGNMENT_REL is non-NULL. */
1387 toaddr
= alignment_rel
->r_offset
;
1389 irel
= elf_section_data (sec
)->relocs
;
1390 irelend
= irel
+ sec
->reloc_count
;
1392 /* Actually delete the bytes. */
1393 memmove (contents
+ addr
, contents
+ addr
+ count
,
1394 (size_t) (toaddr
- addr
- count
));
1396 /* If we don't have an alignment marker to worry about, we can just
1397 shrink the section. Otherwise, we have to fill in the newly
1398 created gap with NOP insns (0x03). */
1402 memset (contents
+ toaddr
- count
, 0x03, count
);
1404 /* Adjust all the relocs. */
1405 for (irel
= elf_section_data (sec
)->relocs
; irel
< irelend
; irel
++)
1407 /* Get the new reloc address. */
1408 if (irel
->r_offset
> addr
1409 && (irel
->r_offset
< toaddr
1410 || (force_snip
&& irel
->r_offset
== toaddr
)))
1411 irel
->r_offset
-= count
;
1413 /* If we see an ALIGN marker at the end of the gap, we move it
1414 to the beginning of the gap, since marking these gaps is what
1416 if (irel
->r_offset
== toaddr
1417 && ELF32_R_TYPE (irel
->r_info
) == R_RX_RH_RELAX
1418 && irel
->r_addend
& RX_RELAXA_ALIGN
)
1419 irel
->r_offset
-= count
;
1422 /* Adjust the local symbols defined in this section. */
1423 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1424 isym
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1425 isymend
= isym
+ symtab_hdr
->sh_info
;
1427 for (; isym
< isymend
; isym
++)
1429 /* If the symbol is in the range of memory we just moved, we
1430 have to adjust its value. */
1431 if (isym
->st_shndx
== sec_shndx
1432 && isym
->st_value
> addr
1433 && isym
->st_value
< toaddr
)
1434 isym
->st_value
-= count
;
1436 /* If the symbol *spans* the bytes we just deleted (i.e. it's
1437 *end* is in the moved bytes but it's *start* isn't), then we
1438 must adjust its size. */
1439 if (isym
->st_shndx
== sec_shndx
1440 && isym
->st_value
< addr
1441 && isym
->st_value
+ isym
->st_size
> addr
1442 && isym
->st_value
+ isym
->st_size
< toaddr
)
1443 isym
->st_size
-= count
;
1446 /* Now adjust the global symbols defined in this section. */
1447 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
1448 - symtab_hdr
->sh_info
);
1449 sym_hashes
= elf_sym_hashes (abfd
);
1450 end_hashes
= sym_hashes
+ symcount
;
1452 for (; sym_hashes
< end_hashes
; sym_hashes
++)
1454 struct elf_link_hash_entry
*sym_hash
= *sym_hashes
;
1456 if ((sym_hash
->root
.type
== bfd_link_hash_defined
1457 || sym_hash
->root
.type
== bfd_link_hash_defweak
)
1458 && sym_hash
->root
.u
.def
.section
== sec
)
1460 /* As above, adjust the value if needed. */
1461 if (sym_hash
->root
.u
.def
.value
> addr
1462 && sym_hash
->root
.u
.def
.value
< toaddr
)
1463 sym_hash
->root
.u
.def
.value
-= count
;
1465 /* As above, adjust the size if needed. */
1466 if (sym_hash
->root
.u
.def
.value
< addr
1467 && sym_hash
->root
.u
.def
.value
+ sym_hash
->size
> addr
1468 && sym_hash
->root
.u
.def
.value
+ sym_hash
->size
< toaddr
)
1469 sym_hash
->size
-= count
;
1476 /* Used to sort relocs by address. If relocs have the same address,
1477 we maintain their relative order, except that R_RX_RH_RELAX
1478 alignment relocs must be the first reloc for any given address. */
1481 reloc_bubblesort (Elf_Internal_Rela
* r
, int count
)
1485 bfd_boolean swappit
;
1487 /* This is almost a classic bubblesort. It's the slowest sort, but
1488 we're taking advantage of the fact that the relocations are
1489 mostly in order already (the assembler emits them that way) and
1490 we need relocs with the same address to remain in the same
1496 for (i
= 0; i
< count
- 1; i
++)
1498 if (r
[i
].r_offset
> r
[i
+ 1].r_offset
)
1500 else if (r
[i
].r_offset
< r
[i
+ 1].r_offset
)
1502 else if (ELF32_R_TYPE (r
[i
+ 1].r_info
) == R_RX_RH_RELAX
1503 && (r
[i
+ 1].r_addend
& RX_RELAXA_ALIGN
))
1505 else if (ELF32_R_TYPE (r
[i
+ 1].r_info
) == R_RX_RH_RELAX
1506 && (r
[i
+ 1].r_addend
& RX_RELAXA_ELIGN
)
1507 && !(ELF32_R_TYPE (r
[i
].r_info
) == R_RX_RH_RELAX
1508 && (r
[i
].r_addend
& RX_RELAXA_ALIGN
)))
1515 Elf_Internal_Rela tmp
;
1520 /* If we do move a reloc back, re-scan to see if it
1521 needs to be moved even further back. This avoids
1522 most of the O(n^2) behavior for our cases. */
1532 #define OFFSET_FOR_RELOC(rel, lrel, scale) \
1533 rx_offset_for_reloc (abfd, rel + 1, symtab_hdr, shndx_buf, intsyms, \
1534 lrel, abfd, sec, link_info, scale)
1537 rx_offset_for_reloc (bfd
* abfd
,
1538 Elf_Internal_Rela
* rel
,
1539 Elf_Internal_Shdr
* symtab_hdr
,
1540 Elf_External_Sym_Shndx
* shndx_buf ATTRIBUTE_UNUSED
,
1541 Elf_Internal_Sym
* intsyms
,
1542 Elf_Internal_Rela
** lrel
,
1544 asection
* input_section
,
1545 struct bfd_link_info
* info
,
1549 bfd_reloc_status_type r
;
1553 /* REL is the first of 1..N relocations. We compute the symbol
1554 value for each relocation, then combine them if needed. LREL
1555 gets a pointer to the last relocation used. */
1560 /* Get the value of the symbol referred to by the reloc. */
1561 if (ELF32_R_SYM (rel
->r_info
) < symtab_hdr
->sh_info
)
1563 /* A local symbol. */
1564 Elf_Internal_Sym
*isym
;
1567 isym
= intsyms
+ ELF32_R_SYM (rel
->r_info
);
1569 if (isym
->st_shndx
== SHN_UNDEF
)
1570 ssec
= bfd_und_section_ptr
;
1571 else if (isym
->st_shndx
== SHN_ABS
)
1572 ssec
= bfd_abs_section_ptr
;
1573 else if (isym
->st_shndx
== SHN_COMMON
)
1574 ssec
= bfd_com_section_ptr
;
1576 ssec
= bfd_section_from_elf_index (abfd
,
1579 /* Initial symbol value. */
1580 symval
= isym
->st_value
;
1582 /* GAS may have made this symbol relative to a section, in
1583 which case, we have to add the addend to find the
1585 if (ELF_ST_TYPE (isym
->st_info
) == STT_SECTION
)
1586 symval
+= rel
->r_addend
;
1590 if ((ssec
->flags
& SEC_MERGE
)
1591 && ssec
->sec_info_type
== ELF_INFO_TYPE_MERGE
)
1592 symval
= _bfd_merged_section_offset (abfd
, & ssec
,
1593 elf_section_data (ssec
)->sec_info
,
1597 /* Now make the offset relative to where the linker is putting it. */
1600 ssec
->output_section
->vma
+ ssec
->output_offset
;
1602 symval
+= rel
->r_addend
;
1607 struct elf_link_hash_entry
* h
;
1609 /* An external symbol. */
1610 indx
= ELF32_R_SYM (rel
->r_info
) - symtab_hdr
->sh_info
;
1611 h
= elf_sym_hashes (abfd
)[indx
];
1612 BFD_ASSERT (h
!= NULL
);
1614 if (h
->root
.type
!= bfd_link_hash_defined
1615 && h
->root
.type
!= bfd_link_hash_defweak
)
1617 /* This appears to be a reference to an undefined
1618 symbol. Just ignore it--it will be caught by the
1619 regular reloc processing. */
1625 symval
= (h
->root
.u
.def
.value
1626 + h
->root
.u
.def
.section
->output_section
->vma
1627 + h
->root
.u
.def
.section
->output_offset
);
1629 symval
+= rel
->r_addend
;
1632 switch (ELF32_R_TYPE (rel
->r_info
))
1635 RX_STACK_PUSH (symval
);
1639 RX_STACK_POP (tmp1
);
1641 RX_STACK_PUSH (tmp1
);
1645 RX_STACK_POP (tmp1
);
1646 RX_STACK_POP (tmp2
);
1648 RX_STACK_PUSH (tmp1
);
1652 RX_STACK_POP (tmp1
);
1653 RX_STACK_POP (tmp2
);
1655 RX_STACK_PUSH (tmp2
);
1659 RX_STACK_POP (tmp1
);
1660 RX_STACK_POP (tmp2
);
1662 RX_STACK_PUSH (tmp1
);
1666 RX_STACK_POP (tmp1
);
1667 RX_STACK_POP (tmp2
);
1669 RX_STACK_PUSH (tmp1
);
1673 RX_STACK_POP (tmp1
);
1674 RX_STACK_POP (tmp2
);
1676 RX_STACK_PUSH (tmp1
);
1680 RX_STACK_POP (tmp1
);
1681 RX_STACK_POP (tmp2
);
1683 RX_STACK_PUSH (tmp1
);
1686 case R_RX_OPsctsize
:
1687 RX_STACK_PUSH (input_section
->size
);
1691 RX_STACK_PUSH (input_section
->output_section
->vma
);
1695 RX_STACK_POP (tmp1
);
1696 RX_STACK_POP (tmp2
);
1698 RX_STACK_PUSH (tmp1
);
1702 RX_STACK_POP (tmp1
);
1703 RX_STACK_POP (tmp2
);
1705 RX_STACK_PUSH (tmp1
);
1709 RX_STACK_POP (tmp1
);
1710 RX_STACK_POP (tmp2
);
1712 RX_STACK_PUSH (tmp1
);
1716 RX_STACK_POP (tmp1
);
1718 RX_STACK_PUSH (tmp1
);
1722 RX_STACK_POP (tmp1
);
1723 RX_STACK_POP (tmp2
);
1725 RX_STACK_PUSH (tmp1
);
1729 RX_STACK_PUSH (get_romstart (&r
, info
, input_bfd
, input_section
, rel
->r_offset
));
1733 RX_STACK_PUSH (get_ramstart (&r
, info
, input_bfd
, input_section
, rel
->r_offset
));
1741 RX_STACK_POP (symval
);
1752 RX_STACK_POP (symval
);
1760 RX_STACK_POP (symval
);
1771 move_reloc (Elf_Internal_Rela
* irel
, Elf_Internal_Rela
* srel
, int delta
)
1773 bfd_vma old_offset
= srel
->r_offset
;
1776 while (irel
<= srel
)
1778 if (irel
->r_offset
== old_offset
)
1779 irel
->r_offset
+= delta
;
1784 /* Relax one section. */
1787 elf32_rx_relax_section (bfd
* abfd
,
1789 struct bfd_link_info
* link_info
,
1790 bfd_boolean
* again
,
1791 bfd_boolean allow_pcrel3
)
1793 Elf_Internal_Shdr
* symtab_hdr
;
1794 Elf_Internal_Shdr
* shndx_hdr
;
1795 Elf_Internal_Rela
* internal_relocs
;
1796 Elf_Internal_Rela
* free_relocs
= NULL
;
1797 Elf_Internal_Rela
* irel
;
1798 Elf_Internal_Rela
* srel
;
1799 Elf_Internal_Rela
* irelend
;
1800 Elf_Internal_Rela
* next_alignment
;
1801 Elf_Internal_Rela
* prev_alignment
;
1802 bfd_byte
* contents
= NULL
;
1803 bfd_byte
* free_contents
= NULL
;
1804 Elf_Internal_Sym
* intsyms
= NULL
;
1805 Elf_Internal_Sym
* free_intsyms
= NULL
;
1806 Elf_External_Sym_Shndx
* shndx_buf
= NULL
;
1812 int section_alignment_glue
;
1813 /* how much to scale the relocation by - 1, 2, or 4. */
1816 /* Assume nothing changes. */
1819 /* We don't have to do anything for a relocatable link, if
1820 this section does not have relocs, or if this is not a
1822 if (link_info
->relocatable
1823 || (sec
->flags
& SEC_RELOC
) == 0
1824 || sec
->reloc_count
== 0
1825 || (sec
->flags
& SEC_CODE
) == 0)
1828 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1829 shndx_hdr
= &elf_tdata (abfd
)->symtab_shndx_hdr
;
1831 sec_start
= sec
->output_section
->vma
+ sec
->output_offset
;
1833 /* Get the section contents. */
1834 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
1835 contents
= elf_section_data (sec
)->this_hdr
.contents
;
1836 /* Go get them off disk. */
1839 if (! bfd_malloc_and_get_section (abfd
, sec
, &contents
))
1841 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1844 /* Read this BFD's symbols. */
1845 /* Get cached copy if it exists. */
1846 if (symtab_hdr
->contents
!= NULL
)
1847 intsyms
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1850 intsyms
= bfd_elf_get_elf_syms (abfd
, symtab_hdr
, symtab_hdr
->sh_info
, 0, NULL
, NULL
, NULL
);
1851 symtab_hdr
->contents
= (bfd_byte
*) intsyms
;
1854 if (shndx_hdr
->sh_size
!= 0)
1858 amt
= symtab_hdr
->sh_info
;
1859 amt
*= sizeof (Elf_External_Sym_Shndx
);
1860 shndx_buf
= (Elf_External_Sym_Shndx
*) bfd_malloc (amt
);
1861 if (shndx_buf
== NULL
)
1863 if (bfd_seek (abfd
, shndx_hdr
->sh_offset
, SEEK_SET
) != 0
1864 || bfd_bread ((PTR
) shndx_buf
, amt
, abfd
) != amt
)
1866 shndx_hdr
->contents
= (bfd_byte
*) shndx_buf
;
1869 /* Get a copy of the native relocations. */
1870 internal_relocs
= (_bfd_elf_link_read_relocs
1871 (abfd
, sec
, (PTR
) NULL
, (Elf_Internal_Rela
*) NULL
,
1872 link_info
->keep_memory
));
1873 if (internal_relocs
== NULL
)
1875 if (! link_info
->keep_memory
)
1876 free_relocs
= internal_relocs
;
1878 /* The RL_ relocs must be just before the operand relocs they go
1879 with, so we must sort them to guarantee this. We use bubblesort
1880 instead of qsort so we can guarantee that relocs with the same
1881 address remain in the same relative order. */
1882 reloc_bubblesort (internal_relocs
, sec
->reloc_count
);
1884 /* Walk through them looking for relaxing opportunities. */
1885 irelend
= internal_relocs
+ sec
->reloc_count
;
1887 /* This will either be NULL or a pointer to the next alignment
1889 next_alignment
= internal_relocs
;
1890 /* This will be the previous alignment, although at first it points
1891 to the first real relocation. */
1892 prev_alignment
= internal_relocs
;
1894 /* We calculate worst case shrinkage caused by alignment directives.
1895 No fool-proof, but better than either ignoring the problem or
1896 doing heavy duty analysis of all the alignment markers in all
1898 section_alignment_glue
= 0;
1899 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
1900 if (ELF32_R_TYPE (irel
->r_info
) == R_RX_RH_RELAX
1901 && irel
->r_addend
& RX_RELAXA_ALIGN
)
1903 int this_glue
= 1 << (irel
->r_addend
& RX_RELAXA_ANUM
);
1905 if (section_alignment_glue
< this_glue
)
1906 section_alignment_glue
= this_glue
;
1908 /* Worst case is all 0..N alignments, in order, causing 2*N-1 byte
1910 section_alignment_glue
*= 2;
1912 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
1914 unsigned char *insn
;
1917 /* The insns we care about are all marked with one of these. */
1918 if (ELF32_R_TYPE (irel
->r_info
) != R_RX_RH_RELAX
)
1921 if (irel
->r_addend
& RX_RELAXA_ALIGN
1922 || next_alignment
== internal_relocs
)
1924 /* When we delete bytes, we need to maintain all the alignments
1925 indicated. In addition, we need to be careful about relaxing
1926 jumps across alignment boundaries - these displacements
1927 *grow* when we delete bytes. For now, don't shrink
1928 displacements across an alignment boundary, just in case.
1929 Note that this only affects relocations to the same
1931 prev_alignment
= next_alignment
;
1932 next_alignment
+= 2;
1933 while (next_alignment
< irelend
1934 && (ELF32_R_TYPE (next_alignment
->r_info
) != R_RX_RH_RELAX
1935 || !(next_alignment
->r_addend
& RX_RELAXA_ELIGN
)))
1937 if (next_alignment
>= irelend
|| next_alignment
->r_offset
== 0)
1938 next_alignment
= NULL
;
1941 /* When we hit alignment markers, see if we've shrunk enough
1942 before them to reduce the gap without violating the alignment
1944 if (irel
->r_addend
& RX_RELAXA_ALIGN
)
1946 /* At this point, the next relocation *should* be the ELIGN
1948 Elf_Internal_Rela
*erel
= irel
+ 1;
1949 unsigned int alignment
, nbytes
;
1951 if (ELF32_R_TYPE (erel
->r_info
) != R_RX_RH_RELAX
)
1953 if (!(erel
->r_addend
& RX_RELAXA_ELIGN
))
1956 alignment
= 1 << (irel
->r_addend
& RX_RELAXA_ANUM
);
1958 if (erel
->r_offset
- irel
->r_offset
< alignment
)
1961 nbytes
= erel
->r_offset
- irel
->r_offset
;
1962 nbytes
/= alignment
;
1963 nbytes
*= alignment
;
1965 elf32_rx_relax_delete_bytes (abfd
, sec
, erel
->r_offset
-nbytes
, nbytes
, next_alignment
,
1966 erel
->r_offset
== sec
->size
);
1972 if (irel
->r_addend
& RX_RELAXA_ELIGN
)
1975 insn
= contents
+ irel
->r_offset
;
1977 nrelocs
= irel
->r_addend
& RX_RELAXA_RNUM
;
1979 /* At this point, we have an insn that is a candidate for linker
1980 relaxation. There are NRELOCS relocs following that may be
1981 relaxed, although each reloc may be made of more than one
1982 reloc entry (such as gp-rel symbols). */
1984 /* Get the value of the symbol referred to by the reloc. Just
1985 in case this is the last reloc in the list, use the RL's
1986 addend to choose between this reloc (no addend) or the next
1987 (yes addend, which means at least one following reloc). */
1989 /* srel points to the "current" reloction for this insn -
1990 actually the last reloc for a given operand, which is the one
1991 we need to update. We check the relaxations in the same
1992 order that the relocations happen, so we'll just push it
1996 pc
= sec
->output_section
->vma
+ sec
->output_offset
2000 symval = OFFSET_FOR_RELOC (srel, &srel, &scale); \
2001 pcrel = symval - pc + srel->r_addend; \
2004 #define SNIPNR(offset, nbytes) \
2005 elf32_rx_relax_delete_bytes (abfd, sec, (insn - contents) + offset, nbytes, next_alignment, 0);
2006 #define SNIP(offset, nbytes, newtype) \
2007 SNIPNR (offset, nbytes); \
2008 srel->r_info = ELF32_R_INFO (ELF32_R_SYM (srel->r_info), newtype)
2010 /* The order of these bit tests must match the order that the
2011 relocs appear in. Since we sorted those by offset, we can
2014 /* Note that the numbers in, say, DSP6 are the bit offsets of
2015 the code fields that describe the operand. Bits number 0 for
2016 the MSB of insn[0]. */
2023 if (irel
->r_addend
& RX_RELAXA_DSP6
)
2028 if (code
== 2 && symval
/scale
<= 255)
2030 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2033 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2034 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2036 SNIP (3, 1, newrel
);
2041 else if (code
== 1 && symval
== 0)
2044 SNIP (2, 1, R_RX_NONE
);
2048 /* Special case DSP:5 format: MOV.bwl dsp:5[Rsrc],Rdst. */
2049 else if (code
== 1 && symval
/scale
<= 31
2050 /* Decodable bits. */
2051 && (insn
[0] & 0xcc) == 0xcc
2053 && (insn
[0] & 0x30) != 3
2054 /* Register MSBs. */
2055 && (insn
[1] & 0x88) == 0x00)
2059 insn
[0] = 0x88 | (insn
[0] & 0x30);
2060 /* The register fields are in the right place already. */
2062 /* We can't relax this new opcode. */
2065 switch ((insn
[0] & 0x30) >> 4)
2068 newrel
= R_RX_RH_ABS5p5B
;
2071 newrel
= R_RX_RH_ABS5p5W
;
2074 newrel
= R_RX_RH_ABS5p5L
;
2078 move_reloc (irel
, srel
, -2);
2079 SNIP (2, 1, newrel
);
2082 /* Special case DSP:5 format: MOVU.bw dsp:5[Rsrc],Rdst. */
2083 else if (code
== 1 && symval
/scale
<= 31
2084 /* Decodable bits. */
2085 && (insn
[0] & 0xf8) == 0x58
2086 /* Register MSBs. */
2087 && (insn
[1] & 0x88) == 0x00)
2091 insn
[0] = 0xb0 | ((insn
[0] & 0x04) << 1);
2092 /* The register fields are in the right place already. */
2094 /* We can't relax this new opcode. */
2097 switch ((insn
[0] & 0x08) >> 3)
2100 newrel
= R_RX_RH_ABS5p5B
;
2103 newrel
= R_RX_RH_ABS5p5W
;
2107 move_reloc (irel
, srel
, -2);
2108 SNIP (2, 1, newrel
);
2112 /* A DSP4 operand always follows a DSP6 operand, even if there's
2113 no relocation for it. We have to read the code out of the
2114 opcode to calculate the offset of the operand. */
2115 if (irel
->r_addend
& RX_RELAXA_DSP4
)
2117 int code6
, offset
= 0;
2121 code6
= insn
[0] & 0x03;
2124 case 0: offset
= 2; break;
2125 case 1: offset
= 3; break;
2126 case 2: offset
= 4; break;
2127 case 3: offset
= 2; break;
2130 code
= (insn
[0] & 0x0c) >> 2;
2132 if (code
== 2 && symval
/ scale
<= 255)
2134 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2138 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2139 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2141 SNIP (offset
+1, 1, newrel
);
2146 else if (code
== 1 && symval
== 0)
2149 SNIP (offset
, 1, R_RX_NONE
);
2152 /* Special case DSP:5 format: MOV.bwl Rsrc,dsp:5[Rdst] */
2153 else if (code
== 1 && symval
/scale
<= 31
2154 /* Decodable bits. */
2155 && (insn
[0] & 0xc3) == 0xc3
2157 && (insn
[0] & 0x30) != 3
2158 /* Register MSBs. */
2159 && (insn
[1] & 0x88) == 0x00)
2163 insn
[0] = 0x80 | (insn
[0] & 0x30);
2164 /* The register fields are in the right place already. */
2166 /* We can't relax this new opcode. */
2169 switch ((insn
[0] & 0x30) >> 4)
2172 newrel
= R_RX_RH_ABS5p5B
;
2175 newrel
= R_RX_RH_ABS5p5W
;
2178 newrel
= R_RX_RH_ABS5p5L
;
2182 move_reloc (irel
, srel
, -2);
2183 SNIP (2, 1, newrel
);
2187 /* These always occur alone, but the offset depends on whether
2188 it's a MEMEX opcode (0x06) or not. */
2189 if (irel
->r_addend
& RX_RELAXA_DSP14
)
2194 if (insn
[0] == 0x06)
2201 if (code
== 2 && symval
/ scale
<= 255)
2203 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2207 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2208 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2210 SNIP (offset
, 1, newrel
);
2214 else if (code
== 1 && symval
== 0)
2217 SNIP (offset
, 1, R_RX_NONE
);
2228 /* These always occur alone. */
2229 if (irel
->r_addend
& RX_RELAXA_IMM6
)
2235 /* These relocations sign-extend, so we must do signed compares. */
2236 ssymval
= (long) symval
;
2238 code
= insn
[0] & 0x03;
2240 if (code
== 0 && ssymval
<= 8388607 && ssymval
>= -8388608)
2242 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2246 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2247 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2249 SNIP (2, 1, newrel
);
2254 else if (code
== 3 && ssymval
<= 32767 && ssymval
>= -32768)
2256 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2260 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2261 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2263 SNIP (2, 1, newrel
);
2268 /* Special case UIMM8 format: CMP #uimm8,Rdst. */
2269 else if (code
== 2 && ssymval
<= 255 && ssymval
>= 16
2270 /* Decodable bits. */
2271 && (insn
[0] & 0xfc) == 0x74
2272 /* Decodable bits. */
2273 && ((insn
[1] & 0xf0) == 0x00))
2278 insn
[1] = 0x50 | (insn
[1] & 0x0f);
2280 /* We can't relax this new opcode. */
2283 if (STACK_REL_P (ELF32_R_TYPE (srel
->r_info
)))
2284 newrel
= R_RX_ABS8U
;
2286 newrel
= R_RX_DIR8U
;
2288 SNIP (2, 1, newrel
);
2292 else if (code
== 2 && ssymval
<= 127 && ssymval
>= -128)
2294 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2298 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2299 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2301 SNIP (2, 1, newrel
);
2306 /* Special case UIMM4 format: CMP, MUL, AND, OR. */
2307 else if (code
== 1 && ssymval
<= 15 && ssymval
>= 0
2308 /* Decodable bits and immediate type. */
2310 /* Decodable bits. */
2311 && (insn
[1] & 0xc0) == 0x00)
2313 static const int newop
[4] = { 1, 3, 4, 5 };
2315 insn
[0] = 0x60 | newop
[insn
[1] >> 4];
2316 /* The register number doesn't move. */
2318 /* We can't relax this new opcode. */
2321 move_reloc (irel
, srel
, -1);
2323 SNIP (2, 1, R_RX_RH_UIMM4p8
);
2327 /* Special case UIMM4 format: ADD -> ADD/SUB. */
2328 else if (code
== 1 && ssymval
<= 15 && ssymval
>= -15
2329 /* Decodable bits and immediate type. */
2331 /* Same register for source and destination. */
2332 && ((insn
[1] >> 4) == (insn
[1] & 0x0f)))
2336 /* Note that we can't turn "add $0,Rs" into a NOP
2337 because the flags need to be set right. */
2341 insn
[0] = 0x60; /* Subtract. */
2342 newrel
= R_RX_RH_UNEG4p8
;
2346 insn
[0] = 0x62; /* Add. */
2347 newrel
= R_RX_RH_UIMM4p8
;
2350 /* The register number is in the right place. */
2352 /* We can't relax this new opcode. */
2355 move_reloc (irel
, srel
, -1);
2357 SNIP (2, 1, newrel
);
2362 /* These are either matched with a DSP6 (2-byte base) or an id24
2364 if (irel
->r_addend
& RX_RELAXA_IMM12
)
2366 int dspcode
, offset
= 0;
2371 if ((insn
[0] & 0xfc) == 0xfc)
2372 dspcode
= 1; /* Just something with one byte operand. */
2374 dspcode
= insn
[0] & 3;
2377 case 0: offset
= 2; break;
2378 case 1: offset
= 3; break;
2379 case 2: offset
= 4; break;
2380 case 3: offset
= 2; break;
2383 /* These relocations sign-extend, so we must do signed compares. */
2384 ssymval
= (long) symval
;
2386 code
= (insn
[1] >> 2) & 3;
2387 if (code
== 0 && ssymval
<= 8388607 && ssymval
>= -8388608)
2389 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2393 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2394 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2396 SNIP (offset
, 1, newrel
);
2401 else if (code
== 3 && ssymval
<= 32767 && ssymval
>= -32768)
2403 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2407 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2408 if (newrel
!= ELF32_R_TYPE (srel
->r_info
))
2410 SNIP (offset
, 1, newrel
);
2415 /* Special case UIMM8 format: MOV #uimm8,Rdst. */
2416 else if (code
== 2 && ssymval
<= 255 && ssymval
>= 16
2417 /* Decodable bits. */
2419 /* Decodable bits. */
2420 && ((insn
[1] & 0x03) == 0x02))
2425 insn
[1] = 0x40 | (insn
[1] >> 4);
2427 /* We can't relax this new opcode. */
2430 if (STACK_REL_P (ELF32_R_TYPE (srel
->r_info
)))
2431 newrel
= R_RX_ABS8U
;
2433 newrel
= R_RX_DIR8U
;
2435 SNIP (2, 1, newrel
);
2439 else if (code
== 2 && ssymval
<= 127 && ssymval
>= -128)
2441 unsigned int newrel
= ELF32_R_TYPE(srel
->r_info
);
2445 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2446 if (newrel
!= ELF32_R_TYPE(srel
->r_info
))
2448 SNIP (offset
, 1, newrel
);
2453 /* Special case UIMM4 format: MOV #uimm4,Rdst. */
2454 else if (code
== 1 && ssymval
<= 15 && ssymval
>= 0
2455 /* Decodable bits. */
2457 /* Decodable bits. */
2458 && ((insn
[1] & 0x03) == 0x02))
2461 insn
[1] = insn
[1] >> 4;
2463 /* We can't relax this new opcode. */
2466 move_reloc (irel
, srel
, -1);
2468 SNIP (2, 1, R_RX_RH_UIMM4p8
);
2473 if (irel
->r_addend
& RX_RELAXA_BRA
)
2475 unsigned int newrel
= ELF32_R_TYPE (srel
->r_info
);
2477 int alignment_glue
= 0;
2481 /* Branches over alignment chunks are problematic, as
2482 deleting bytes here makes the branch *further* away. We
2483 can be agressive with branches within this alignment
2484 block, but not branches outside it. */
2485 if ((prev_alignment
== NULL
2486 || symval
< (bfd_vma
)(sec_start
+ prev_alignment
->r_offset
))
2487 && (next_alignment
== NULL
2488 || symval
> (bfd_vma
)(sec_start
+ next_alignment
->r_offset
)))
2489 alignment_glue
= section_alignment_glue
;
2491 if (ELF32_R_TYPE(srel
[1].r_info
) == R_RX_RH_RELAX
2492 && srel
[1].r_addend
& RX_RELAXA_BRA
2493 && srel
[1].r_offset
< irel
->r_offset
+ pcrel
)
2496 newrel
= next_smaller_reloc (ELF32_R_TYPE (srel
->r_info
));
2498 /* The values we compare PCREL with are not what you'd
2499 expect; they're off by a little to compensate for (1)
2500 where the reloc is relative to the insn, and (2) how much
2501 the insn is going to change when we relax it. */
2503 /* These we have to decode. */
2506 case 0x04: /* BRA pcdsp:24 */
2507 if (-32768 + alignment_glue
<= pcrel
2508 && pcrel
<= 32765 - alignment_glue
)
2511 SNIP (3, 1, newrel
);
2516 case 0x38: /* BRA pcdsp:16 */
2517 if (-128 + alignment_glue
<= pcrel
2518 && pcrel
<= 127 - alignment_glue
)
2521 SNIP (2, 1, newrel
);
2526 case 0x2e: /* BRA pcdsp:8 */
2527 /* Note that there's a risk here of shortening things so
2528 much that we no longer fit this reloc; it *should*
2529 only happen when you branch across a branch, and that
2530 branch also devolves into BRA.S. "Real" code should
2532 if (max_pcrel3
+ alignment_glue
<= pcrel
2533 && pcrel
<= 10 - alignment_glue
2537 SNIP (1, 1, newrel
);
2538 move_reloc (irel
, srel
, -1);
2543 case 0x05: /* BSR pcdsp:24 */
2544 if (-32768 + alignment_glue
<= pcrel
2545 && pcrel
<= 32765 - alignment_glue
)
2548 SNIP (1, 1, newrel
);
2553 case 0x3a: /* BEQ.W pcdsp:16 */
2554 case 0x3b: /* BNE.W pcdsp:16 */
2555 if (-128 + alignment_glue
<= pcrel
2556 && pcrel
<= 127 - alignment_glue
)
2558 insn
[0] = 0x20 | (insn
[0] & 1);
2559 SNIP (1, 1, newrel
);
2564 case 0x20: /* BEQ.B pcdsp:8 */
2565 case 0x21: /* BNE.B pcdsp:8 */
2566 if (max_pcrel3
+ alignment_glue
<= pcrel
2567 && pcrel
- alignment_glue
<= 10
2570 insn
[0] = 0x10 | ((insn
[0] & 1) << 3);
2571 SNIP (1, 1, newrel
);
2572 move_reloc (irel
, srel
, -1);
2577 case 0x16: /* synthetic BNE dsp24 */
2578 case 0x1e: /* synthetic BEQ dsp24 */
2579 if (-32767 + alignment_glue
<= pcrel
2580 && pcrel
<= 32766 - alignment_glue
2583 if (insn
[0] == 0x16)
2587 /* We snip out the bytes at the end else the reloc
2588 will get moved too, and too much. */
2589 SNIP (3, 2, newrel
);
2590 move_reloc (irel
, srel
, -1);
2596 /* Special case - synthetic conditional branches, pcrel24.
2597 Note that EQ and NE have been handled above. */
2598 if ((insn
[0] & 0xf0) == 0x20
2601 && srel
->r_offset
!= irel
->r_offset
+ 1
2602 && -32767 + alignment_glue
<= pcrel
2603 && pcrel
<= 32766 - alignment_glue
)
2607 SNIP (5, 1, newrel
);
2611 /* Special case - synthetic conditional branches, pcrel16 */
2612 if ((insn
[0] & 0xf0) == 0x20
2615 && srel
->r_offset
!= irel
->r_offset
+ 1
2616 && -127 + alignment_glue
<= pcrel
2617 && pcrel
<= 126 - alignment_glue
)
2619 int cond
= (insn
[0] & 0x0f) ^ 0x01;
2621 insn
[0] = 0x20 | cond
;
2622 /* By moving the reloc first, we avoid having
2623 delete_bytes move it also. */
2624 move_reloc (irel
, srel
, -2);
2625 SNIP (2, 3, newrel
);
2630 BFD_ASSERT (nrelocs
== 0);
2632 /* Special case - check MOV.bwl #IMM, dsp[reg] and see if we can
2633 use MOV.bwl #uimm:8, dsp:5[r7] format. This is tricky
2634 because it may have one or two relocations. */
2635 if ((insn
[0] & 0xfc) == 0xf8
2636 && (insn
[1] & 0x80) == 0x00
2637 && (insn
[0] & 0x03) != 0x03)
2639 int dcode
, icode
, reg
, ioff
, dscale
, ilen
;
2640 bfd_vma disp_val
= 0;
2642 Elf_Internal_Rela
* disp_rel
= 0;
2643 Elf_Internal_Rela
* imm_rel
= 0;
2648 dcode
= insn
[0] & 0x03;
2649 icode
= (insn
[1] >> 2) & 0x03;
2650 reg
= (insn
[1] >> 4) & 0x0f;
2652 ioff
= dcode
== 1 ? 3 : dcode
== 2 ? 4 : 2;
2654 /* Figure out what the dispacement is. */
2655 if (dcode
== 1 || dcode
== 2)
2657 /* There's a displacement. See if there's a reloc for it. */
2658 if (srel
[1].r_offset
== irel
->r_offset
+ 2)
2670 #if RX_OPCODE_BIG_ENDIAN
2671 disp_val
= insn
[2] * 256 + insn
[3];
2673 disp_val
= insn
[2] + insn
[3] * 256;
2676 switch (insn
[1] & 3)
2692 /* Figure out what the immediate is. */
2693 if (srel
[1].r_offset
== irel
->r_offset
+ ioff
)
2696 imm_val
= (long) symval
;
2701 unsigned char * ip
= insn
+ ioff
;
2706 /* For byte writes, we don't sign extend. Makes the math easier later. */
2710 imm_val
= (char) ip
[0];
2713 #if RX_OPCODE_BIG_ENDIAN
2714 imm_val
= ((char) ip
[0] << 8) | ip
[1];
2716 imm_val
= ((char) ip
[1] << 8) | ip
[0];
2720 #if RX_OPCODE_BIG_ENDIAN
2721 imm_val
= ((char) ip
[0] << 16) | (ip
[1] << 8) | ip
[2];
2723 imm_val
= ((char) ip
[2] << 16) | (ip
[1] << 8) | ip
[0];
2727 #if RX_OPCODE_BIG_ENDIAN
2728 imm_val
= (ip
[0] << 24) | (ip
[1] << 16) | (ip
[2] << 8) | ip
[3];
2730 imm_val
= (ip
[3] << 24) | (ip
[2] << 16) | (ip
[1] << 8) | ip
[0];
2764 /* The shortcut happens when the immediate is 0..255,
2765 register r0 to r7, and displacement (scaled) 0..31. */
2767 if (0 <= imm_val
&& imm_val
<= 255
2768 && 0 <= reg
&& reg
<= 7
2769 && disp_val
/ dscale
<= 31)
2771 insn
[0] = 0x3c | (insn
[1] & 0x03);
2772 insn
[1] = (((disp_val
/ dscale
) << 3) & 0x80) | (reg
<< 4) | ((disp_val
/dscale
) & 0x0f);
2777 int newrel
= R_RX_NONE
;
2782 newrel
= R_RX_RH_ABS5p8B
;
2785 newrel
= R_RX_RH_ABS5p8W
;
2788 newrel
= R_RX_RH_ABS5p8L
;
2791 disp_rel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (disp_rel
->r_info
), newrel
);
2792 move_reloc (irel
, disp_rel
, -1);
2796 imm_rel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (imm_rel
->r_info
), R_RX_DIR8U
);
2797 move_reloc (disp_rel
? disp_rel
: irel
,
2799 irel
->r_offset
- imm_rel
->r_offset
+ 2);
2802 SNIPNR (3, ilen
- 3);
2805 /* We can't relax this new opcode. */
2811 /* We can't reliably relax branches to DIR3U_PCREL unless we know
2812 whatever they're branching over won't shrink any more. If we're
2813 basically done here, do one more pass just for branches - but
2814 don't request a pass after that one! */
2815 if (!*again
&& !allow_pcrel3
)
2817 bfd_boolean ignored
;
2819 elf32_rx_relax_section (abfd
, sec
, link_info
, &ignored
, TRUE
);
2825 if (free_relocs
!= NULL
)
2828 if (free_contents
!= NULL
)
2829 free (free_contents
);
2831 if (shndx_buf
!= NULL
)
2833 shndx_hdr
->contents
= NULL
;
2837 if (free_intsyms
!= NULL
)
2838 free (free_intsyms
);
2844 elf32_rx_relax_section_wrapper (bfd
* abfd
,
2846 struct bfd_link_info
* link_info
,
2847 bfd_boolean
* again
)
2849 return elf32_rx_relax_section (abfd
, sec
, link_info
, again
, FALSE
);
2852 /* Function to set the ELF flag bits. */
2855 rx_elf_set_private_flags (bfd
* abfd
, flagword flags
)
2857 elf_elfheader (abfd
)->e_flags
= flags
;
2858 elf_flags_init (abfd
) = TRUE
;
2862 static bfd_boolean no_warn_mismatch
= FALSE
;
2863 static bfd_boolean ignore_lma
= TRUE
;
2865 void bfd_elf32_rx_set_target_flags (bfd_boolean
, bfd_boolean
);
2868 bfd_elf32_rx_set_target_flags (bfd_boolean user_no_warn_mismatch
,
2869 bfd_boolean user_ignore_lma
)
2871 no_warn_mismatch
= user_no_warn_mismatch
;
2872 ignore_lma
= user_ignore_lma
;
2875 /* Merge backend specific data from an object file to the output
2876 object file when linking. */
2879 rx_elf_merge_private_bfd_data (bfd
* ibfd
, bfd
* obfd
)
2883 bfd_boolean error
= FALSE
;
2885 new_flags
= elf_elfheader (ibfd
)->e_flags
;
2886 old_flags
= elf_elfheader (obfd
)->e_flags
;
2888 if (!elf_flags_init (obfd
))
2890 /* First call, no flags set. */
2891 elf_flags_init (obfd
) = TRUE
;
2892 elf_elfheader (obfd
)->e_flags
= new_flags
;
2894 else if (old_flags
!= new_flags
)
2896 flagword known_flags
= E_FLAG_RX_64BIT_DOUBLES
| E_FLAG_RX_DSP
;
2898 if ((old_flags
^ new_flags
) & known_flags
)
2900 /* Only complain if flag bits we care about do not match.
2901 Other bits may be set, since older binaries did use some
2902 deprecated flags. */
2903 if (no_warn_mismatch
)
2905 elf_elfheader (obfd
)->e_flags
= (new_flags
| old_flags
) & known_flags
;
2909 (*_bfd_error_handler
)
2910 ("ELF header flags mismatch: old_flags = 0x%.8lx, new_flags = 0x%.8lx, filename = %s",
2911 old_flags
, new_flags
, bfd_get_filename (ibfd
));
2916 elf_elfheader (obfd
)->e_flags
= new_flags
& known_flags
;
2920 bfd_set_error (bfd_error_bad_value
);
2926 rx_elf_print_private_bfd_data (bfd
* abfd
, void * ptr
)
2928 FILE * file
= (FILE *) ptr
;
2931 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
2933 /* Print normal ELF private data. */
2934 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
2936 flags
= elf_elfheader (abfd
)->e_flags
;
2937 fprintf (file
, _("private flags = 0x%lx:"), (long) flags
);
2939 if (flags
& E_FLAG_RX_64BIT_DOUBLES
)
2940 fprintf (file
, _(" [64-bit doubles]"));
2941 if (flags
& E_FLAG_RX_DSP
)
2942 fprintf (file
, _(" [dsp]"));
2948 /* Return the MACH for an e_flags value. */
2951 elf32_rx_machine (bfd
* abfd
)
2953 if ((elf_elfheader (abfd
)->e_flags
& EF_RX_CPU_MASK
) == EF_RX_CPU_RX
)
2960 rx_elf_object_p (bfd
* abfd
)
2964 Elf_Internal_Phdr
*phdr
= elf_tdata (abfd
)->phdr
;
2965 int nphdrs
= elf_elfheader (abfd
)->e_phnum
;
2968 /* We never want to automatically choose the non-swapping big-endian
2969 target. The user can only get that explicitly, such as with -I
2971 if (abfd
->xvec
== &bfd_elf32_rx_be_ns_vec
2972 && abfd
->target_defaulted
)
2975 bfd_default_set_arch_mach (abfd
, bfd_arch_rx
,
2976 elf32_rx_machine (abfd
));
2978 /* For each PHDR in the object, we must find some section that
2979 corresponds (based on matching file offsets) and use its VMA
2980 information to reconstruct the p_vaddr field we clobbered when we
2982 for (i
=0; i
<nphdrs
; i
++)
2984 for (u
=0; u
<elf_tdata(abfd
)->num_elf_sections
; u
++)
2986 Elf_Internal_Shdr
*sec
= elf_tdata(abfd
)->elf_sect_ptr
[u
];
2988 if (phdr
[i
].p_offset
<= (bfd_vma
) sec
->sh_offset
2989 && (bfd_vma
)sec
->sh_offset
<= phdr
[i
].p_offset
+ (phdr
[i
].p_filesz
- 1))
2991 /* Found one! The difference between the two addresses,
2992 plus the difference between the two file offsets, is
2993 enough information to reconstruct the lma. */
2995 /* Example where they aren't:
2996 PHDR[1] = lma fffc0100 offset 00002010 size 00000100
2997 SEC[6] = vma 00000050 offset 00002050 size 00000040
2999 The correct LMA for the section is fffc0140 + (2050-2010).
3002 phdr
[i
].p_vaddr
= sec
->sh_addr
+ (sec
->sh_offset
- phdr
[i
].p_offset
);
3007 /* We must update the bfd sections as well, so we don't stop
3009 bsec
= abfd
->sections
;
3012 if (phdr
[i
].p_vaddr
<= bsec
->lma
3013 && bsec
->vma
<= phdr
[i
].p_vaddr
+ (phdr
[i
].p_filesz
- 1))
3015 bsec
->lma
= phdr
[i
].p_paddr
+ (bsec
->vma
- phdr
[i
].p_vaddr
);
3027 rx_dump_symtab (bfd
* abfd
, void * internal_syms
, void * external_syms
)
3030 Elf_Internal_Sym
* isymbuf
;
3031 Elf_Internal_Sym
* isymend
;
3032 Elf_Internal_Sym
* isym
;
3033 Elf_Internal_Shdr
* symtab_hdr
;
3034 bfd_boolean free_internal
= FALSE
, free_external
= FALSE
;
3036 char * st_info_stb_str
;
3037 char * st_other_str
;
3038 char * st_shndx_str
;
3040 if (! internal_syms
)
3042 internal_syms
= bfd_malloc (1000);
3045 if (! external_syms
)
3047 external_syms
= bfd_malloc (1000);
3051 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
3052 locsymcount
= symtab_hdr
->sh_size
/ get_elf_backend_data (abfd
)->s
->sizeof_sym
;
3054 isymbuf
= bfd_elf_get_elf_syms (abfd
, symtab_hdr
,
3055 symtab_hdr
->sh_info
, 0,
3056 internal_syms
, external_syms
, NULL
);
3058 isymbuf
= internal_syms
;
3059 isymend
= isymbuf
+ locsymcount
;
3061 for (isym
= isymbuf
; isym
< isymend
; isym
++)
3063 switch (ELF_ST_TYPE (isym
->st_info
))
3065 case STT_FUNC
: st_info_str
= "STT_FUNC";
3066 case STT_SECTION
: st_info_str
= "STT_SECTION";
3067 case STT_FILE
: st_info_str
= "STT_FILE";
3068 case STT_OBJECT
: st_info_str
= "STT_OBJECT";
3069 case STT_TLS
: st_info_str
= "STT_TLS";
3070 default: st_info_str
= "";
3072 switch (ELF_ST_BIND (isym
->st_info
))
3074 case STB_LOCAL
: st_info_stb_str
= "STB_LOCAL";
3075 case STB_GLOBAL
: st_info_stb_str
= "STB_GLOBAL";
3076 default: st_info_stb_str
= "";
3078 switch (ELF_ST_VISIBILITY (isym
->st_other
))
3080 case STV_DEFAULT
: st_other_str
= "STV_DEFAULT";
3081 case STV_INTERNAL
: st_other_str
= "STV_INTERNAL";
3082 case STV_PROTECTED
: st_other_str
= "STV_PROTECTED";
3083 default: st_other_str
= "";
3085 switch (isym
->st_shndx
)
3087 case SHN_ABS
: st_shndx_str
= "SHN_ABS";
3088 case SHN_COMMON
: st_shndx_str
= "SHN_COMMON";
3089 case SHN_UNDEF
: st_shndx_str
= "SHN_UNDEF";
3090 default: st_shndx_str
= "";
3093 printf ("isym = %p st_value = %lx st_size = %lx st_name = (%lu) %s "
3094 "st_info = (%d) %s %s st_other = (%d) %s st_shndx = (%d) %s\n",
3096 (unsigned long) isym
->st_value
,
3097 (unsigned long) isym
->st_size
,
3099 bfd_elf_string_from_elf_section (abfd
, symtab_hdr
->sh_link
,
3101 isym
->st_info
, st_info_str
, st_info_stb_str
,
3102 isym
->st_other
, st_other_str
,
3103 isym
->st_shndx
, st_shndx_str
);
3106 free (internal_syms
);
3108 free (external_syms
);
3112 rx_get_reloc (long reloc
)
3114 if (0 <= reloc
&& reloc
< R_RX_max
)
3115 return rx_elf_howto_table
[reloc
].name
;
3121 /* We must take care to keep the on-disk copy of any code sections
3122 that are fully linked swapped if the target is big endian, to match
3123 the Renesas tools. */
3125 /* The rule is: big endian object that are final-link executables,
3126 have code sections stored with 32-bit words swapped relative to
3127 what you'd get by default. */
3130 rx_get_section_contents (bfd
* abfd
,
3134 bfd_size_type count
)
3136 int exec
= (abfd
->flags
& EXEC_P
) ? 1 : 0;
3137 int s_code
= (section
->flags
& SEC_CODE
) ? 1 : 0;
3141 fprintf (stderr
, "dj: get %ld %ld from %s %s e%d sc%d %08lx:%08lx\n",
3142 (long) offset
, (long) count
, section
->name
,
3143 bfd_big_endian(abfd
) ? "be" : "le",
3144 exec
, s_code
, (long unsigned) section
->filepos
,
3145 (long unsigned) offset
);
3148 if (exec
&& s_code
&& bfd_big_endian (abfd
))
3150 char * cloc
= (char *) location
;
3151 bfd_size_type cnt
, end_cnt
;
3155 /* Fetch and swap unaligned bytes at the beginning. */
3160 rv
= _bfd_generic_get_section_contents (abfd
, section
, buf
,
3165 bfd_putb32 (bfd_getl32 (buf
), buf
);
3167 cnt
= 4 - (offset
% 4);
3171 memcpy (location
, buf
+ (offset
% 4), cnt
);
3178 end_cnt
= count
% 4;
3180 /* Fetch and swap the middle bytes. */
3183 rv
= _bfd_generic_get_section_contents (abfd
, section
, cloc
, offset
,
3188 for (cnt
= count
; cnt
>= 4; cnt
-= 4, cloc
+= 4)
3189 bfd_putb32 (bfd_getl32 (cloc
), cloc
);
3192 /* Fetch and swap the end bytes. */
3197 /* Fetch the end bytes. */
3198 rv
= _bfd_generic_get_section_contents (abfd
, section
, buf
,
3199 offset
+ count
- end_cnt
, 4);
3203 bfd_putb32 (bfd_getl32 (buf
), buf
);
3204 memcpy (cloc
, buf
, end_cnt
);
3208 rv
= _bfd_generic_get_section_contents (abfd
, section
, location
, offset
, count
);
3215 rx2_set_section_contents (bfd
* abfd
,
3217 const void * location
,
3219 bfd_size_type count
)
3223 fprintf (stderr
, " set sec %s %08x loc %p offset %#x count %#x\n",
3224 section
->name
, (unsigned) section
->vma
, location
, (int) offset
, (int) count
);
3225 for (i
= 0; i
< count
; i
++)
3227 if (i
% 16 == 0 && i
> 0)
3228 fprintf (stderr
, "\n");
3230 if (i
% 16 && i
% 4 == 0)
3231 fprintf (stderr
, " ");
3234 fprintf (stderr
, " %08x:", (int) (section
->vma
+ offset
+ i
));
3236 fprintf (stderr
, " %02x", ((unsigned char *) location
)[i
]);
3238 fprintf (stderr
, "\n");
3240 return _bfd_elf_set_section_contents (abfd
, section
, location
, offset
, count
);
3242 #define _bfd_elf_set_section_contents rx2_set_section_contents
3246 rx_set_section_contents (bfd
* abfd
,
3248 const void * location
,
3250 bfd_size_type count
)
3252 bfd_boolean exec
= (abfd
->flags
& EXEC_P
) ? TRUE
: FALSE
;
3253 bfd_boolean s_code
= (section
->flags
& SEC_CODE
) ? TRUE
: FALSE
;
3255 char * swapped_data
= NULL
;
3257 bfd_vma caddr
= section
->vma
+ offset
;
3259 bfd_size_type scount
;
3264 fprintf (stderr
, "\ndj: set %ld %ld to %s %s e%d sc%d\n",
3265 (long) offset
, (long) count
, section
->name
,
3266 bfd_big_endian (abfd
) ? "be" : "le",
3269 for (i
= 0; i
< count
; i
++)
3271 int a
= section
->vma
+ offset
+ i
;
3273 if (a
% 16 == 0 && a
> 0)
3274 fprintf (stderr
, "\n");
3276 if (a
% 16 && a
% 4 == 0)
3277 fprintf (stderr
, " ");
3279 if (a
% 16 == 0 || i
== 0)
3280 fprintf (stderr
, " %08x:", (int) (section
->vma
+ offset
+ i
));
3282 fprintf (stderr
, " %02x", ((unsigned char *) location
)[i
]);
3285 fprintf (stderr
, "\n");
3288 if (! exec
|| ! s_code
|| ! bfd_big_endian (abfd
))
3289 return _bfd_elf_set_section_contents (abfd
, section
, location
, offset
, count
);
3291 while (count
> 0 && caddr
> 0 && caddr
% 4)
3295 case 0: faddr
= offset
+ 3; break;
3296 case 1: faddr
= offset
+ 1; break;
3297 case 2: faddr
= offset
- 1; break;
3298 case 3: faddr
= offset
- 3; break;
3301 rv
= _bfd_elf_set_section_contents (abfd
, section
, location
, faddr
, 1);
3311 scount
= (int)(count
/ 4) * 4;
3314 char * cloc
= (char *) location
;
3316 swapped_data
= (char *) bfd_alloc (abfd
, count
);
3318 for (i
= 0; i
< count
; i
+= 4)
3320 bfd_vma v
= bfd_getl32 (cloc
+ i
);
3321 bfd_putb32 (v
, swapped_data
+ i
);
3324 rv
= _bfd_elf_set_section_contents (abfd
, section
, swapped_data
, offset
, scount
);
3336 caddr
= section
->vma
+ offset
;
3341 case 0: faddr
= offset
+ 3; break;
3342 case 1: faddr
= offset
+ 1; break;
3343 case 2: faddr
= offset
- 1; break;
3344 case 3: faddr
= offset
- 3; break;
3346 rv
= _bfd_elf_set_section_contents (abfd
, section
, location
, faddr
, 1);
3361 rx_final_link (bfd
* abfd
, struct bfd_link_info
* info
)
3365 for (o
= abfd
->sections
; o
!= NULL
; o
= o
->next
)
3368 fprintf (stderr
, "sec %s fl %x vma %lx lma %lx size %lx raw %lx\n",
3369 o
->name
, o
->flags
, o
->vma
, o
->lma
, o
->size
, o
->rawsize
);
3371 if (o
->flags
& SEC_CODE
3372 && bfd_big_endian (abfd
)
3376 fprintf (stderr
, "adjusting...\n");
3378 o
->size
+= 4 - (o
->size
% 4);
3382 return bfd_elf_final_link (abfd
, info
);
3386 elf32_rx_modify_program_headers (bfd
* abfd ATTRIBUTE_UNUSED
,
3387 struct bfd_link_info
* info ATTRIBUTE_UNUSED
)
3389 const struct elf_backend_data
* bed
;
3390 struct elf_obj_tdata
* tdata
;
3391 Elf_Internal_Phdr
* phdr
;
3395 bed
= get_elf_backend_data (abfd
);
3396 tdata
= elf_tdata (abfd
);
3398 count
= tdata
->program_header_size
/ bed
->s
->sizeof_phdr
;
3401 for (i
= count
; i
-- != 0;)
3402 if (phdr
[i
].p_type
== PT_LOAD
)
3404 /* The Renesas tools expect p_paddr to be zero. However,
3405 there is no other way to store the writable data in ROM for
3406 startup initialization. So, we let the linker *think*
3407 we're using paddr and vaddr the "usual" way, but at the
3408 last minute we move the paddr into the vaddr (which is what
3409 the simulator uses) and zero out paddr. Note that this
3410 does not affect the section headers, just the program
3411 headers. We hope. */
3412 phdr
[i
].p_vaddr
= phdr
[i
].p_paddr
;
3413 #if 0 /* If we zero out p_paddr, then the LMA in the section table
3415 phdr
[i
].p_paddr
= 0;
3422 #define ELF_ARCH bfd_arch_rx
3423 #define ELF_MACHINE_CODE EM_RX
3424 #define ELF_MAXPAGESIZE 0x1000
3426 #define TARGET_BIG_SYM bfd_elf32_rx_be_vec
3427 #define TARGET_BIG_NAME "elf32-rx-be"
3429 #define TARGET_LITTLE_SYM bfd_elf32_rx_le_vec
3430 #define TARGET_LITTLE_NAME "elf32-rx-le"
3432 #define elf_info_to_howto_rel NULL
3433 #define elf_info_to_howto rx_info_to_howto_rela
3434 #define elf_backend_object_p rx_elf_object_p
3435 #define elf_backend_relocate_section rx_elf_relocate_section
3436 #define elf_symbol_leading_char ('_')
3437 #define elf_backend_can_gc_sections 1
3438 #define elf_backend_modify_program_headers elf32_rx_modify_program_headers
3440 #define bfd_elf32_bfd_reloc_type_lookup rx_reloc_type_lookup
3441 #define bfd_elf32_bfd_reloc_name_lookup rx_reloc_name_lookup
3442 #define bfd_elf32_bfd_set_private_flags rx_elf_set_private_flags
3443 #define bfd_elf32_bfd_merge_private_bfd_data rx_elf_merge_private_bfd_data
3444 #define bfd_elf32_bfd_print_private_bfd_data rx_elf_print_private_bfd_data
3445 #define bfd_elf32_get_section_contents rx_get_section_contents
3446 #define bfd_elf32_set_section_contents rx_set_section_contents
3447 #define bfd_elf32_bfd_final_link rx_final_link
3448 #define bfd_elf32_bfd_relax_section elf32_rx_relax_section_wrapper
3450 #include "elf32-target.h"
3452 /* We define a second big-endian target that doesn't have the custom
3453 section get/set hooks, for times when we want to preserve the
3454 pre-swapped .text sections (like objcopy). */
3456 #undef TARGET_BIG_SYM
3457 #define TARGET_BIG_SYM bfd_elf32_rx_be_ns_vec
3458 #undef TARGET_BIG_NAME
3459 #define TARGET_BIG_NAME "elf32-rx-be-ns"
3460 #undef TARGET_LITTLE_SYM
3462 #undef bfd_elf32_get_section_contents
3463 #undef bfd_elf32_set_section_contents
3466 #define elf32_bed elf32_rx_be_ns_bed
3468 #include "elf32-target.h"