OLD | NEW |
1 /* BFD back-end for TMS320C30 coff binaries. | 1 /* BFD back-end for TMS320C30 coff binaries. |
2 Copyright 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2011 | 2 Copyright 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2011, 2012 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au) | 4 Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au) |
5 | 5 |
6 This file is part of BFD, the Binary File Descriptor library. | 6 This file is part of BFD, the Binary File Descriptor library. |
7 | 7 |
8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
11 (at your option) any later version. | 11 (at your option) any later version. |
12 | 12 |
13 This program is distributed in the hope that it will be useful, | 13 This program is distributed in the hope that it will be useful, |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 GNU General Public License for more details. | 16 GNU General Public License for more details. |
17 | 17 |
18 You should have received a copy of the GNU General Public License | 18 You should have received a copy of the GNU General Public License |
19 along with this program; if not, write to the Free Software | 19 along with this program; if not, write to the Free Software |
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA | 20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA |
21 02110-1301, USA. */ | 21 02110-1301, USA. */ |
22 | 22 |
23 #include "sysdep.h" | 23 #include "sysdep.h" |
24 #include "bfd.h" | 24 #include "bfd.h" |
25 #include "libbfd.h" | 25 #include "libbfd.h" |
26 #include "bfdlink.h" | 26 #include "bfdlink.h" |
27 #include "coff/tic30.h" | 27 #include "coff/tic30.h" |
28 #include "coff/internal.h" | 28 #include "coff/internal.h" |
29 #include "libcoff.h" | 29 #include "libcoff.h" |
30 | 30 |
31 static int coff_tic30_select_reloc PARAMS ((reloc_howto_type *)); | |
32 static void rtype2howto PARAMS ((arelent *, struct internal_reloc *)); | |
33 static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbo
l **, bfd *, asection *)); | |
34 | |
35 reloc_howto_type * tic30_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_r
eal_type)); | |
36 | |
37 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1) | 31 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1) |
38 | 32 |
39 reloc_howto_type tic30_coff_howto_table[] = | 33 reloc_howto_type tic30_coff_howto_table[] = |
40 { | 34 { |
41 HOWTO (R_TIC30_ABS16, 2, 1, 16, FALSE, 0, 0, NULL, | 35 HOWTO (R_TIC30_ABS16, 2, 1, 16, FALSE, 0, 0, NULL, |
42 "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), | 36 "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), |
43 HOWTO (R_TIC30_ABS24, 2, 2, 24, FALSE, 8, complain_overflow_bitfield, NULL, | 37 HOWTO (R_TIC30_ABS24, 2, 2, 24, FALSE, 8, complain_overflow_bitfield, NULL, |
44 "24", FALSE, 0xFFFFFF00, 0xFFFFFF00, FALSE), | 38 "24", FALSE, 0xFFFFFF00, 0xFFFFFF00, FALSE), |
45 HOWTO (R_TIC30_LDP, 18, 0, 24, FALSE, 0, complain_overflow_bitfield, NULL, | 39 HOWTO (R_TIC30_LDP, 18, 0, 24, FALSE, 0, complain_overflow_bitfield, NULL, |
46 "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE), | 40 "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE), |
47 HOWTO (R_TIC30_ABS32, 2, 2, 32, FALSE, 0, complain_overflow_bitfield, NULL, | 41 HOWTO (R_TIC30_ABS32, 2, 2, 32, FALSE, 0, complain_overflow_bitfield, NULL, |
48 "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE), | 42 "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE), |
49 HOWTO (R_TIC30_PC16, 2, 1, 16, TRUE, 0, complain_overflow_signed, NULL, | 43 HOWTO (R_TIC30_PC16, 2, 1, 16, TRUE, 0, complain_overflow_signed, NULL, |
50 "PCREL", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), | 44 "PCREL", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), |
51 EMPTY_HOWTO (-1) | 45 EMPTY_HOWTO (-1) |
52 }; | 46 }; |
53 | 47 |
54 #ifndef coff_bfd_reloc_type_lookup | 48 #ifndef coff_bfd_reloc_type_lookup |
55 #define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup | 49 #define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup |
56 #define coff_bfd_reloc_name_lookup tic30_coff_reloc_name_lookup | 50 #define coff_bfd_reloc_name_lookup tic30_coff_reloc_name_lookup |
57 | 51 |
58 /* For the case statement use the code values used in tc_gen_reloc to | 52 /* For the case statement use the code values used in tc_gen_reloc to |
59 map to the howto table entries that match those in both the aout | 53 map to the howto table entries that match those in both the aout |
60 and coff implementations. */ | 54 and coff implementations. */ |
61 | 55 |
62 reloc_howto_type * | 56 static reloc_howto_type * |
63 tic30_coff_reloc_type_lookup (abfd, code) | 57 tic30_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
64 bfd *abfd ATTRIBUTE_UNUSED; | 58 » » » bfd_reloc_code_real_type code) |
65 bfd_reloc_code_real_type code; | |
66 { | 59 { |
67 switch (code) | 60 switch (code) |
68 { | 61 { |
69 case BFD_RELOC_8: | 62 case BFD_RELOC_8: |
70 case BFD_RELOC_TIC30_LDP: | 63 case BFD_RELOC_TIC30_LDP: |
71 return &tic30_coff_howto_table[2]; | 64 return &tic30_coff_howto_table[2]; |
72 case BFD_RELOC_16: | 65 case BFD_RELOC_16: |
73 return &tic30_coff_howto_table[0]; | 66 return &tic30_coff_howto_table[0]; |
74 case BFD_RELOC_24: | 67 case BFD_RELOC_24: |
75 return &tic30_coff_howto_table[1]; | 68 return &tic30_coff_howto_table[1]; |
(...skipping 21 matching lines...) Expand all Loading... |
97 return &tic30_coff_howto_table[i]; | 90 return &tic30_coff_howto_table[i]; |
98 | 91 |
99 return NULL; | 92 return NULL; |
100 } | 93 } |
101 | 94 |
102 #endif | 95 #endif |
103 | 96 |
104 /* Turn a howto into a reloc number. */ | 97 /* Turn a howto into a reloc number. */ |
105 | 98 |
106 static int | 99 static int |
107 coff_tic30_select_reloc (howto) | 100 coff_tic30_select_reloc (reloc_howto_type *howto) |
108 reloc_howto_type *howto; | |
109 { | 101 { |
110 return howto->type; | 102 return howto->type; |
111 } | 103 } |
112 | 104 |
113 #define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto) | 105 #define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto) |
114 | 106 |
115 #define BADMAG(x) TIC30BADMAG(x) | 107 #define BADMAG(x) TIC30BADMAG(x) |
116 #define TIC30 1 /* Customize coffcode.h */ | 108 #define TIC30 1 /* Customize coffcode.h */ |
117 #define __A_MAGIC_SET__ | 109 #define __A_MAGIC_SET__ |
118 | 110 |
119 /* Code to swap in the reloc */ | 111 /* Code to swap in the reloc */ |
120 #define SWAP_IN_RELOC_OFFSET H_GET_32 | 112 #define SWAP_IN_RELOC_OFFSET H_GET_32 |
121 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 | 113 #define SWAP_OUT_RELOC_OFFSET H_PUT_32 |
122 #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \ | 114 #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \ |
123 dst->r_stuff[1] = 'C'; | 115 dst->r_stuff[1] = 'C'; |
124 | 116 |
125 /* Code to turn a r_type into a howto ptr, uses the above howto table. */ | 117 /* Code to turn a r_type into a howto ptr, uses the above howto table. */ |
126 | 118 |
127 static void | 119 static void |
128 rtype2howto (internal, dst) | 120 rtype2howto (arelent *internal, struct internal_reloc *dst) |
129 arelent *internal; | |
130 struct internal_reloc *dst; | |
131 { | 121 { |
132 switch (dst->r_type) | 122 switch (dst->r_type) |
133 { | 123 { |
134 case R_TIC30_ABS16: | 124 case R_TIC30_ABS16: |
135 internal->howto = &tic30_coff_howto_table[0]; | 125 internal->howto = &tic30_coff_howto_table[0]; |
136 break; | 126 break; |
137 case R_TIC30_ABS24: | 127 case R_TIC30_ABS24: |
138 internal->howto = &tic30_coff_howto_table[1]; | 128 internal->howto = &tic30_coff_howto_table[1]; |
139 break; | 129 break; |
140 case R_TIC30_ABS32: | 130 case R_TIC30_ABS32: |
(...skipping 15 matching lines...) Expand all Loading... |
156 | 146 |
157 /* Perform any necessary magic to the addend in a reloc entry */ | 147 /* Perform any necessary magic to the addend in a reloc entry */ |
158 | 148 |
159 #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ | 149 #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \ |
160 cache_ptr->addend = ext_reloc.r_offset; | 150 cache_ptr->addend = ext_reloc.r_offset; |
161 | 151 |
162 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \ | 152 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \ |
163 reloc_processing(relent, reloc, symbols, abfd, section) | 153 reloc_processing(relent, reloc, symbols, abfd, section) |
164 | 154 |
165 static void | 155 static void |
166 reloc_processing (relent, reloc, symbols, abfd, section) | 156 reloc_processing (arelent *relent, |
167 arelent *relent; | 157 » » struct internal_reloc *reloc, |
168 struct internal_reloc *reloc; | 158 » » asymbol **symbols, |
169 asymbol **symbols; | 159 » » bfd *abfd, |
170 bfd *abfd; | 160 » » asection *section) |
171 asection *section; | |
172 { | 161 { |
173 relent->address = reloc->r_vaddr; | 162 relent->address = reloc->r_vaddr; |
174 rtype2howto (relent, reloc); | 163 rtype2howto (relent, reloc); |
175 | 164 |
176 if (reloc->r_symndx > 0) | 165 if (reloc->r_symndx > 0) |
177 relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; | 166 relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; |
178 else | 167 else |
179 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; | 168 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; |
180 | 169 |
181 relent->addend = reloc->r_offset; | 170 relent->addend = reloc->r_offset; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 BFD_JUMP_TABLE_SYMBOLS (coff), | 214 BFD_JUMP_TABLE_SYMBOLS (coff), |
226 BFD_JUMP_TABLE_RELOCS (coff), | 215 BFD_JUMP_TABLE_RELOCS (coff), |
227 BFD_JUMP_TABLE_WRITE (coff), | 216 BFD_JUMP_TABLE_WRITE (coff), |
228 BFD_JUMP_TABLE_LINK (coff), | 217 BFD_JUMP_TABLE_LINK (coff), |
229 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | 218 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), |
230 | 219 |
231 NULL, | 220 NULL, |
232 | 221 |
233 COFF_SWAP_TABLE | 222 COFF_SWAP_TABLE |
234 }; | 223 }; |
OLD | NEW |