OLD | NEW |
1 /* BFD back-end for Renesas H8/300 COFF binaries. | 1 /* BFD back-end for Renesas H8/300 COFF binaries. |
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 Written by Steve Chamberlain, <sac@cygnus.com>. | 5 Written by Steve Chamberlain, <sac@cygnus.com>. |
6 | 6 |
7 This file is part of BFD, the Binary File Descriptor library. | 7 This file is part of BFD, the Binary File Descriptor library. |
8 | 8 |
9 This program is free software; you can redistribute it and/or modify | 9 This program is free software; you can redistribute it and/or modify |
10 it under the terms of the GNU General Public License as published by | 10 it under the terms of the GNU General Public License as published by |
11 the Free Software Foundation; either version 3 of the License, or | 11 the Free Software Foundation; either version 3 of the License, or |
12 (at your option) any later version. | 12 (at your option) any later version. |
13 | 13 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 { | 53 { |
54 /* The basic hash table. */ | 54 /* The basic hash table. */ |
55 struct bfd_hash_table root; | 55 struct bfd_hash_table root; |
56 | 56 |
57 bfd *abfd; | 57 bfd *abfd; |
58 | 58 |
59 /* Offset at which we'll add the next entry. */ | 59 /* Offset at which we'll add the next entry. */ |
60 unsigned int offset; | 60 unsigned int offset; |
61 }; | 61 }; |
62 | 62 |
63 static struct bfd_hash_entry * | |
64 funcvec_hash_newfunc | |
65 (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); | |
66 | |
67 static bfd_reloc_status_type special | |
68 (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **); | |
69 static int select_reloc | |
70 (reloc_howto_type *); | |
71 static void rtype2howto | |
72 (arelent *, struct internal_reloc *); | |
73 static void reloc_processing | |
74 (arelent *, struct internal_reloc *, asymbol **, bfd *, asection *); | |
75 static bfd_boolean h8300_symbol_address_p | |
76 (bfd *, asection *, bfd_vma); | |
77 static int h8300_reloc16_estimate | |
78 (bfd *, asection *, arelent *, unsigned int, | |
79 struct bfd_link_info *); | |
80 static void h8300_reloc16_extra_cases | |
81 (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, | |
82 bfd_byte *, unsigned int *, unsigned int *); | |
83 static bfd_boolean h8300_bfd_link_add_symbols | |
84 (bfd *, struct bfd_link_info *); | |
85 | 63 |
86 /* To lookup a value in the function vector hash table. */ | 64 /* To lookup a value in the function vector hash table. */ |
87 #define funcvec_hash_lookup(table, string, create, copy) \ | 65 #define funcvec_hash_lookup(table, string, create, copy) \ |
88 ((struct funcvec_hash_entry *) \ | 66 ((struct funcvec_hash_entry *) \ |
89 bfd_hash_lookup (&(table)->root, (string), (create), (copy))) | 67 bfd_hash_lookup (&(table)->root, (string), (create), (copy))) |
90 | 68 |
91 /* The derived h8300 COFF linker table. Note it's derived from | 69 /* The derived h8300 COFF linker table. Note it's derived from |
92 the generic linker hash table, not the COFF backend linker hash | 70 the generic linker hash table, not the COFF backend linker hash |
93 table! We use this to attach additional data structures we | 71 table! We use this to attach additional data structures we |
94 need while linking on the h8300. */ | 72 need while linking on the h8300. */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 /* Special handling for H8/300 relocs. | 195 /* Special handling for H8/300 relocs. |
218 We only come here for pcrel stuff and return normally if not an -r link. | 196 We only come here for pcrel stuff and return normally if not an -r link. |
219 When doing -r, we can't do any arithmetic for the pcrel stuff, because | 197 When doing -r, we can't do any arithmetic for the pcrel stuff, because |
220 the code in reloc.c assumes that we can manipulate the targets of | 198 the code in reloc.c assumes that we can manipulate the targets of |
221 the pcrel branches. This isn't so, since the H8/300 can do relaxing, | 199 the pcrel branches. This isn't so, since the H8/300 can do relaxing, |
222 which means that the gap after the instruction may not be enough to | 200 which means that the gap after the instruction may not be enough to |
223 contain the offset required for the branch, so we have to use only | 201 contain the offset required for the branch, so we have to use only |
224 the addend until the final link. */ | 202 the addend until the final link. */ |
225 | 203 |
226 static bfd_reloc_status_type | 204 static bfd_reloc_status_type |
227 special (bfd *abfd ATTRIBUTE_UNUSED, | 205 special (bfd * abfd ATTRIBUTE_UNUSED, |
228 » arelent *reloc_entry ATTRIBUTE_UNUSED, | 206 » arelent * reloc_entry ATTRIBUTE_UNUSED, |
229 » asymbol *symbol ATTRIBUTE_UNUSED, | 207 » asymbol * symbol ATTRIBUTE_UNUSED, |
230 » PTR data ATTRIBUTE_UNUSED, | 208 » void * data ATTRIBUTE_UNUSED, |
231 » asection *input_section ATTRIBUTE_UNUSED, | 209 » asection * input_section ATTRIBUTE_UNUSED, |
232 » bfd *output_bfd, | 210 » bfd * output_bfd, |
233 » char **error_message ATTRIBUTE_UNUSED) | 211 » char ** error_message ATTRIBUTE_UNUSED) |
234 { | 212 { |
235 if (output_bfd == (bfd *) NULL) | 213 if (output_bfd == (bfd *) NULL) |
236 return bfd_reloc_continue; | 214 return bfd_reloc_continue; |
237 | 215 |
238 /* Adjust the reloc address to that in the output section. */ | 216 /* Adjust the reloc address to that in the output section. */ |
239 reloc_entry->address += input_section->output_offset; | 217 reloc_entry->address += input_section->output_offset; |
240 return bfd_reloc_ok; | 218 return bfd_reloc_ok; |
241 } | 219 } |
242 | 220 |
243 static reloc_howto_type howto_table[] = { | 221 static reloc_howto_type howto_table[] = |
| 222 { |
244 HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8",
FALSE, 0x000000ff, 0x000000ff, FALSE), | 223 HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8",
FALSE, 0x000000ff, 0x000000ff, FALSE), |
245 HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16
", FALSE, 0x0000ffff, 0x0000ffff, FALSE), | 224 HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16
", FALSE, 0x0000ffff, 0x0000ffff, FALSE), |
246 HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "32
", FALSE, 0xffffffff, 0xffffffff, FALSE), | 225 HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "32
", FALSE, 0xffffffff, 0xffffffff, FALSE), |
247 HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8"
, FALSE, 0x000000ff, 0x000000ff, TRUE), | 226 HOWTO (R_PCRBYTE, 0, 0, 8, TRUE, 0, complain_overflow_signed, special, "DISP8"
, FALSE, 0x000000ff, 0x000000ff, TRUE), |
248 HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, special, "DISP1
6", FALSE, 0x0000ffff, 0x0000ffff, TRUE), | 227 HOWTO (R_PCRWORD, 0, 1, 16, TRUE, 0, complain_overflow_signed, special, "DISP1
6", FALSE, 0x0000ffff, 0x0000ffff, TRUE), |
249 HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, special, "DISP3
2", FALSE, 0xffffffff, 0xffffffff, TRUE), | 228 HOWTO (R_PCRLONG, 0, 2, 32, TRUE, 0, complain_overflow_signed, special, "DISP3
2", FALSE, 0xffffffff, 0xffffffff, TRUE), |
250 HOWTO (R_MOV16B1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "re
laxable mov.b:16", FALSE, 0x0000ffff, 0x0000ffff, FALSE), | 229 HOWTO (R_MOV16B1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "re
laxable mov.b:16", FALSE, 0x0000ffff, 0x0000ffff, FALSE), |
251 HOWTO (R_MOV16B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "rel
axed mov.b:16", FALSE, 0x000000ff, 0x000000ff, FALSE), | 230 HOWTO (R_MOV16B2, 0, 1, 8, FALSE, 0, complain_overflow_bitfield, special, "rel
axed mov.b:16", FALSE, 0x000000ff, 0x000000ff, FALSE), |
252 HOWTO (R_JMP1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16/pc
rel", FALSE, 0x0000ffff, 0x0000ffff, FALSE), | 231 HOWTO (R_JMP1, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16/pc
rel", FALSE, 0x0000ffff, 0x0000ffff, FALSE), |
253 HOWTO (R_JMP2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pcrecl
/16", FALSE, 0x000000ff, 0x000000ff, FALSE), | 232 HOWTO (R_JMP2, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "pcrecl
/16", FALSE, 0x000000ff, 0x000000ff, FALSE), |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 | 1415 |
1437 #include "coffcode.h" | 1416 #include "coffcode.h" |
1438 | 1417 |
1439 #undef coff_bfd_get_relocated_section_contents | 1418 #undef coff_bfd_get_relocated_section_contents |
1440 #undef coff_bfd_relax_section | 1419 #undef coff_bfd_relax_section |
1441 #define coff_bfd_get_relocated_section_contents \ | 1420 #define coff_bfd_get_relocated_section_contents \ |
1442 bfd_coff_reloc16_get_relocated_section_contents | 1421 bfd_coff_reloc16_get_relocated_section_contents |
1443 #define coff_bfd_relax_section bfd_coff_reloc16_relax_section | 1422 #define coff_bfd_relax_section bfd_coff_reloc16_relax_section |
1444 | 1423 |
1445 CREATE_BIG_COFF_TARGET_VEC (h8300coff_vec, "coff-h8300", BFD_IS_RELAXABLE, 0, '_
', NULL, COFF_SWAP_TABLE) | 1424 CREATE_BIG_COFF_TARGET_VEC (h8300coff_vec, "coff-h8300", BFD_IS_RELAXABLE, 0, '_
', NULL, COFF_SWAP_TABLE) |
OLD | NEW |