]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD back-end for TMS320C30 a.out binaries. |
72adc230 AM |
2 | Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 |
3 | Free Software Foundation, Inc. | |
252b5132 RH |
4 | Contributed by Steven Haworth ([email protected]) |
5 | ||
6 | This file is part of BFD, the Binary File Descriptor library. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
21 | 02111-1307, USA. */ | |
22 | ||
23 | #define TARGET_IS_BIG_ENDIAN_P | |
24 | #define N_HEADER_IN_TEXT(x) 1 | |
252b5132 RH |
25 | #define TEXT_START_ADDR 1024 |
26 | #define TARGET_PAGE_SIZE 128 | |
27 | #define SEGMENT_SIZE TARGET_PAGE_SIZE | |
28 | #define DEFAULT_ARCH bfd_arch_tic30 | |
29 | #define ARCH_SIZE 32 | |
30 | ||
e43d48cc AM |
31 | /* Do not "beautify" the CONCAT* macro args. Traditional C will not |
32 | remove whitespace added here, and thus will fail to concatenate | |
33 | the tokens. */ | |
34 | #define MY(OP) CONCAT2 (tic30_aout_,OP) | |
252b5132 | 35 | #define TARGETNAME "a.out-tic30" |
e43d48cc | 36 | #define NAME(x,y) CONCAT3 (tic30_aout,_32_,y) |
252b5132 RH |
37 | |
38 | #include "bfd.h" | |
39 | #include "sysdep.h" | |
40 | #include "libaout.h" | |
41 | ||
42 | #include "aout/aout64.h" | |
43 | #include "aout/stab_gnu.h" | |
44 | #include "aout/ar.h" | |
45 | ||
46 | static bfd_reloc_status_type tic30_aout_fix_16 | |
47 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
48 | static bfd_reloc_status_type tic30_aout_fix_32 | |
49 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
50 | static bfd_reloc_status_type tic30_aout_fix_pcrel_16 | |
51 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
52 | static reloc_howto_type *tic30_aout_reloc_howto | |
53 | PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *)); | |
54 | static bfd_reloc_status_type tic30_aout_relocate_contents | |
55 | PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *)); | |
56 | static bfd_reloc_status_type tic30_aout_final_link_relocate | |
57 | PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma, | |
58 | bfd_vma, bfd_vma)); | |
b34976b6 AM |
59 | static const bfd_target *tic30_aout_object_p |
60 | PARAMS ((bfd *)); | |
61 | static bfd_boolean tic30_aout_write_object_contents | |
62 | PARAMS ((bfd *)); | |
63 | static bfd_boolean tic30_aout_set_sizes | |
64 | PARAMS ((bfd *)); | |
65 | static const bfd_target * tic30_aout_callback | |
66 | PARAMS ((bfd *)); | |
67 | static bfd_boolean MY_bfd_copy_private_section_data | |
dc810e39 | 68 | PARAMS ((bfd *, asection *, bfd *, asection *)); |
b34976b6 AM |
69 | static bfd_boolean MY_bfd_final_link |
70 | PARAMS ((bfd *, struct bfd_link_info *)); | |
dc810e39 AM |
71 | reloc_howto_type * tic30_aout_reloc_type_lookup |
72 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
73 | enum machine_type tic30_aout_machine_type | |
b34976b6 AM |
74 | PARAMS ((enum bfd_architecture, unsigned long, bfd_boolean *)); |
75 | bfd_boolean tic30_aout_set_arch_mach | |
dc810e39 AM |
76 | PARAMS ((bfd *, enum bfd_architecture, unsigned long)); |
77 | ||
78 | #define MY_reloc_howto(BFD, REL, IN, EX, PC) \ | |
79 | tic30_aout_reloc_howto(BFD, REL, &IN, &EX, &PC) | |
252b5132 RH |
80 | #define MY_final_link_relocate tic30_aout_final_link_relocate |
81 | #define MY_object_p tic30_aout_object_p | |
82 | #define MY_mkobject NAME(aout,mkobject) | |
83 | #define MY_write_object_contents tic30_aout_write_object_contents | |
84 | #define MY_set_sizes tic30_aout_set_sizes | |
85 | ||
86 | #ifndef MY_exec_hdr_flags | |
87 | #define MY_exec_hdr_flags 1 | |
88 | #endif | |
89 | ||
90 | #ifndef MY_backend_data | |
91 | ||
92 | #ifndef MY_zmagic_contiguous | |
93 | #define MY_zmagic_contiguous 0 | |
94 | #endif | |
95 | #ifndef MY_text_includes_header | |
96 | #define MY_text_includes_header 0 | |
97 | #endif | |
98 | #ifndef MY_entry_is_text_address | |
99 | #define MY_entry_is_text_address 0 | |
100 | #endif | |
101 | #ifndef MY_exec_header_not_counted | |
102 | #define MY_exec_header_not_counted 1 | |
103 | #endif | |
104 | #ifndef MY_add_dynamic_symbols | |
105 | #define MY_add_dynamic_symbols 0 | |
106 | #endif | |
107 | #ifndef MY_add_one_symbol | |
108 | #define MY_add_one_symbol 0 | |
109 | #endif | |
110 | #ifndef MY_link_dynamic_object | |
111 | #define MY_link_dynamic_object 0 | |
112 | #endif | |
113 | #ifndef MY_write_dynamic_symbol | |
114 | #define MY_write_dynamic_symbol 0 | |
115 | #endif | |
116 | #ifndef MY_check_dynamic_reloc | |
117 | #define MY_check_dynamic_reloc 0 | |
118 | #endif | |
119 | #ifndef MY_finish_dynamic_link | |
120 | #define MY_finish_dynamic_link 0 | |
121 | #endif | |
122 | ||
dc810e39 | 123 | static const struct aout_backend_data tic30_aout_backend_data = |
252b5132 RH |
124 | { |
125 | MY_zmagic_contiguous, | |
126 | MY_text_includes_header, | |
127 | MY_entry_is_text_address, | |
128 | MY_exec_hdr_flags, | |
129 | 0, /* text vma? */ | |
130 | MY_set_sizes, | |
131 | MY_exec_header_not_counted, | |
132 | MY_add_dynamic_symbols, | |
133 | MY_add_one_symbol, | |
134 | MY_link_dynamic_object, | |
135 | MY_write_dynamic_symbol, | |
136 | MY_check_dynamic_reloc, | |
137 | MY_finish_dynamic_link | |
138 | }; | |
139 | #define MY_backend_data &tic30_aout_backend_data | |
140 | #endif | |
141 | ||
142 | /* FIXME: This is wrong. aoutx.h should really only be included by | |
143 | aout32.c. */ | |
144 | ||
145 | #include "aoutx.h" | |
146 | ||
147 | /* This table lists the relocation types for the TMS320C30. There are | |
148 | only a few relocations required, and all must be divided by 4 (>> | |
149 | 2) to get the 32-bit addresses in the format the TMS320C30 likes | |
c4dfa77f | 150 | it. */ |
252b5132 | 151 | reloc_howto_type tic30_aout_howto_table[] = |
1725a96e NC |
152 | { |
153 | EMPTY_HOWTO (-1), | |
b34976b6 AM |
154 | HOWTO (1, 2, 1, 16, FALSE, 0, 0, tic30_aout_fix_16, |
155 | "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE), | |
156 | HOWTO (2, 2, 2, 24, FALSE, 0, complain_overflow_bitfield, NULL, | |
157 | "24", FALSE, 0x00FFFFFF, 0x00FFFFFF, FALSE), | |
158 | HOWTO (3, 18, 3, 24, FALSE, 0, complain_overflow_bitfield, NULL, | |
159 | "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE), | |
160 | HOWTO (4, 2, 4, 32, FALSE, 0, complain_overflow_bitfield, tic30_aout_fix_32, | |
161 | "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE), | |
162 | HOWTO (5, 2, 1, 16, TRUE, 0, complain_overflow_signed, | |
163 | tic30_aout_fix_pcrel_16, "PCREL", TRUE, 0x0000FFFF, 0x0000FFFF, TRUE), | |
1725a96e NC |
164 | EMPTY_HOWTO (-1), |
165 | EMPTY_HOWTO (-1), | |
166 | EMPTY_HOWTO (-1), | |
167 | EMPTY_HOWTO (-1), | |
168 | EMPTY_HOWTO (-1) | |
169 | }; | |
170 | ||
171 | extern reloc_howto_type *NAME (aout, reloc_type_lookup) | |
b34976b6 | 172 | PARAMS ((bfd *, bfd_reloc_code_real_type)); |
252b5132 RH |
173 | |
174 | reloc_howto_type * | |
175 | tic30_aout_reloc_type_lookup (abfd, code) | |
5f771d47 | 176 | bfd *abfd ATTRIBUTE_UNUSED; |
252b5132 RH |
177 | bfd_reloc_code_real_type code; |
178 | { | |
179 | switch (code) | |
180 | { | |
181 | case BFD_RELOC_8: | |
182 | case BFD_RELOC_TIC30_LDP: | |
183 | return &tic30_aout_howto_table[3]; | |
184 | case BFD_RELOC_16: | |
185 | return &tic30_aout_howto_table[1]; | |
186 | case BFD_RELOC_24: | |
187 | return &tic30_aout_howto_table[2]; | |
188 | case BFD_RELOC_16_PCREL: | |
189 | return &tic30_aout_howto_table[5]; | |
190 | case BFD_RELOC_32: | |
191 | return &tic30_aout_howto_table[4]; | |
192 | default: | |
193 | return (reloc_howto_type *) NULL; | |
194 | } | |
195 | } | |
196 | ||
197 | static reloc_howto_type * | |
198 | tic30_aout_reloc_howto (abfd, relocs, r_index, r_extern, r_pcrel) | |
199 | bfd *abfd; | |
200 | struct reloc_std_external *relocs; | |
201 | int *r_index; | |
202 | int *r_extern; | |
203 | int *r_pcrel; | |
204 | { | |
205 | unsigned int r_length; | |
206 | unsigned int r_pcrel_done; | |
207 | int index; | |
208 | ||
209 | *r_pcrel = 0; | |
210 | if (bfd_header_big_endian (abfd)) | |
211 | { | |
212 | *r_index = ((relocs->r_index[0] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[2]); | |
213 | *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_BIG)); | |
214 | r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_BIG)); | |
215 | r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) >> RELOC_STD_BITS_LENGTH_SH_BIG); | |
216 | } | |
217 | else | |
218 | { | |
219 | *r_index = ((relocs->r_index[2] << 16) | (relocs->r_index[1] << 8) | relocs->r_index[0]); | |
220 | *r_extern = (0 != (relocs->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE)); | |
221 | r_pcrel_done = (0 != (relocs->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE)); | |
222 | r_length = ((relocs->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) >> RELOC_STD_BITS_LENGTH_SH_LITTLE); | |
223 | } | |
224 | index = r_length + 4 * r_pcrel_done; | |
225 | return tic30_aout_howto_table + index; | |
226 | } | |
227 | ||
228 | /* This function is used as a callback for 16-bit relocs. This is | |
229 | required for relocations between segments. A line in aoutx.h | |
230 | requires that any relocations for the data section should point to | |
231 | the end of the aligned text section, plus an offset. By default, | |
232 | this does not happen, therefore this function takes care of | |
c4dfa77f | 233 | that. */ |
252b5132 RH |
234 | |
235 | static bfd_reloc_status_type | |
236 | tic30_aout_fix_16 (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) | |
237 | bfd *abfd; | |
238 | arelent *reloc_entry; | |
239 | asymbol *symbol; | |
240 | PTR data; | |
5f771d47 | 241 | asection *input_section ATTRIBUTE_UNUSED; |
252b5132 | 242 | bfd *output_bfd; |
5f771d47 | 243 | char **error_message ATTRIBUTE_UNUSED; |
252b5132 RH |
244 | { |
245 | bfd_vma relocation; | |
246 | ||
c4dfa77f | 247 | /* Make sure that the symbol's section is defined. */ |
252b5132 RH |
248 | if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0) |
249 | return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; | |
250 | /* Get the size of the input section and turn it into the TMS320C30 | |
c4dfa77f | 251 | 32-bit address format. */ |
252b5132 RH |
252 | relocation = (symbol->section->vma >> 2); |
253 | relocation += bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address); | |
254 | bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address); | |
255 | return bfd_reloc_ok; | |
256 | } | |
257 | ||
258 | /* This function does the same thing as tic30_aout_fix_16 except for 32 | |
c4dfa77f | 259 | bit relocations. */ |
252b5132 RH |
260 | |
261 | static bfd_reloc_status_type | |
262 | tic30_aout_fix_32 (abfd, reloc_entry, symbol, data, input_section, | |
263 | output_bfd, error_message) | |
264 | bfd *abfd; | |
265 | arelent *reloc_entry; | |
266 | asymbol *symbol; | |
267 | PTR data; | |
5f771d47 | 268 | asection *input_section ATTRIBUTE_UNUSED; |
252b5132 | 269 | bfd *output_bfd; |
5f771d47 | 270 | char **error_message ATTRIBUTE_UNUSED; |
252b5132 RH |
271 | { |
272 | bfd_vma relocation; | |
273 | ||
c4dfa77f | 274 | /* Make sure that the symbol's section is defined. */ |
252b5132 RH |
275 | if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0) |
276 | return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined; | |
277 | /* Get the size of the input section and turn it into the TMS320C30 | |
c4dfa77f | 278 | 32-bit address format. */ |
252b5132 RH |
279 | relocation = (symbol->section->vma >> 2); |
280 | relocation += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); | |
281 | bfd_put_32 (abfd, relocation, (bfd_byte *) data + reloc_entry->address); | |
282 | return bfd_reloc_ok; | |
283 | } | |
284 | ||
285 | /* This function is used to work out pc-relative offsets for the | |
286 | TMS320C30. The data already placed by md_pcrel_from within gas is | |
287 | useless for a relocation, so we just get the offset value and place | |
288 | a version of this within the object code. | |
289 | tic30_aout_final_link_relocate will then calculate the required | |
c4dfa77f | 290 | relocation to add on to the value in the object code. */ |
252b5132 RH |
291 | |
292 | static bfd_reloc_status_type | |
293 | tic30_aout_fix_pcrel_16 (abfd, reloc_entry, symbol, data, input_section, | |
294 | output_bfd, error_message) | |
295 | bfd *abfd; | |
296 | arelent *reloc_entry; | |
5f771d47 | 297 | asymbol *symbol ATTRIBUTE_UNUSED; |
252b5132 | 298 | PTR data; |
5f771d47 ILT |
299 | asection *input_section ATTRIBUTE_UNUSED; |
300 | bfd *output_bfd ATTRIBUTE_UNUSED; | |
301 | char **error_message ATTRIBUTE_UNUSED; | |
252b5132 RH |
302 | { |
303 | bfd_vma relocation = 1; | |
304 | bfd_byte offset_data = bfd_get_8 (abfd, (bfd_byte *) data + reloc_entry->address - 1); | |
305 | ||
306 | /* The byte before the location of the fix contains bits 23-16 of | |
307 | the pcrel instruction. Bit 21 is set for a delayed instruction | |
c4dfa77f | 308 | which requires on offset of 3 instead of 1. */ |
252b5132 RH |
309 | if (offset_data & 0x20) |
310 | relocation -= 3; | |
311 | else | |
312 | relocation -= 1; | |
313 | bfd_put_16 (abfd, relocation, (bfd_byte *) data + reloc_entry->address); | |
314 | return bfd_reloc_ok; | |
315 | } | |
316 | ||
317 | /* These macros will get 24-bit values from the bfd definition. | |
c4dfa77f | 318 | Big-endian only. */ |
beb0d161 KH |
319 | #define bfd_getb_24(BFD,ADDR) \ |
320 | (bfd_get_8 (BFD, ADDR ) << 16) | \ | |
321 | (bfd_get_8 (BFD, ADDR + 1) << 8) | \ | |
322 | (bfd_get_8 (BFD, ADDR + 2) ) | |
323 | ||
324 | #define bfd_putb_24(BFD,DATA,ADDR) \ | |
325 | bfd_put_8 (BFD, (bfd_byte) ((DATA >> 16) & 0xFF), ADDR ); \ | |
326 | bfd_put_8 (BFD, (bfd_byte) ((DATA >> 8) & 0xFF), ADDR + 1); \ | |
327 | bfd_put_8 (BFD, (bfd_byte) ( DATA & 0xFF), ADDR + 2) | |
252b5132 RH |
328 | |
329 | /* Set parameters about this a.out file that are machine-dependent. | |
330 | This routine is called from some_aout_object_p just before it returns. */ | |
331 | ||
332 | static const bfd_target * | |
333 | tic30_aout_callback (abfd) | |
334 | bfd *abfd; | |
335 | { | |
336 | struct internal_exec *execp = exec_hdr (abfd); | |
337 | unsigned int arch_align_power; | |
338 | unsigned long arch_align; | |
339 | ||
1725a96e | 340 | /* Calculate the file positions of the parts of a newly read aout header. */ |
252b5132 RH |
341 | obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp); |
342 | ||
1725a96e | 343 | /* The virtual memory addresses of the sections. */ |
252b5132 RH |
344 | obj_textsec (abfd)->vma = N_TXTADDR (*execp); |
345 | obj_datasec (abfd)->vma = N_DATADDR (*execp); | |
346 | obj_bsssec (abfd)->vma = N_BSSADDR (*execp); | |
347 | ||
348 | obj_textsec (abfd)->lma = obj_textsec (abfd)->vma; | |
349 | obj_datasec (abfd)->lma = obj_datasec (abfd)->vma; | |
350 | obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma; | |
351 | ||
1725a96e | 352 | /* The file offsets of the sections. */ |
252b5132 RH |
353 | obj_textsec (abfd)->filepos = N_TXTOFF (*execp); |
354 | obj_datasec (abfd)->filepos = N_DATOFF (*execp); | |
355 | ||
1725a96e | 356 | /* The file offsets of the relocation info. */ |
252b5132 RH |
357 | obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp); |
358 | obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp); | |
359 | ||
360 | /* The file offsets of the string table and symbol table. */ | |
361 | obj_sym_filepos (abfd) = N_SYMOFF (*execp); | |
362 | obj_str_filepos (abfd) = N_STROFF (*execp); | |
363 | ||
364 | /* Determine the architecture and machine type of the object file. */ | |
365 | #ifdef SET_ARCH_MACH | |
366 | SET_ARCH_MACH (abfd, *execp); | |
367 | #else | |
dc810e39 | 368 | bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L); |
252b5132 RH |
369 | #endif |
370 | ||
371 | /* Now that we know the architecture, set the alignments of the | |
372 | sections. This is normally done by NAME(aout,new_section_hook), | |
373 | but when the initial sections were created the architecture had | |
374 | not yet been set. However, for backward compatibility, we don't | |
375 | set the alignment power any higher than as required by the size | |
376 | of the section. */ | |
377 | arch_align_power = bfd_get_arch_info (abfd)->section_align_power; | |
378 | arch_align = 1 << arch_align_power; | |
379 | if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align) | |
380 | == obj_textsec (abfd)->_raw_size) | |
381 | && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align) | |
382 | == obj_datasec (abfd)->_raw_size) | |
383 | && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align) | |
384 | == obj_bsssec (abfd)->_raw_size)) | |
385 | { | |
386 | obj_textsec (abfd)->alignment_power = arch_align_power; | |
387 | obj_datasec (abfd)->alignment_power = arch_align_power; | |
388 | obj_bsssec (abfd)->alignment_power = arch_align_power; | |
389 | } | |
390 | return abfd->xvec; | |
391 | } | |
392 | ||
393 | static bfd_reloc_status_type | |
394 | tic30_aout_final_link_relocate (howto, input_bfd, input_section, contents, | |
395 | address, value, addend) | |
396 | reloc_howto_type *howto; | |
397 | bfd *input_bfd; | |
398 | asection *input_section; | |
399 | bfd_byte *contents; | |
400 | bfd_vma address; | |
401 | bfd_vma value; | |
402 | bfd_vma addend; | |
403 | { | |
404 | bfd_vma relocation; | |
405 | ||
406 | if (address > input_section->_raw_size) | |
407 | return bfd_reloc_outofrange; | |
408 | ||
409 | relocation = value + addend; | |
410 | if (howto->pc_relative) | |
411 | { | |
412 | relocation -= (input_section->output_section->vma + input_section->output_offset); | |
413 | if (howto->pcrel_offset) | |
414 | relocation -= address; | |
415 | } | |
416 | return tic30_aout_relocate_contents (howto, input_bfd, relocation, | |
417 | contents + address); | |
418 | } | |
419 | ||
420 | bfd_reloc_status_type | |
421 | tic30_aout_relocate_contents (howto, input_bfd, relocation, location) | |
422 | reloc_howto_type *howto; | |
423 | bfd *input_bfd; | |
424 | bfd_vma relocation; | |
425 | bfd_byte *location; | |
426 | { | |
427 | bfd_vma x; | |
b34976b6 | 428 | bfd_boolean overflow; |
252b5132 RH |
429 | |
430 | if (howto->size < 0) | |
431 | relocation = -relocation; | |
432 | ||
433 | switch (howto->size) | |
434 | { | |
435 | default: | |
436 | case 0: | |
437 | abort (); | |
438 | break; | |
439 | case 1: | |
440 | x = bfd_get_16 (input_bfd, location); | |
441 | break; | |
442 | case 2: | |
443 | x = bfd_getb_24 (input_bfd, location); | |
444 | break; | |
445 | case 3: | |
446 | x = bfd_get_8 (input_bfd, location); | |
447 | break; | |
448 | case 4: | |
449 | x = bfd_get_32 (input_bfd, location); | |
450 | break; | |
451 | } | |
1725a96e | 452 | |
b34976b6 | 453 | overflow = FALSE; |
1725a96e | 454 | |
252b5132 RH |
455 | if (howto->complain_on_overflow != complain_overflow_dont) |
456 | { | |
457 | bfd_vma check; | |
458 | bfd_signed_vma signed_check; | |
459 | bfd_vma add; | |
460 | bfd_signed_vma signed_add; | |
461 | ||
462 | if (howto->rightshift == 0) | |
463 | { | |
464 | check = relocation; | |
465 | signed_check = (bfd_signed_vma) relocation; | |
466 | } | |
467 | else | |
468 | { | |
469 | check = relocation >> howto->rightshift; | |
470 | if ((bfd_signed_vma) relocation >= 0) | |
471 | signed_check = check; | |
472 | else | |
473 | signed_check = (check | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->rightshift))); | |
474 | } | |
475 | add = x & howto->src_mask; | |
476 | signed_add = add; | |
477 | if ((add & (((~howto->src_mask) >> 1) & howto->src_mask)) != 0) | |
478 | signed_add -= (((~howto->src_mask) >> 1) & howto->src_mask) << 1; | |
479 | if (howto->bitpos == 0) | |
480 | { | |
481 | check += add; | |
482 | signed_check += signed_add; | |
483 | } | |
484 | else | |
485 | { | |
486 | check += add >> howto->bitpos; | |
487 | if (signed_add >= 0) | |
488 | signed_check += add >> howto->bitpos; | |
489 | else | |
490 | signed_check += ((add >> howto->bitpos) | ((bfd_vma) - 1 & ~((bfd_vma) - 1 >> howto->bitpos))); | |
491 | } | |
492 | switch (howto->complain_on_overflow) | |
493 | { | |
494 | case complain_overflow_signed: | |
495 | { | |
496 | bfd_signed_vma reloc_signed_max = (1 << (howto->bitsize - 1)) - 1; | |
497 | bfd_signed_vma reloc_signed_min = ~reloc_signed_max; | |
498 | if (signed_check > reloc_signed_max || signed_check < reloc_signed_min) | |
b34976b6 | 499 | overflow = TRUE; |
252b5132 RH |
500 | } |
501 | break; | |
502 | case complain_overflow_unsigned: | |
503 | { | |
504 | bfd_vma reloc_unsigned_max = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; | |
505 | if (check > reloc_unsigned_max) | |
b34976b6 | 506 | overflow = TRUE; |
252b5132 RH |
507 | } |
508 | break; | |
509 | case complain_overflow_bitfield: | |
510 | { | |
511 | bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1; | |
dc810e39 AM |
512 | if ((check & ~reloc_bits) != 0 |
513 | && (((bfd_vma) signed_check & ~reloc_bits) | |
514 | != ((bfd_vma) -1 & ~reloc_bits))) | |
b34976b6 | 515 | overflow = TRUE; |
252b5132 RH |
516 | } |
517 | break; | |
518 | default: | |
519 | abort (); | |
520 | } | |
521 | } | |
522 | relocation >>= (bfd_vma) howto->rightshift; | |
523 | relocation <<= (bfd_vma) howto->bitpos; | |
524 | x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)); | |
525 | switch (howto->size) | |
526 | { | |
527 | default: | |
528 | case 0: | |
529 | abort (); | |
530 | break; | |
531 | case 1: | |
532 | bfd_put_16 (input_bfd, x, location); | |
533 | break; | |
534 | case 2: | |
535 | bfd_putb_24 (input_bfd, x, location); | |
536 | break; | |
537 | case 3: | |
538 | bfd_put_8 (input_bfd, x, location); | |
539 | break; | |
540 | case 4: | |
541 | bfd_put_32 (input_bfd, x, location); | |
542 | break; | |
543 | } | |
544 | return overflow ? bfd_reloc_overflow : bfd_reloc_ok; | |
545 | } | |
546 | ||
1725a96e | 547 | /* Finish up the reading of an a.out file header. */ |
252b5132 RH |
548 | |
549 | static const bfd_target * | |
550 | tic30_aout_object_p (abfd) | |
551 | bfd *abfd; | |
552 | { | |
1725a96e NC |
553 | struct external_exec exec_bytes; /* Raw exec header from file. */ |
554 | struct internal_exec exec; /* Cleaned-up exec header. */ | |
252b5132 | 555 | const bfd_target *target; |
dc810e39 | 556 | bfd_size_type amt = EXEC_BYTES_SIZE; |
252b5132 | 557 | |
dc810e39 | 558 | if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt) |
252b5132 RH |
559 | { |
560 | if (bfd_get_error () != bfd_error_system_call) | |
561 | bfd_set_error (bfd_error_wrong_format); | |
562 | return 0; | |
563 | } | |
564 | ||
565 | #ifdef SWAP_MAGIC | |
566 | exec.a_info = SWAP_MAGIC (exec_bytes.e_info); | |
567 | #else | |
dc810e39 | 568 | exec.a_info = H_GET_32 (abfd, exec_bytes.e_info); |
252b5132 RH |
569 | #endif /* SWAP_MAGIC */ |
570 | ||
571 | if (N_BADMAG (exec)) | |
572 | return 0; | |
573 | #ifdef MACHTYPE_OK | |
574 | if (!(MACHTYPE_OK (N_MACHTYPE (exec)))) | |
575 | return 0; | |
576 | #endif | |
577 | ||
578 | NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec); | |
579 | ||
580 | #ifdef SWAP_MAGIC | |
581 | /* swap_exec_header_in read in a_info with the wrong byte order */ | |
582 | exec.a_info = SWAP_MAGIC (exec_bytes.e_info); | |
583 | #endif /* SWAP_MAGIC */ | |
584 | ||
585 | target = NAME (aout, some_aout_object_p) (abfd, &exec, tic30_aout_callback); | |
586 | ||
587 | #ifdef ENTRY_CAN_BE_ZERO | |
588 | /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage) | |
1725a96e NC |
589 | means that it isn't obvious if EXEC_P should be set. |
590 | All of the following must be true for an executable: | |
591 | There must be no relocations, the bfd can be neither an | |
592 | archive nor an archive element, and the file must be executable. */ | |
252b5132 RH |
593 | |
594 | if (exec.a_trsize + exec.a_drsize == 0 | |
595 | && bfd_get_format (abfd) == bfd_object && abfd->my_archive == NULL) | |
596 | { | |
597 | struct stat buf; | |
598 | #ifndef S_IXUSR | |
599 | #define S_IXUSR 0100 /* Execute by owner. */ | |
600 | #endif | |
601 | if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR)) | |
602 | abfd->flags |= EXEC_P; | |
603 | } | |
604 | #endif /* ENTRY_CAN_BE_ZERO */ | |
605 | ||
606 | return target; | |
607 | } | |
608 | ||
609 | /* Copy private section data. This actually does nothing with the | |
610 | sections. It copies the subformat field. We copy it here, because | |
611 | we need to know whether this is a QMAGIC file before we set the | |
612 | section contents, and copy_private_bfd_data is not called until | |
613 | after the section contents have been set. */ | |
614 | ||
b34976b6 | 615 | static bfd_boolean |
252b5132 RH |
616 | MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) |
617 | bfd *ibfd; | |
5f771d47 | 618 | asection *isec ATTRIBUTE_UNUSED; |
252b5132 | 619 | bfd *obfd; |
5f771d47 | 620 | asection *osec ATTRIBUTE_UNUSED; |
252b5132 RH |
621 | { |
622 | if (bfd_get_flavour (obfd) == bfd_target_aout_flavour) | |
623 | obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); | |
b34976b6 | 624 | return TRUE; |
252b5132 RH |
625 | } |
626 | ||
627 | /* Write an object file. | |
628 | Section contents have already been written. We write the | |
629 | file header, symbols, and relocation. */ | |
630 | ||
b34976b6 | 631 | static bfd_boolean |
252b5132 RH |
632 | tic30_aout_write_object_contents (abfd) |
633 | bfd *abfd; | |
634 | { | |
635 | struct external_exec exec_bytes; | |
636 | struct internal_exec *execp = exec_hdr (abfd); | |
637 | ||
252b5132 | 638 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; |
8ba8a462 | 639 | |
252b5132 | 640 | { |
1725a96e | 641 | bfd_size_type text_size; /* Dummy vars. */ |
252b5132 | 642 | file_ptr text_end; |
1725a96e | 643 | |
252b5132 RH |
644 | if (adata (abfd).magic == undecided_magic) |
645 | NAME (aout, adjust_sizes_and_vmas) (abfd, &text_size, &text_end); | |
646 | ||
647 | execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; | |
648 | execp->a_entry = bfd_get_start_address (abfd); | |
649 | ||
650 | execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * obj_reloc_entry_size (abfd)); | |
651 | execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * obj_reloc_entry_size (abfd)); | |
652 | NAME (aout, swap_exec_header_out) (abfd, execp, &exec_bytes); | |
653 | ||
654 | if (adata (abfd).exec_bytes_size > 0) | |
655 | { | |
dc810e39 | 656 | bfd_size_type amt; |
252b5132 | 657 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
b34976b6 | 658 | return FALSE; |
dc810e39 AM |
659 | amt = adata (abfd).exec_bytes_size; |
660 | if (bfd_bwrite ((PTR) &exec_bytes, amt, abfd) != amt) | |
b34976b6 | 661 | return FALSE; |
252b5132 | 662 | } |
252b5132 | 663 | |
1725a96e | 664 | /* Now write out reloc info, followed by syms and strings. */ |
252b5132 RH |
665 | if (bfd_get_outsymbols (abfd) != (asymbol **) NULL |
666 | && bfd_get_symcount (abfd) != 0) | |
667 | { | |
668 | if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*execp)), SEEK_SET) != 0) | |
b34976b6 | 669 | return FALSE; |
252b5132 RH |
670 | |
671 | if (!NAME (aout, write_syms) (abfd)) | |
b34976b6 | 672 | return FALSE; |
252b5132 RH |
673 | } |
674 | ||
675 | if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0) | |
b34976b6 | 676 | return FALSE; |
252b5132 | 677 | if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd))) |
b34976b6 | 678 | return FALSE; |
252b5132 RH |
679 | |
680 | if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0) | |
b34976b6 | 681 | return FALSE; |
252b5132 | 682 | if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd))) |
b34976b6 | 683 | return FALSE; |
252b5132 RH |
684 | } |
685 | ||
b34976b6 | 686 | return TRUE; |
252b5132 RH |
687 | } |
688 | ||
b34976b6 | 689 | static bfd_boolean |
252b5132 RH |
690 | tic30_aout_set_sizes (abfd) |
691 | bfd *abfd; | |
692 | { | |
693 | adata (abfd).page_size = TARGET_PAGE_SIZE; | |
694 | ||
695 | #ifdef SEGMENT_SIZE | |
696 | adata (abfd).segment_size = SEGMENT_SIZE; | |
697 | #else | |
698 | adata (abfd).segment_size = TARGET_PAGE_SIZE; | |
699 | #endif | |
700 | ||
701 | #ifdef ZMAGIC_DISK_BLOCK_SIZE | |
702 | adata (abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE; | |
703 | #else | |
704 | adata (abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE; | |
705 | #endif | |
706 | ||
707 | adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; | |
708 | ||
b34976b6 | 709 | return TRUE; |
252b5132 RH |
710 | } |
711 | ||
712 | #ifndef MY_final_link_callback | |
713 | ||
714 | /* Callback for the final_link routine to set the section offsets. */ | |
715 | ||
716 | static void MY_final_link_callback | |
717 | PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *)); | |
718 | ||
719 | static void | |
720 | MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff) | |
721 | bfd *abfd; | |
722 | file_ptr *ptreloff; | |
723 | file_ptr *pdreloff; | |
724 | file_ptr *psymoff; | |
725 | { | |
726 | struct internal_exec *execp = exec_hdr (abfd); | |
727 | ||
728 | *ptreloff = obj_datasec (abfd)->filepos + execp->a_data; | |
729 | *pdreloff = *ptreloff + execp->a_trsize; | |
730 | *psymoff = *pdreloff + execp->a_drsize;; | |
731 | } | |
732 | ||
733 | #endif | |
734 | ||
735 | #ifndef MY_bfd_final_link | |
736 | ||
737 | /* Final link routine. We need to use a call back to get the correct | |
738 | offsets in the output file. */ | |
739 | ||
b34976b6 | 740 | static bfd_boolean |
252b5132 RH |
741 | MY_bfd_final_link (abfd, info) |
742 | bfd *abfd; | |
743 | struct bfd_link_info *info; | |
744 | { | |
745 | struct internal_exec *execp = exec_hdr (abfd); | |
746 | file_ptr pos; | |
747 | bfd_vma vma = 0; | |
748 | int pad; | |
749 | ||
750 | /* Set the executable header size to 0, as we don't want one for an | |
c4dfa77f | 751 | output. */ |
252b5132 RH |
752 | adata (abfd).exec_bytes_size = 0; |
753 | pos = adata (abfd).exec_bytes_size; | |
754 | /* Text. */ | |
755 | vma = info->create_object_symbols_section->vma; | |
756 | pos += vma; | |
757 | obj_textsec (abfd)->filepos = pos; | |
758 | obj_textsec (abfd)->vma = vma; | |
759 | obj_textsec (abfd)->user_set_vma = 1; | |
760 | pos += obj_textsec (abfd)->_raw_size; | |
761 | vma += obj_textsec (abfd)->_raw_size; | |
762 | ||
763 | /* Data. */ | |
764 | if (abfd->flags & D_PAGED) | |
765 | { | |
766 | if (info->create_object_symbols_section->next->vma > 0) | |
767 | obj_datasec (abfd)->vma = info->create_object_symbols_section->next->vma; | |
768 | else | |
769 | obj_datasec (abfd)->vma = BFD_ALIGN (vma, adata (abfd).segment_size); | |
770 | } | |
771 | else | |
772 | { | |
773 | obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4); | |
774 | } | |
1725a96e | 775 | |
252b5132 | 776 | if (obj_datasec (abfd)->vma < vma) |
1725a96e NC |
777 | obj_datasec (abfd)->vma = BFD_ALIGN (vma, 4); |
778 | ||
252b5132 RH |
779 | obj_datasec (abfd)->user_set_vma = 1; |
780 | vma = obj_datasec (abfd)->vma; | |
781 | obj_datasec (abfd)->filepos = vma + adata (abfd).exec_bytes_size; | |
782 | execp->a_text = vma - obj_textsec (abfd)->vma; | |
783 | obj_textsec (abfd)->_raw_size = execp->a_text; | |
784 | ||
785 | /* Since BSS follows data immediately, see if it needs alignment. */ | |
786 | vma += obj_datasec (abfd)->_raw_size; | |
787 | pad = align_power (vma, obj_bsssec (abfd)->alignment_power) - vma; | |
788 | obj_datasec (abfd)->_raw_size += pad; | |
789 | pos += obj_datasec (abfd)->_raw_size; | |
790 | execp->a_data = obj_datasec (abfd)->_raw_size; | |
791 | ||
792 | /* BSS. */ | |
793 | obj_bsssec (abfd)->vma = vma; | |
794 | obj_bsssec (abfd)->user_set_vma = 1; | |
795 | ||
c4dfa77f | 796 | /* We are fully resized, so don't readjust in final_link. */ |
252b5132 RH |
797 | adata (abfd).magic = z_magic; |
798 | ||
799 | return NAME (aout, final_link) (abfd, info, MY_final_link_callback); | |
800 | } | |
801 | ||
802 | #endif | |
803 | ||
804 | enum machine_type | |
805 | tic30_aout_machine_type (arch, machine, unknown) | |
806 | enum bfd_architecture arch; | |
5f771d47 | 807 | unsigned long machine ATTRIBUTE_UNUSED; |
b34976b6 | 808 | bfd_boolean *unknown; |
252b5132 RH |
809 | { |
810 | enum machine_type arch_flags; | |
811 | ||
812 | arch_flags = M_UNKNOWN; | |
b34976b6 | 813 | *unknown = TRUE; |
252b5132 RH |
814 | |
815 | switch (arch) | |
816 | { | |
817 | case bfd_arch_tic30: | |
b34976b6 | 818 | *unknown = FALSE; |
252b5132 RH |
819 | break; |
820 | default: | |
821 | arch_flags = M_UNKNOWN; | |
822 | } | |
823 | if (arch_flags != M_UNKNOWN) | |
b34976b6 | 824 | *unknown = FALSE; |
252b5132 RH |
825 | return arch_flags; |
826 | } | |
827 | ||
b34976b6 | 828 | bfd_boolean |
252b5132 RH |
829 | tic30_aout_set_arch_mach (abfd, arch, machine) |
830 | bfd *abfd; | |
831 | enum bfd_architecture arch; | |
832 | unsigned long machine; | |
833 | { | |
834 | if (!bfd_default_set_arch_mach (abfd, arch, machine)) | |
b34976b6 | 835 | return FALSE; |
252b5132 RH |
836 | if (arch != bfd_arch_unknown) |
837 | { | |
b34976b6 | 838 | bfd_boolean unknown; |
252b5132 RH |
839 | tic30_aout_machine_type (arch, machine, &unknown); |
840 | if (unknown) | |
b34976b6 | 841 | return FALSE; |
252b5132 RH |
842 | } |
843 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; | |
844 | return (*aout_backend_info (abfd)->set_sizes) (abfd); | |
845 | } | |
846 | ||
847 | /* We assume BFD generic archive files. */ | |
848 | #ifndef MY_openr_next_archived_file | |
849 | #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file | |
850 | #endif | |
851 | #ifndef MY_get_elt_at_index | |
852 | #define MY_get_elt_at_index _bfd_generic_get_elt_at_index | |
853 | #endif | |
854 | #ifndef MY_generic_stat_arch_elt | |
855 | #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
856 | #endif | |
857 | #ifndef MY_slurp_armap | |
858 | #define MY_slurp_armap bfd_slurp_bsd_armap | |
859 | #endif | |
860 | #ifndef MY_slurp_extended_name_table | |
861 | #define MY_slurp_extended_name_table _bfd_slurp_extended_name_table | |
862 | #endif | |
863 | #ifndef MY_construct_extended_name_table | |
864 | #define MY_construct_extended_name_table \ | |
865 | _bfd_archive_bsd_construct_extended_name_table | |
866 | #endif | |
867 | #ifndef MY_write_armap | |
868 | #define MY_write_armap bsd_write_armap | |
869 | #endif | |
870 | #ifndef MY_read_ar_hdr | |
871 | #define MY_read_ar_hdr _bfd_generic_read_ar_hdr | |
872 | #endif | |
873 | #ifndef MY_truncate_arname | |
874 | #define MY_truncate_arname bfd_bsd_truncate_arname | |
875 | #endif | |
876 | #ifndef MY_update_armap_timestamp | |
877 | #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp | |
878 | #endif | |
879 | ||
880 | /* No core file defined here -- configure in trad-core.c separately. */ | |
881 | #ifndef MY_core_file_failing_command | |
882 | #define MY_core_file_failing_command _bfd_nocore_core_file_failing_command | |
883 | #endif | |
884 | #ifndef MY_core_file_failing_signal | |
885 | #define MY_core_file_failing_signal _bfd_nocore_core_file_failing_signal | |
886 | #endif | |
887 | #ifndef MY_core_file_matches_executable_p | |
888 | #define MY_core_file_matches_executable_p \ | |
889 | _bfd_nocore_core_file_matches_executable_p | |
890 | #endif | |
891 | #ifndef MY_core_file_p | |
892 | #define MY_core_file_p _bfd_dummy_target | |
893 | #endif | |
894 | ||
895 | #ifndef MY_bfd_debug_info_start | |
896 | #define MY_bfd_debug_info_start bfd_void | |
897 | #endif | |
898 | #ifndef MY_bfd_debug_info_end | |
899 | #define MY_bfd_debug_info_end bfd_void | |
900 | #endif | |
901 | #ifndef MY_bfd_debug_info_accumulate | |
902 | #define MY_bfd_debug_info_accumulate \ | |
198beae2 | 903 | (void (*) PARAMS ((bfd*, struct bfd_section *))) bfd_void |
252b5132 RH |
904 | #endif |
905 | ||
906 | #ifndef MY_core_file_failing_command | |
907 | #define MY_core_file_failing_command NAME(aout,core_file_failing_command) | |
908 | #endif | |
909 | #ifndef MY_core_file_failing_signal | |
910 | #define MY_core_file_failing_signal NAME(aout,core_file_failing_signal) | |
911 | #endif | |
912 | #ifndef MY_core_file_matches_executable_p | |
913 | #define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p) | |
914 | #endif | |
915 | #ifndef MY_set_section_contents | |
916 | #define MY_set_section_contents NAME(aout,set_section_contents) | |
917 | #endif | |
918 | #ifndef MY_get_section_contents | |
919 | #define MY_get_section_contents aout_32_get_section_contents | |
920 | #endif | |
921 | #ifndef MY_get_section_contents_in_window | |
922 | #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window | |
923 | #endif | |
924 | #ifndef MY_new_section_hook | |
925 | #define MY_new_section_hook NAME(aout,new_section_hook) | |
926 | #endif | |
927 | #ifndef MY_get_symtab_upper_bound | |
928 | #define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound) | |
929 | #endif | |
6cee3f79 AC |
930 | #ifndef MY_canonicalize_symtab |
931 | #define MY_canonicalize_symtab NAME(aout,canonicalize_symtab) | |
252b5132 RH |
932 | #endif |
933 | #ifndef MY_get_reloc_upper_bound | |
934 | #define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound) | |
935 | #endif | |
936 | #ifndef MY_canonicalize_reloc | |
937 | #define MY_canonicalize_reloc NAME(aout,canonicalize_reloc) | |
938 | #endif | |
939 | #ifndef MY_make_empty_symbol | |
940 | #define MY_make_empty_symbol NAME(aout,make_empty_symbol) | |
941 | #endif | |
942 | #ifndef MY_print_symbol | |
943 | #define MY_print_symbol NAME(aout,print_symbol) | |
944 | #endif | |
945 | #ifndef MY_get_symbol_info | |
946 | #define MY_get_symbol_info NAME(aout,get_symbol_info) | |
947 | #endif | |
948 | #ifndef MY_get_lineno | |
949 | #define MY_get_lineno NAME(aout,get_lineno) | |
950 | #endif | |
951 | #ifndef MY_set_arch_mach | |
952 | #define MY_set_arch_mach tic30_aout_set_arch_mach | |
953 | #endif | |
954 | #ifndef MY_find_nearest_line | |
955 | #define MY_find_nearest_line NAME(aout,find_nearest_line) | |
956 | #endif | |
957 | #ifndef MY_sizeof_headers | |
958 | #define MY_sizeof_headers NAME(aout,sizeof_headers) | |
959 | #endif | |
960 | #ifndef MY_bfd_get_relocated_section_contents | |
961 | #define MY_bfd_get_relocated_section_contents \ | |
962 | bfd_generic_get_relocated_section_contents | |
963 | #endif | |
964 | #ifndef MY_bfd_relax_section | |
965 | #define MY_bfd_relax_section bfd_generic_relax_section | |
966 | #endif | |
967 | #ifndef MY_bfd_gc_sections | |
968 | #define MY_bfd_gc_sections bfd_generic_gc_sections | |
969 | #endif | |
8550eb6e JJ |
970 | #ifndef MY_bfd_merge_sections |
971 | #define MY_bfd_merge_sections bfd_generic_merge_sections | |
972 | #endif | |
72adc230 AM |
973 | #ifndef MY_bfd_is_group_section |
974 | #define MY_bfd_is_group_section bfd_generic_is_group_section | |
975 | #endif | |
e61463e1 AM |
976 | #ifndef MY_bfd_discard_group |
977 | #define MY_bfd_discard_group bfd_generic_discard_group | |
978 | #endif | |
252b5132 RH |
979 | #ifndef MY_bfd_reloc_type_lookup |
980 | #define MY_bfd_reloc_type_lookup tic30_aout_reloc_type_lookup | |
981 | #endif | |
982 | #ifndef MY_bfd_make_debug_symbol | |
983 | #define MY_bfd_make_debug_symbol 0 | |
984 | #endif | |
985 | #ifndef MY_read_minisymbols | |
986 | #define MY_read_minisymbols NAME(aout,read_minisymbols) | |
987 | #endif | |
988 | #ifndef MY_minisymbol_to_symbol | |
989 | #define MY_minisymbol_to_symbol NAME(aout,minisymbol_to_symbol) | |
990 | #endif | |
991 | #ifndef MY_bfd_link_hash_table_create | |
992 | #define MY_bfd_link_hash_table_create NAME(aout,link_hash_table_create) | |
993 | #endif | |
e2d34d7d DJ |
994 | #ifndef MY_bfd_link_hash_table_free |
995 | #define MY_bfd_link_hash_table_free _bfd_generic_link_hash_table_free | |
996 | #endif | |
252b5132 RH |
997 | #ifndef MY_bfd_link_add_symbols |
998 | #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols) | |
999 | #endif | |
2d653fc7 AM |
1000 | #ifndef MY_bfd_link_just_syms |
1001 | #define MY_bfd_link_just_syms _bfd_generic_link_just_syms | |
1002 | #endif | |
252b5132 RH |
1003 | #ifndef MY_bfd_link_split_section |
1004 | #define MY_bfd_link_split_section _bfd_generic_link_split_section | |
1005 | #endif | |
1006 | ||
252b5132 RH |
1007 | #ifndef MY_bfd_copy_private_bfd_data |
1008 | #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data | |
1009 | #endif | |
1010 | ||
1011 | #ifndef MY_bfd_merge_private_bfd_data | |
1012 | #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data | |
1013 | #endif | |
1014 | ||
1015 | #ifndef MY_bfd_copy_private_symbol_data | |
1016 | #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data | |
1017 | #endif | |
1018 | ||
1019 | #ifndef MY_bfd_print_private_bfd_data | |
1020 | #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data | |
1021 | #endif | |
1022 | ||
1023 | #ifndef MY_bfd_set_private_flags | |
1024 | #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags | |
1025 | #endif | |
1026 | ||
1027 | #ifndef MY_bfd_is_local_label_name | |
1028 | #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name | |
1029 | #endif | |
1030 | ||
1031 | #ifndef MY_bfd_free_cached_info | |
1032 | #define MY_bfd_free_cached_info NAME(aout,bfd_free_cached_info) | |
1033 | #endif | |
1034 | ||
1035 | #ifndef MY_close_and_cleanup | |
1036 | #define MY_close_and_cleanup MY_bfd_free_cached_info | |
1037 | #endif | |
1038 | ||
1039 | #ifndef MY_get_dynamic_symtab_upper_bound | |
1040 | #define MY_get_dynamic_symtab_upper_bound \ | |
1041 | _bfd_nodynamic_get_dynamic_symtab_upper_bound | |
1042 | #endif | |
1043 | #ifndef MY_canonicalize_dynamic_symtab | |
1044 | #define MY_canonicalize_dynamic_symtab \ | |
1045 | _bfd_nodynamic_canonicalize_dynamic_symtab | |
1046 | #endif | |
4c45e5c9 JJ |
1047 | #ifndef MY_get_synthetic_symtab |
1048 | #define MY_get_synthetic_symtab \ | |
1049 | _bfd_nodynamic_get_synthetic_symtab | |
1050 | #endif | |
252b5132 RH |
1051 | #ifndef MY_get_dynamic_reloc_upper_bound |
1052 | #define MY_get_dynamic_reloc_upper_bound \ | |
1053 | _bfd_nodynamic_get_dynamic_reloc_upper_bound | |
1054 | #endif | |
1055 | #ifndef MY_canonicalize_dynamic_reloc | |
1056 | #define MY_canonicalize_dynamic_reloc \ | |
1057 | _bfd_nodynamic_canonicalize_dynamic_reloc | |
1058 | #endif | |
1059 | ||
1060 | /* Aout symbols normally have leading underscores */ | |
1061 | #ifndef MY_symbol_leading_char | |
1062 | #define MY_symbol_leading_char '_' | |
1063 | #endif | |
1064 | ||
1065 | /* Aout archives normally use spaces for padding */ | |
1066 | #ifndef AR_PAD_CHAR | |
1067 | #define AR_PAD_CHAR ' ' | |
1068 | #endif | |
1069 | ||
1070 | #ifndef MY_BFD_TARGET | |
1071 | const bfd_target tic30_aout_vec = | |
1072 | { | |
1073 | TARGETNAME, /* name */ | |
1074 | bfd_target_aout_flavour, | |
1075 | BFD_ENDIAN_BIG, /* target byte order (big) */ | |
1076 | BFD_ENDIAN_BIG, /* target headers byte order (big) */ | |
1077 | (HAS_RELOC | /* object flags */ | |
1078 | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), | |
1079 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
1080 | MY_symbol_leading_char, | |
1081 | AR_PAD_CHAR, /* ar_pad_char */ | |
1082 | 15, /* ar_max_namelen */ | |
1083 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
1084 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
1085 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ | |
1086 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
1087 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
1088 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
1089 | {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ | |
1090 | bfd_generic_archive_p, MY_core_file_p}, | |
1091 | {bfd_false, MY_mkobject, /* bfd_set_format */ | |
1092 | _bfd_generic_mkarchive, bfd_false}, | |
1093 | {bfd_false, MY_write_object_contents, /* bfd_write_contents */ | |
1094 | _bfd_write_archive_contents, bfd_false}, | |
1095 | ||
1096 | BFD_JUMP_TABLE_GENERIC (MY), | |
1097 | BFD_JUMP_TABLE_COPY (MY), | |
1098 | BFD_JUMP_TABLE_CORE (MY), | |
1099 | BFD_JUMP_TABLE_ARCHIVE (MY), | |
1100 | BFD_JUMP_TABLE_SYMBOLS (MY), | |
1101 | BFD_JUMP_TABLE_RELOCS (MY), | |
1102 | BFD_JUMP_TABLE_WRITE (MY), | |
1103 | BFD_JUMP_TABLE_LINK (MY), | |
1104 | BFD_JUMP_TABLE_DYNAMIC (MY), | |
1105 | ||
c3c89269 | 1106 | NULL, |
c4dfa77f | 1107 | |
c3c89269 | 1108 | (PTR) MY_backend_data |
252b5132 RH |
1109 | }; |
1110 | #endif /* MY_BFD_TARGET */ |