1 /* BFD back-end for Renesas H8/300 ELF binaries.
2 Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006,
3 2007 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., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
28 static reloc_howto_type
*elf32_h8_reloc_type_lookup
29 (bfd
*abfd
, bfd_reloc_code_real_type code
);
30 static void elf32_h8_info_to_howto
31 (bfd
*, arelent
*, Elf_Internal_Rela
*);
32 static void elf32_h8_info_to_howto_rel
33 (bfd
*, arelent
*, Elf_Internal_Rela
*);
34 static unsigned long elf32_h8_mach (flagword
);
35 static void elf32_h8_final_write_processing (bfd
*, bfd_boolean
);
36 static bfd_boolean
elf32_h8_object_p (bfd
*);
37 static bfd_boolean
elf32_h8_merge_private_bfd_data (bfd
*, bfd
*);
38 static bfd_boolean elf32_h8_relax_section
39 (bfd
*, asection
*, struct bfd_link_info
*, bfd_boolean
*);
40 static bfd_boolean elf32_h8_relax_delete_bytes
41 (bfd
*, asection
*, bfd_vma
, int);
42 static bfd_boolean
elf32_h8_symbol_address_p (bfd
*, asection
*, bfd_vma
);
43 static bfd_byte
*elf32_h8_get_relocated_section_contents
44 (bfd
*, struct bfd_link_info
*, struct bfd_link_order
*,
45 bfd_byte
*, bfd_boolean
, asymbol
**);
46 static bfd_reloc_status_type elf32_h8_final_link_relocate
47 (unsigned long, bfd
*, bfd
*, asection
*,
48 bfd_byte
*, bfd_vma
, bfd_vma
, bfd_vma
,
49 struct bfd_link_info
*, asection
*, int);
50 static bfd_boolean elf32_h8_relocate_section
51 (bfd
*, struct bfd_link_info
*, bfd
*, asection
*,
52 bfd_byte
*, Elf_Internal_Rela
*,
53 Elf_Internal_Sym
*, asection
**);
54 static bfd_reloc_status_type special
55 (bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **);
57 /* This does not include any relocation information, but should be
58 good enough for GDB or objdump to read the file. */
60 static reloc_howto_type h8_elf_howto_table
[] = {
62 HOWTO (R_H8_NONE
, /* type */
64 0, /* size (0 = byte, 1 = short, 2 = long) */
66 FALSE
, /* pc_relative */
68 complain_overflow_dont
,/* complain_on_overflow */
69 special
, /* special_function */
70 "R_H8_NONE", /* name */
71 FALSE
, /* partial_inplace */
74 FALSE
), /* pcrel_offset */
75 #define R_H8_DIR32_X (R_H8_NONE_X + 1)
76 HOWTO (R_H8_DIR32
, /* type */
78 2, /* size (0 = byte, 1 = short, 2 = long) */
80 FALSE
, /* pc_relative */
82 complain_overflow_dont
,/* complain_on_overflow */
83 special
, /* special_function */
84 "R_H8_DIR32", /* name */
85 FALSE
, /* partial_inplace */
87 0xffffffff, /* dst_mask */
88 FALSE
), /* pcrel_offset */
89 #define R_H8_DIR16_X (R_H8_DIR32_X + 1)
90 HOWTO (R_H8_DIR16
, /* type */
92 1, /* size (0 = byte, 1 = short, 2 = long) */
94 FALSE
, /* pc_relative */
96 complain_overflow_dont
,/* complain_on_overflow */
97 special
, /* special_function */
98 "R_H8_DIR16", /* name */
99 FALSE
, /* partial_inplace */
101 0x0000ffff, /* dst_mask */
102 FALSE
), /* pcrel_offset */
103 #define R_H8_DIR8_X (R_H8_DIR16_X + 1)
104 HOWTO (R_H8_DIR8
, /* type */
106 0, /* size (0 = byte, 1 = short, 2 = long) */
108 FALSE
, /* pc_relative */
110 complain_overflow_dont
,/* complain_on_overflow */
111 special
, /* special_function */
112 "R_H8_DIR8", /* name */
113 FALSE
, /* partial_inplace */
115 0x000000ff, /* dst_mask */
116 FALSE
), /* pcrel_offset */
117 #define R_H8_DIR16A8_X (R_H8_DIR8_X + 1)
118 HOWTO (R_H8_DIR16A8
, /* type */
120 1, /* size (0 = byte, 1 = short, 2 = long) */
122 FALSE
, /* pc_relative */
124 complain_overflow_bitfield
, /* complain_on_overflow */
125 special
, /* special_function */
126 "R_H8_DIR16A8", /* name */
127 FALSE
, /* partial_inplace */
129 0x0000ffff, /* dst_mask */
130 FALSE
), /* pcrel_offset */
131 #define R_H8_DIR16R8_X (R_H8_DIR16A8_X + 1)
132 HOWTO (R_H8_DIR16R8
, /* type */
134 1, /* size (0 = byte, 1 = short, 2 = long) */
136 FALSE
, /* pc_relative */
138 complain_overflow_bitfield
, /* complain_on_overflow */
139 special
, /* special_function */
140 "R_H8_DIR16R8", /* name */
141 FALSE
, /* partial_inplace */
143 0x0000ffff, /* dst_mask */
144 FALSE
), /* pcrel_offset */
145 #define R_H8_DIR24A8_X (R_H8_DIR16R8_X + 1)
146 HOWTO (R_H8_DIR24A8
, /* type */
148 2, /* size (0 = byte, 1 = short, 2 = long) */
150 FALSE
, /* pc_relative */
152 complain_overflow_bitfield
, /* complain_on_overflow */
153 special
, /* special_function */
154 "R_H8_DIR24A8", /* name */
155 TRUE
, /* partial_inplace */
156 0xff000000, /* src_mask */
157 0x00ffffff, /* dst_mask */
158 FALSE
), /* pcrel_offset */
159 #define R_H8_DIR24R8_X (R_H8_DIR24A8_X + 1)
160 HOWTO (R_H8_DIR24R8
, /* type */
162 2, /* size (0 = byte, 1 = short, 2 = long) */
164 FALSE
, /* pc_relative */
166 complain_overflow_bitfield
, /* complain_on_overflow */
167 special
, /* special_function */
168 "R_H8_DIR24R8", /* name */
169 TRUE
, /* partial_inplace */
170 0xff000000, /* src_mask */
171 0x00ffffff, /* dst_mask */
172 FALSE
), /* pcrel_offset */
173 #define R_H8_DIR32A16_X (R_H8_DIR24R8_X + 1)
174 HOWTO (R_H8_DIR32A16
, /* type */
176 2, /* size (0 = byte, 1 = short, 2 = long) */
178 FALSE
, /* pc_relative */
180 complain_overflow_dont
,/* complain_on_overflow */
181 special
, /* special_function */
182 "R_H8_DIR32A16", /* name */
183 FALSE
, /* partial_inplace */
185 0xffffffff, /* dst_mask */
186 FALSE
), /* pcrel_offset */
187 #define R_H8_PCREL16_X (R_H8_DIR32A16_X + 1)
188 HOWTO (R_H8_PCREL16
, /* type */
190 1, /* size (0 = byte, 1 = short, 2 = long) */
192 TRUE
, /* pc_relative */
194 complain_overflow_signed
,/* complain_on_overflow */
195 special
, /* special_function */
196 "R_H8_PCREL16", /* name */
197 FALSE
, /* partial_inplace */
198 0xffff, /* src_mask */
199 0xffff, /* dst_mask */
200 TRUE
), /* pcrel_offset */
201 #define R_H8_PCREL8_X (R_H8_PCREL16_X + 1)
202 HOWTO (R_H8_PCREL8
, /* type */
204 0, /* size (0 = byte, 1 = short, 2 = long) */
206 TRUE
, /* pc_relative */
208 complain_overflow_signed
,/* complain_on_overflow */
209 special
, /* special_function */
210 "R_H8_PCREL8", /* name */
211 FALSE
, /* partial_inplace */
214 TRUE
), /* pcrel_offset */
217 /* This structure is used to map BFD reloc codes to H8 ELF relocs. */
219 struct elf_reloc_map
{
220 bfd_reloc_code_real_type bfd_reloc_val
;
221 unsigned char howto_index
;
224 /* An array mapping BFD reloc codes to H8 ELF relocs. */
226 static const struct elf_reloc_map h8_reloc_map
[] = {
227 { BFD_RELOC_NONE
, R_H8_NONE_X
},
228 { BFD_RELOC_32
, R_H8_DIR32_X
},
229 { BFD_RELOC_16
, R_H8_DIR16_X
},
230 { BFD_RELOC_8
, R_H8_DIR8_X
},
231 { BFD_RELOC_H8_DIR16A8
, R_H8_DIR16A8_X
},
232 { BFD_RELOC_H8_DIR16R8
, R_H8_DIR16R8_X
},
233 { BFD_RELOC_H8_DIR24A8
, R_H8_DIR24A8_X
},
234 { BFD_RELOC_H8_DIR24R8
, R_H8_DIR24R8_X
},
235 { BFD_RELOC_H8_DIR32A16
, R_H8_DIR32A16_X
},
236 { BFD_RELOC_16_PCREL
, R_H8_PCREL16_X
},
237 { BFD_RELOC_8_PCREL
, R_H8_PCREL8_X
},
241 static reloc_howto_type
*
242 elf32_h8_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
243 bfd_reloc_code_real_type code
)
247 for (i
= 0; i
< sizeof (h8_reloc_map
) / sizeof (struct elf_reloc_map
); i
++)
249 if (h8_reloc_map
[i
].bfd_reloc_val
== code
)
250 return &h8_elf_howto_table
[(int) h8_reloc_map
[i
].howto_index
];
255 static reloc_howto_type
*
256 elf32_h8_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
262 i
< sizeof (h8_elf_howto_table
) / sizeof (h8_elf_howto_table
[0]);
264 if (h8_elf_howto_table
[i
].name
!= NULL
265 && strcasecmp (h8_elf_howto_table
[i
].name
, r_name
) == 0)
266 return &h8_elf_howto_table
[i
];
272 elf32_h8_info_to_howto (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*bfd_reloc
,
273 Elf_Internal_Rela
*elf_reloc
)
278 r
= ELF32_R_TYPE (elf_reloc
->r_info
);
279 for (i
= 0; i
< sizeof (h8_elf_howto_table
) / sizeof (reloc_howto_type
); i
++)
280 if (h8_elf_howto_table
[i
].type
== r
)
282 bfd_reloc
->howto
= &h8_elf_howto_table
[i
];
289 elf32_h8_info_to_howto_rel (bfd
*abfd ATTRIBUTE_UNUSED
, arelent
*bfd_reloc
,
290 Elf_Internal_Rela
*elf_reloc ATTRIBUTE_UNUSED
)
295 r
= ELF32_R_TYPE (elf_reloc
->r_info
);
296 bfd_reloc
->howto
= &h8_elf_howto_table
[r
];
299 /* Special handling for H8/300 relocs.
300 We only come here for pcrel stuff and return normally if not an -r link.
301 When doing -r, we can't do any arithmetic for the pcrel stuff, because
302 we support relaxing on the H8/300 series chips. */
303 static bfd_reloc_status_type
304 special (bfd
*abfd ATTRIBUTE_UNUSED
,
305 arelent
*reloc_entry ATTRIBUTE_UNUSED
,
306 asymbol
*symbol ATTRIBUTE_UNUSED
,
307 PTR data ATTRIBUTE_UNUSED
,
308 asection
*input_section ATTRIBUTE_UNUSED
,
310 char **error_message ATTRIBUTE_UNUSED
)
312 if (output_bfd
== (bfd
*) NULL
)
313 return bfd_reloc_continue
;
315 /* Adjust the reloc address to that in the output section. */
316 reloc_entry
->address
+= input_section
->output_offset
;
320 /* Perform a relocation as part of a final link. */
321 static bfd_reloc_status_type
322 elf32_h8_final_link_relocate (unsigned long r_type
, bfd
*input_bfd
,
323 bfd
*output_bfd ATTRIBUTE_UNUSED
,
324 asection
*input_section ATTRIBUTE_UNUSED
,
325 bfd_byte
*contents
, bfd_vma offset
,
326 bfd_vma value
, bfd_vma addend
,
327 struct bfd_link_info
*info ATTRIBUTE_UNUSED
,
328 asection
*sym_sec ATTRIBUTE_UNUSED
,
329 int is_local ATTRIBUTE_UNUSED
)
331 bfd_byte
*hit_data
= contents
+ offset
;
342 bfd_put_32 (input_bfd
, value
, hit_data
);
349 bfd_put_16 (input_bfd
, value
, hit_data
);
356 bfd_put_8 (input_bfd
, value
, hit_data
);
362 /* HIT_DATA is the address for the first byte for the relocated
363 value. Subtract 1 so that we can manipulate the data in 32-bit
367 /* Clear out the top byte in value. */
370 /* Retrieve the type byte for value from the section contents. */
371 value
|= (bfd_get_32 (input_bfd
, hit_data
) & 0xff000000);
373 /* Now scribble it out in one 32-bit hunk. */
374 bfd_put_32 (input_bfd
, value
, hit_data
);
378 value
-= (input_section
->output_section
->vma
379 + input_section
->output_offset
);
383 /* The value is relative to the start of the instruction,
384 not the relocation offset. Subtract 2 to account for
388 bfd_put_16 (input_bfd
, value
, hit_data
);
392 value
-= (input_section
->output_section
->vma
393 + input_section
->output_offset
);
397 /* The value is relative to the start of the instruction,
398 not the relocation offset. Subtract 1 to account for
402 bfd_put_8 (input_bfd
, value
, hit_data
);
406 return bfd_reloc_notsupported
;
410 /* Relocate an H8 ELF section. */
412 elf32_h8_relocate_section (bfd
*output_bfd
, struct bfd_link_info
*info
,
413 bfd
*input_bfd
, asection
*input_section
,
414 bfd_byte
*contents
, Elf_Internal_Rela
*relocs
,
415 Elf_Internal_Sym
*local_syms
,
416 asection
**local_sections
)
418 Elf_Internal_Shdr
*symtab_hdr
;
419 struct elf_link_hash_entry
**sym_hashes
;
420 Elf_Internal_Rela
*rel
, *relend
;
422 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
423 sym_hashes
= elf_sym_hashes (input_bfd
);
426 relend
= relocs
+ input_section
->reloc_count
;
427 for (; rel
< relend
; rel
++)
430 unsigned long r_symndx
;
431 Elf_Internal_Sym
*sym
;
433 struct elf_link_hash_entry
*h
;
435 bfd_reloc_status_type r
;
437 reloc_howto_type
*howto
;
439 elf32_h8_info_to_howto (input_bfd
, &bfd_reloc
, rel
);
440 howto
= bfd_reloc
.howto
;
442 r_symndx
= ELF32_R_SYM (rel
->r_info
);
443 r_type
= ELF32_R_TYPE (rel
->r_info
);
447 if (r_symndx
< symtab_hdr
->sh_info
)
449 sym
= local_syms
+ r_symndx
;
450 sec
= local_sections
[r_symndx
];
451 relocation
= _bfd_elf_rela_local_sym (output_bfd
, sym
, &sec
, rel
);
455 bfd_boolean unresolved_reloc
, warned
;
457 RELOC_FOR_GLOBAL_SYMBOL (info
, input_bfd
, input_section
, rel
,
458 r_symndx
, symtab_hdr
, sym_hashes
,
460 unresolved_reloc
, warned
);
463 if (sec
!= NULL
&& elf_discarded_section (sec
))
465 /* For relocs against symbols from removed linkonce sections,
466 or sections discarded by a linker script, we just want the
467 section contents zeroed. Avoid any special processing. */
468 _bfd_clear_contents (howto
, input_bfd
, contents
+ rel
->r_offset
);
474 if (info
->relocatable
)
477 r
= elf32_h8_final_link_relocate (r_type
, input_bfd
, output_bfd
,
479 contents
, rel
->r_offset
,
480 relocation
, rel
->r_addend
,
481 info
, sec
, h
== NULL
);
483 if (r
!= bfd_reloc_ok
)
486 const char *msg
= (const char *) 0;
489 name
= h
->root
.root
.string
;
492 name
= (bfd_elf_string_from_elf_section
493 (input_bfd
, symtab_hdr
->sh_link
, sym
->st_name
));
494 if (name
== NULL
|| *name
== '\0')
495 name
= bfd_section_name (input_bfd
, sec
);
500 case bfd_reloc_overflow
:
501 if (! ((*info
->callbacks
->reloc_overflow
)
502 (info
, (h
? &h
->root
: NULL
), name
, howto
->name
,
503 (bfd_vma
) 0, input_bfd
, input_section
,
508 case bfd_reloc_undefined
:
509 if (! ((*info
->callbacks
->undefined_symbol
)
510 (info
, name
, input_bfd
, input_section
,
511 rel
->r_offset
, TRUE
)))
515 case bfd_reloc_outofrange
:
516 msg
= _("internal error: out of range error");
519 case bfd_reloc_notsupported
:
520 msg
= _("internal error: unsupported relocation error");
523 case bfd_reloc_dangerous
:
524 msg
= _("internal error: dangerous error");
528 msg
= _("internal error: unknown error");
532 if (!((*info
->callbacks
->warning
)
533 (info
, msg
, name
, input_bfd
, input_section
,
544 /* Object files encode the specific H8 model they were compiled
545 for in the ELF flags field.
547 Examine that field and return the proper BFD machine type for
550 elf32_h8_mach (flagword flags
)
552 switch (flags
& EF_H8_MACH
)
554 case E_H8_MACH_H8300
:
556 return bfd_mach_h8300
;
558 case E_H8_MACH_H8300H
:
559 return bfd_mach_h8300h
;
561 case E_H8_MACH_H8300S
:
562 return bfd_mach_h8300s
;
564 case E_H8_MACH_H8300HN
:
565 return bfd_mach_h8300hn
;
567 case E_H8_MACH_H8300SN
:
568 return bfd_mach_h8300sn
;
570 case E_H8_MACH_H8300SX
:
571 return bfd_mach_h8300sx
;
573 case E_H8_MACH_H8300SXN
:
574 return bfd_mach_h8300sxn
;
578 /* The final processing done just before writing out a H8 ELF object
579 file. We use this opportunity to encode the BFD machine type
580 into the flags field in the object file. */
583 elf32_h8_final_write_processing (bfd
*abfd
,
584 bfd_boolean linker ATTRIBUTE_UNUSED
)
588 switch (bfd_get_mach (abfd
))
592 val
= E_H8_MACH_H8300
;
595 case bfd_mach_h8300h
:
596 val
= E_H8_MACH_H8300H
;
599 case bfd_mach_h8300s
:
600 val
= E_H8_MACH_H8300S
;
603 case bfd_mach_h8300hn
:
604 val
= E_H8_MACH_H8300HN
;
607 case bfd_mach_h8300sn
:
608 val
= E_H8_MACH_H8300SN
;
611 case bfd_mach_h8300sx
:
612 val
= E_H8_MACH_H8300SX
;
615 case bfd_mach_h8300sxn
:
616 val
= E_H8_MACH_H8300SXN
;
620 elf_elfheader (abfd
)->e_flags
&= ~ (EF_H8_MACH
);
621 elf_elfheader (abfd
)->e_flags
|= val
;
624 /* Return nonzero if ABFD represents a valid H8 ELF object file; also
625 record the encoded machine type found in the ELF flags. */
628 elf32_h8_object_p (bfd
*abfd
)
630 bfd_default_set_arch_mach (abfd
, bfd_arch_h8300
,
631 elf32_h8_mach (elf_elfheader (abfd
)->e_flags
));
635 /* Merge backend specific data from an object file to the output
636 object file when linking. The only data we need to copy at this
637 time is the architecture/machine information. */
640 elf32_h8_merge_private_bfd_data (bfd
*ibfd
, bfd
*obfd
)
642 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
643 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
646 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
647 && bfd_get_mach (obfd
) < bfd_get_mach (ibfd
))
649 if (! bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
),
650 bfd_get_mach (ibfd
)))
657 /* This function handles relaxing for the H8..
659 There are a few relaxing opportunities available on the H8:
661 jmp/jsr:24 -> bra/bsr:8 2 bytes
662 The jmp may be completely eliminated if the previous insn is a
663 conditional branch to the insn after the jump. In that case
664 we invert the branch and delete the jump and save 4 bytes.
666 bCC:16 -> bCC:8 2 bytes
667 bsr:16 -> bsr:8 2 bytes
669 bset:16 -> bset:8 2 bytes
670 bset:24/32 -> bset:8 4 bytes
671 (also applicable to other bit manipulation instructions)
673 mov.b:16 -> mov.b:8 2 bytes
674 mov.b:24/32 -> mov.b:8 4 bytes
676 bset:24/32 -> bset:16 2 bytes
677 (also applicable to other bit manipulation instructions)
679 mov.[bwl]:24/32 -> mov.[bwl]:16 2 bytes */
682 elf32_h8_relax_section (bfd
*abfd
, asection
*sec
,
683 struct bfd_link_info
*link_info
, bfd_boolean
*again
)
685 Elf_Internal_Shdr
*symtab_hdr
;
686 Elf_Internal_Rela
*internal_relocs
;
687 Elf_Internal_Rela
*irel
, *irelend
;
688 bfd_byte
*contents
= NULL
;
689 Elf_Internal_Sym
*isymbuf
= NULL
;
690 static asection
*last_input_section
= NULL
;
691 static Elf_Internal_Rela
*last_reloc
= NULL
;
693 /* Assume nothing changes. */
696 /* We don't have to do anything for a relocatable link, if
697 this section does not have relocs, or if this is not a
699 if (link_info
->relocatable
700 || (sec
->flags
& SEC_RELOC
) == 0
701 || sec
->reloc_count
== 0
702 || (sec
->flags
& SEC_CODE
) == 0)
705 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
707 /* Get a copy of the native relocations. */
708 internal_relocs
= (_bfd_elf_link_read_relocs
709 (abfd
, sec
, (PTR
) NULL
, (Elf_Internal_Rela
*) NULL
,
710 link_info
->keep_memory
));
711 if (internal_relocs
== NULL
)
714 if (sec
!= last_input_section
)
717 last_input_section
= sec
;
719 /* Walk through the relocs looking for relaxing opportunities. */
720 irelend
= internal_relocs
+ sec
->reloc_count
;
721 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
725 /* Keep track of the previous reloc so that we can delete
726 some long jumps created by the compiler. */
727 if (irel
!= internal_relocs
)
728 last_reloc
= irel
- 1;
730 if (ELF32_R_TYPE (irel
->r_info
) != R_H8_DIR24R8
731 && ELF32_R_TYPE (irel
->r_info
) != R_H8_PCREL16
732 && ELF32_R_TYPE (irel
->r_info
) != R_H8_DIR16A8
733 && ELF32_R_TYPE (irel
->r_info
) != R_H8_DIR24A8
734 && ELF32_R_TYPE (irel
->r_info
) != R_H8_DIR32A16
)
737 /* Get the section contents if we haven't done so already. */
738 if (contents
== NULL
)
740 /* Get cached copy if it exists. */
741 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
742 contents
= elf_section_data (sec
)->this_hdr
.contents
;
745 /* Go get them off disk. */
746 if (!bfd_malloc_and_get_section (abfd
, sec
, &contents
))
751 /* Read this BFD's local symbols if we haven't done so already. */
752 if (isymbuf
== NULL
&& symtab_hdr
->sh_info
!= 0)
754 isymbuf
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
756 isymbuf
= bfd_elf_get_elf_syms (abfd
, symtab_hdr
,
757 symtab_hdr
->sh_info
, 0,
763 /* Get the value of the symbol referred to by the reloc. */
764 if (ELF32_R_SYM (irel
->r_info
) < symtab_hdr
->sh_info
)
766 /* A local symbol. */
767 Elf_Internal_Sym
*isym
;
770 isym
= isymbuf
+ ELF32_R_SYM (irel
->r_info
);
771 sym_sec
= bfd_section_from_elf_index (abfd
, isym
->st_shndx
);
772 symval
= isym
->st_value
;
773 /* If the reloc is absolute, it will not have
774 a symbol or section associated with it. */
776 symval
+= sym_sec
->output_section
->vma
777 + sym_sec
->output_offset
;
782 struct elf_link_hash_entry
*h
;
784 /* An external symbol. */
785 indx
= ELF32_R_SYM (irel
->r_info
) - symtab_hdr
->sh_info
;
786 h
= elf_sym_hashes (abfd
)[indx
];
787 BFD_ASSERT (h
!= NULL
);
788 if (h
->root
.type
!= bfd_link_hash_defined
789 && h
->root
.type
!= bfd_link_hash_defweak
)
791 /* This appears to be a reference to an undefined
792 symbol. Just ignore it--it will be caught by the
793 regular reloc processing. */
797 symval
= (h
->root
.u
.def
.value
798 + h
->root
.u
.def
.section
->output_section
->vma
799 + h
->root
.u
.def
.section
->output_offset
);
802 /* For simplicity of coding, we are going to modify the section
803 contents, the section relocs, and the BFD symbol table. We
804 must tell the rest of the code not to free up this
805 information. It would be possible to instead create a table
806 of changes which have to be made, as is done in coff-mips.c;
807 that would be more work, but would require less memory when
808 the linker is run. */
809 switch (ELF32_R_TYPE (irel
->r_info
))
811 /* Try to turn a 24-bit absolute branch/call into an 8-bit
812 pc-relative branch/call. */
815 bfd_vma value
= symval
+ irel
->r_addend
;
818 /* Get the address of this instruction. */
819 dot
= (sec
->output_section
->vma
820 + sec
->output_offset
+ irel
->r_offset
- 1);
822 /* Compute the distance from this insn to the branch target. */
825 /* If the distance is within -126..+130 inclusive, then we can
826 relax this jump. +130 is valid since the target will move
827 two bytes closer if we do relax this branch. */
828 if ((int) gap
>= -126 && (int) gap
<= 130)
832 /* Note that we've changed the relocs, section contents,
834 elf_section_data (sec
)->relocs
= internal_relocs
;
835 elf_section_data (sec
)->this_hdr
.contents
= contents
;
836 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
838 /* Get the instruction code being relaxed. */
839 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 1);
841 /* If the previous instruction conditionally jumped around
842 this instruction, we may be able to reverse the condition
843 and redirect the previous instruction to the target of
846 Such sequences are used by the compiler to deal with
847 long conditional branches.
849 Only perform this optimisation for jumps (code 0x5a) not
850 subroutine calls, as otherwise it could transform:
863 which changes the call (jsr) into a branch (bne). */
868 && ELF32_R_TYPE (last_reloc
->r_info
) == R_H8_PCREL8
869 && ELF32_R_SYM (last_reloc
->r_info
) < symtab_hdr
->sh_info
)
872 asection
*last_sym_sec
;
873 Elf_Internal_Sym
*last_sym
;
875 /* We will need to examine the symbol used by the
876 previous relocation. */
878 last_sym
= isymbuf
+ ELF32_R_SYM (last_reloc
->r_info
);
880 = bfd_section_from_elf_index (abfd
, last_sym
->st_shndx
);
881 last_value
= (last_sym
->st_value
882 + last_sym_sec
->output_section
->vma
883 + last_sym_sec
->output_offset
);
885 /* Verify that the previous relocation was for a
886 branch around this instruction and that no symbol
887 exists at the current location. */
888 if (last_value
== dot
+ 4
889 && last_reloc
->r_offset
+ 2 == irel
->r_offset
890 && ! elf32_h8_symbol_address_p (abfd
, sec
, dot
))
892 /* We can eliminate this jump. Twiddle the
893 previous relocation as necessary. */
895 = ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
896 ELF32_R_TYPE (R_H8_NONE
));
899 = ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
900 ELF32_R_TYPE (R_H8_PCREL8
));
901 last_reloc
->r_addend
= irel
->r_addend
;
903 code
= bfd_get_8 (abfd
,
904 contents
+ last_reloc
->r_offset
- 1);
908 contents
+ last_reloc
->r_offset
- 1);
910 /* Delete four bytes of data. */
911 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
923 bfd_put_8 (abfd
, 0x55, contents
+ irel
->r_offset
- 1);
924 else if (code
== 0x5a)
926 bfd_put_8 (abfd
, 0x40, contents
+ irel
->r_offset
- 1);
930 /* Fix the relocation's type. */
931 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
934 /* Delete two bytes of data. */
935 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
936 irel
->r_offset
+ 1, 2))
939 /* That will change things, so, we should relax again.
940 Note that this is not required, and it may be slow. */
946 /* Try to turn a 16-bit pc-relative branch into a 8-bit pc-relative
950 bfd_vma value
= symval
+ irel
->r_addend
;
954 /* Get the address of this instruction. */
955 dot
= (sec
->output_section
->vma
957 + irel
->r_offset
- 2);
961 /* If the distance is within -126..+130 inclusive, then we can
962 relax this jump. +130 is valid since the target will move
963 two bytes closer if we do relax this branch. */
964 if ((int) gap
>= -126 && (int) gap
<= 130)
968 /* Note that we've changed the relocs, section contents,
970 elf_section_data (sec
)->relocs
= internal_relocs
;
971 elf_section_data (sec
)->this_hdr
.contents
= contents
;
972 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
974 /* Get the opcode. */
975 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 2);
979 /* bCC:16 -> bCC:8 */
980 /* Get the second byte of the original insn, which
981 contains the condition code. */
982 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 1);
984 /* Compute the fisrt byte of the relaxed
985 instruction. The original sequence 0x58 0xX0
986 is relaxed to 0x4X, where X represents the
991 bfd_put_8 (abfd
, code
, contents
+ irel
->r_offset
- 2);
993 else if (code
== 0x5c)
995 bfd_put_8 (abfd
, 0x55, contents
+ irel
->r_offset
- 2);
999 /* Fix the relocation's type. */
1000 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
1004 /* Delete two bytes of data. */
1005 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
1006 irel
->r_offset
+ 1, 2))
1009 /* That will change things, so, we should relax again.
1010 Note that this is not required, and it may be slow. */
1016 /* This is a 16-bit absolute address in one of the following
1019 "band", "bclr", "biand", "bild", "bior", "bist", "bixor",
1020 "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", and
1023 We may relax this into an 8-bit absolute address if it's in
1029 value
= bfd_h8300_pad_address (abfd
, symval
+ irel
->r_addend
);
1030 if (value
>= 0xffffff00u
)
1033 unsigned char temp_code
;
1035 /* Note that we've changed the relocs, section contents,
1037 elf_section_data (sec
)->relocs
= internal_relocs
;
1038 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1039 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
1041 /* Get the opcode. */
1042 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 2);
1044 /* All instructions with R_H8_DIR16A8 start with
1049 temp_code
= code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 1);
1050 /* If this is a mov.b instruction, clear the lower
1051 nibble, which contains the source/destination
1053 if ((temp_code
& 0x10) != 0x10)
1059 /* This is mov.b @aa:16,Rd. */
1060 bfd_put_8 (abfd
, (code
& 0xf) | 0x20,
1061 contents
+ irel
->r_offset
- 2);
1064 /* This is mov.b Rs,@aa:16. */
1065 bfd_put_8 (abfd
, (code
& 0xf) | 0x30,
1066 contents
+ irel
->r_offset
- 2);
1069 /* This is a bit-maniputation instruction that
1070 stores one bit into memory, one of "bclr",
1071 "bist", "bnot", "bset", and "bst". */
1072 bfd_put_8 (abfd
, 0x7f, contents
+ irel
->r_offset
- 2);
1075 /* This is a bit-maniputation instruction that
1076 loads one bit from memory, one of "band",
1077 "biand", "bild", "bior", "bixor", "bld", "bor",
1078 "btst", and "bxor". */
1079 bfd_put_8 (abfd
, 0x7e, contents
+ irel
->r_offset
- 2);
1085 /* Fix the relocation's type. */
1086 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
1089 /* Move the relocation. */
1092 /* Delete two bytes of data. */
1093 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
1094 irel
->r_offset
+ 1, 2))
1097 /* That will change things, so, we should relax again.
1098 Note that this is not required, and it may be slow. */
1104 /* This is a 24-bit absolute address in one of the following
1107 "band", "bclr", "biand", "bild", "bior", "bist", "bixor",
1108 "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", and
1111 We may relax this into an 8-bit absolute address if it's in
1117 value
= bfd_h8300_pad_address (abfd
, symval
+ irel
->r_addend
);
1118 if (value
>= 0xffffff00u
)
1121 unsigned char temp_code
;
1123 /* Note that we've changed the relocs, section contents,
1125 elf_section_data (sec
)->relocs
= internal_relocs
;
1126 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1127 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
1129 /* Get the opcode. */
1130 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 2);
1132 /* All instructions with R_H8_DIR24A8 start with
1137 temp_code
= code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 1);
1139 /* If this is a mov.b instruction, clear the lower
1140 nibble, which contains the source/destination
1142 if ((temp_code
& 0x30) != 0x30)
1148 /* This is mov.b @aa:24/32,Rd. */
1149 bfd_put_8 (abfd
, (code
& 0xf) | 0x20,
1150 contents
+ irel
->r_offset
- 2);
1153 /* This is mov.b Rs,@aa:24/32. */
1154 bfd_put_8 (abfd
, (code
& 0xf) | 0x30,
1155 contents
+ irel
->r_offset
- 2);
1158 /* This is a bit-maniputation instruction that
1159 stores one bit into memory, one of "bclr",
1160 "bist", "bnot", "bset", and "bst". */
1161 bfd_put_8 (abfd
, 0x7f, contents
+ irel
->r_offset
- 2);
1164 /* This is a bit-maniputation instruction that
1165 loads one bit from memory, one of "band",
1166 "biand", "bild", "bior", "bixor", "bld", "bor",
1167 "btst", and "bxor". */
1168 bfd_put_8 (abfd
, 0x7e, contents
+ irel
->r_offset
- 2);
1174 /* Fix the relocation's type. */
1175 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
1179 /* Delete two bytes of data. */
1180 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
1181 irel
->r_offset
+ 1, 4))
1184 /* That will change things, so, we should relax again.
1185 Note that this is not required, and it may be slow. */
1193 /* This is a 24-/32-bit absolute address in one of the
1194 following instructions:
1196 "band", "bclr", "biand", "bild", "bior", "bist",
1197 "bixor", "bld", "bnot", "bor", "bset", "bst", "btst",
1198 "bxor", "ldc.w", "stc.w" and "mov.[bwl]"
1200 We may relax this into an 16-bit absolute address if it's
1201 in the right range. */
1206 value
= bfd_h8300_pad_address (abfd
, symval
+ irel
->r_addend
);
1207 if (value
<= 0x7fff || value
>= 0xffff8000u
)
1211 /* Note that we've changed the relocs, section contents,
1213 elf_section_data (sec
)->relocs
= internal_relocs
;
1214 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1215 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
1217 /* Get the opcode. */
1218 code
= bfd_get_8 (abfd
, contents
+ irel
->r_offset
- 1);
1220 /* Fix the opcode. For all the instructions that
1221 belong to this relaxation, we simply need to turn
1222 off bit 0x20 in the previous byte. */
1225 bfd_put_8 (abfd
, code
, contents
+ irel
->r_offset
- 1);
1227 /* Fix the relocation's type. */
1228 irel
->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel
->r_info
),
1231 /* Delete two bytes of data. */
1232 if (!elf32_h8_relax_delete_bytes (abfd
, sec
,
1233 irel
->r_offset
+ 1, 2))
1236 /* That will change things, so, we should relax again.
1237 Note that this is not required, and it may be slow. */
1249 && symtab_hdr
->contents
!= (unsigned char *) isymbuf
)
1251 if (! link_info
->keep_memory
)
1254 symtab_hdr
->contents
= (unsigned char *) isymbuf
;
1257 if (contents
!= NULL
1258 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
1260 if (! link_info
->keep_memory
)
1264 /* Cache the section contents for elf_link_input_bfd. */
1265 elf_section_data (sec
)->this_hdr
.contents
= contents
;
1269 if (internal_relocs
!= NULL
1270 && elf_section_data (sec
)->relocs
!= internal_relocs
)
1271 free (internal_relocs
);
1277 && symtab_hdr
->contents
!= (unsigned char *) isymbuf
)
1279 if (contents
!= NULL
1280 && elf_section_data (sec
)->this_hdr
.contents
!= contents
)
1282 if (internal_relocs
!= NULL
1283 && elf_section_data (sec
)->relocs
!= internal_relocs
)
1284 free (internal_relocs
);
1288 /* Delete some bytes from a section while relaxing. */
1291 elf32_h8_relax_delete_bytes (bfd
*abfd
, asection
*sec
, bfd_vma addr
, int count
)
1293 Elf_Internal_Shdr
*symtab_hdr
;
1294 unsigned int sec_shndx
;
1296 Elf_Internal_Rela
*irel
, *irelend
;
1297 Elf_Internal_Rela
*irelalign
;
1298 Elf_Internal_Sym
*isym
;
1299 Elf_Internal_Sym
*isymend
;
1301 struct elf_link_hash_entry
**sym_hashes
;
1302 struct elf_link_hash_entry
**end_hashes
;
1303 unsigned int symcount
;
1305 sec_shndx
= _bfd_elf_section_from_bfd_section (abfd
, sec
);
1307 contents
= elf_section_data (sec
)->this_hdr
.contents
;
1309 /* The deletion must stop at the next ALIGN reloc for an aligment
1310 power larger than the number of bytes we are deleting. */
1315 irel
= elf_section_data (sec
)->relocs
;
1316 irelend
= irel
+ sec
->reloc_count
;
1318 /* Actually delete the bytes. */
1319 memmove (contents
+ addr
, contents
+ addr
+ count
,
1320 (size_t) (toaddr
- addr
- count
));
1323 /* Adjust all the relocs. */
1324 for (irel
= elf_section_data (sec
)->relocs
; irel
< irelend
; irel
++)
1326 /* Get the new reloc address. */
1327 if ((irel
->r_offset
> addr
1328 && irel
->r_offset
< toaddr
))
1329 irel
->r_offset
-= count
;
1332 /* Adjust the local symbols defined in this section. */
1333 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1334 isym
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1335 isymend
= isym
+ symtab_hdr
->sh_info
;
1336 for (; isym
< isymend
; isym
++)
1338 if (isym
->st_shndx
== sec_shndx
1339 && isym
->st_value
> addr
1340 && isym
->st_value
< toaddr
)
1341 isym
->st_value
-= count
;
1344 /* Now adjust the global symbols defined in this section. */
1345 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
1346 - symtab_hdr
->sh_info
);
1347 sym_hashes
= elf_sym_hashes (abfd
);
1348 end_hashes
= sym_hashes
+ symcount
;
1349 for (; sym_hashes
< end_hashes
; sym_hashes
++)
1351 struct elf_link_hash_entry
*sym_hash
= *sym_hashes
;
1352 if ((sym_hash
->root
.type
== bfd_link_hash_defined
1353 || sym_hash
->root
.type
== bfd_link_hash_defweak
)
1354 && sym_hash
->root
.u
.def
.section
== sec
1355 && sym_hash
->root
.u
.def
.value
> addr
1356 && sym_hash
->root
.u
.def
.value
< toaddr
)
1358 sym_hash
->root
.u
.def
.value
-= count
;
1365 /* Return TRUE if a symbol exists at the given address, else return
1368 elf32_h8_symbol_address_p (bfd
*abfd
, asection
*sec
, bfd_vma addr
)
1370 Elf_Internal_Shdr
*symtab_hdr
;
1371 unsigned int sec_shndx
;
1372 Elf_Internal_Sym
*isym
;
1373 Elf_Internal_Sym
*isymend
;
1374 struct elf_link_hash_entry
**sym_hashes
;
1375 struct elf_link_hash_entry
**end_hashes
;
1376 unsigned int symcount
;
1378 sec_shndx
= _bfd_elf_section_from_bfd_section (abfd
, sec
);
1380 /* Examine all the symbols. */
1381 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1382 isym
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1383 isymend
= isym
+ symtab_hdr
->sh_info
;
1384 for (; isym
< isymend
; isym
++)
1386 if (isym
->st_shndx
== sec_shndx
1387 && isym
->st_value
== addr
)
1391 symcount
= (symtab_hdr
->sh_size
/ sizeof (Elf32_External_Sym
)
1392 - symtab_hdr
->sh_info
);
1393 sym_hashes
= elf_sym_hashes (abfd
);
1394 end_hashes
= sym_hashes
+ symcount
;
1395 for (; sym_hashes
< end_hashes
; sym_hashes
++)
1397 struct elf_link_hash_entry
*sym_hash
= *sym_hashes
;
1398 if ((sym_hash
->root
.type
== bfd_link_hash_defined
1399 || sym_hash
->root
.type
== bfd_link_hash_defweak
)
1400 && sym_hash
->root
.u
.def
.section
== sec
1401 && sym_hash
->root
.u
.def
.value
== addr
)
1408 /* This is a version of bfd_generic_get_relocated_section_contents
1409 which uses elf32_h8_relocate_section. */
1412 elf32_h8_get_relocated_section_contents (bfd
*output_bfd
,
1413 struct bfd_link_info
*link_info
,
1414 struct bfd_link_order
*link_order
,
1416 bfd_boolean relocatable
,
1419 Elf_Internal_Shdr
*symtab_hdr
;
1420 asection
*input_section
= link_order
->u
.indirect
.section
;
1421 bfd
*input_bfd
= input_section
->owner
;
1422 asection
**sections
= NULL
;
1423 Elf_Internal_Rela
*internal_relocs
= NULL
;
1424 Elf_Internal_Sym
*isymbuf
= NULL
;
1426 /* We only need to handle the case of relaxing, or of having a
1427 particular set of section contents, specially. */
1429 || elf_section_data (input_section
)->this_hdr
.contents
== NULL
)
1430 return bfd_generic_get_relocated_section_contents (output_bfd
, link_info
,
1435 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1437 memcpy (data
, elf_section_data (input_section
)->this_hdr
.contents
,
1438 (size_t) input_section
->size
);
1440 if ((input_section
->flags
& SEC_RELOC
) != 0
1441 && input_section
->reloc_count
> 0)
1444 Elf_Internal_Sym
*isym
, *isymend
;
1447 internal_relocs
= (_bfd_elf_link_read_relocs
1448 (input_bfd
, input_section
, (PTR
) NULL
,
1449 (Elf_Internal_Rela
*) NULL
, FALSE
));
1450 if (internal_relocs
== NULL
)
1453 if (symtab_hdr
->sh_info
!= 0)
1455 isymbuf
= (Elf_Internal_Sym
*) symtab_hdr
->contents
;
1456 if (isymbuf
== NULL
)
1457 isymbuf
= bfd_elf_get_elf_syms (input_bfd
, symtab_hdr
,
1458 symtab_hdr
->sh_info
, 0,
1460 if (isymbuf
== NULL
)
1464 amt
= symtab_hdr
->sh_info
;
1465 amt
*= sizeof (asection
*);
1466 sections
= (asection
**) bfd_malloc (amt
);
1467 if (sections
== NULL
&& amt
!= 0)
1470 isymend
= isymbuf
+ symtab_hdr
->sh_info
;
1471 for (isym
= isymbuf
, secpp
= sections
; isym
< isymend
; ++isym
, ++secpp
)
1475 if (isym
->st_shndx
== SHN_UNDEF
)
1476 isec
= bfd_und_section_ptr
;
1477 else if (isym
->st_shndx
== SHN_ABS
)
1478 isec
= bfd_abs_section_ptr
;
1479 else if (isym
->st_shndx
== SHN_COMMON
)
1480 isec
= bfd_com_section_ptr
;
1482 isec
= bfd_section_from_elf_index (input_bfd
, isym
->st_shndx
);
1487 if (! elf32_h8_relocate_section (output_bfd
, link_info
, input_bfd
,
1488 input_section
, data
, internal_relocs
,
1492 if (sections
!= NULL
)
1495 && symtab_hdr
->contents
!= (unsigned char *) isymbuf
)
1497 if (elf_section_data (input_section
)->relocs
!= internal_relocs
)
1498 free (internal_relocs
);
1504 if (sections
!= NULL
)
1507 && symtab_hdr
->contents
!= (unsigned char *) isymbuf
)
1509 if (internal_relocs
!= NULL
1510 && elf_section_data (input_section
)->relocs
!= internal_relocs
)
1511 free (internal_relocs
);
1516 #define TARGET_BIG_SYM bfd_elf32_h8300_vec
1517 #define TARGET_BIG_NAME "elf32-h8300"
1518 #define ELF_ARCH bfd_arch_h8300
1519 #define ELF_MACHINE_CODE EM_H8_300
1520 #define ELF_MAXPAGESIZE 0x1
1521 #define bfd_elf32_bfd_reloc_type_lookup elf32_h8_reloc_type_lookup
1522 #define bfd_elf32_bfd_reloc_name_lookup elf32_h8_reloc_name_lookup
1523 #define elf_info_to_howto elf32_h8_info_to_howto
1524 #define elf_info_to_howto_rel elf32_h8_info_to_howto_rel
1526 /* So we can set/examine bits in e_flags to get the specific
1527 H8 architecture in use. */
1528 #define elf_backend_final_write_processing \
1529 elf32_h8_final_write_processing
1530 #define elf_backend_object_p \
1532 #define bfd_elf32_bfd_merge_private_bfd_data \
1533 elf32_h8_merge_private_bfd_data
1535 /* ??? when elf_backend_relocate_section is not defined, elf32-target.h
1536 defaults to using _bfd_generic_link_hash_table_create, but
1537 bfd_elf_size_dynamic_sections uses
1538 dynobj = elf_hash_table (info)->dynobj;
1539 and thus requires an elf hash table. */
1540 #define bfd_elf32_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
1542 /* Use an H8 specific linker, not the ELF generic linker. */
1543 #define elf_backend_relocate_section elf32_h8_relocate_section
1544 #define elf_backend_rela_normal 1
1545 #define elf_backend_can_gc_sections 1
1547 /* And relaxing stuff. */
1548 #define bfd_elf32_bfd_relax_section elf32_h8_relax_section
1549 #define bfd_elf32_bfd_get_relocated_section_contents \
1550 elf32_h8_get_relocated_section_contents
1553 #include "elf32-target.h"